@shopify/hydrogen 2026.10.0-preview.4 → 2026.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/index.mjs +23 -12
- package/dist/client/client.d.mts +18 -15
- package/dist/client/client.mjs +8 -3
- package/dist/client/client.mjs.map +1 -1
- package/dist/client/errors.d.mts +35 -13
- package/dist/client/errors.mjs +23 -13
- package/dist/client/errors.mjs.map +1 -1
- package/dist/client/types.d.mts +140 -90
- package/dist/core/analytics/cart-tracker.d.mts +19 -10
- package/dist/core/analytics/cart-tracker.mjs +18 -10
- package/dist/core/analytics/cart-tracker.mjs.map +1 -1
- package/dist/core/analytics/events.d.mts +17 -11
- package/dist/core/analytics/events.mjs +13 -4
- package/dist/core/analytics/events.mjs.map +1 -1
- package/dist/core/analytics/types.d.mts +207 -118
- package/dist/core/analytics/utils/flatten-connection.d.mts +11 -9
- package/dist/core/analytics/utils/flatten-connection.mjs +7 -6
- package/dist/core/analytics/utils/flatten-connection.mjs.map +1 -1
- package/dist/core/cache/fetch-with-cache.d.mts +24 -4
- package/dist/core/cache/fetch-with-cache.mjs +17 -2
- package/dist/core/cache/fetch-with-cache.mjs.map +1 -1
- package/dist/core/cache/key.d.mts +2 -0
- package/dist/core/cache/key.mjs.map +1 -1
- package/dist/core/cache/run-with-cache.d.mts +56 -8
- package/dist/core/cache/run-with-cache.mjs +17 -6
- package/dist/core/cache/run-with-cache.mjs.map +1 -1
- package/dist/core/cache/store.d.mts +8 -6
- package/dist/core/cache/store.mjs.map +1 -1
- package/dist/core/cache/strategies.d.mts +27 -2
- package/dist/core/cache/strategies.mjs +6 -0
- package/dist/core/cache/strategies.mjs.map +1 -1
- package/dist/core/cart/actions.d.mts +37 -30
- package/dist/core/cart/actions.mjs +21 -9
- package/dist/core/cart/actions.mjs.map +1 -1
- package/dist/core/cart/attach-quantity-input.d.mts +8 -7
- package/dist/core/cart/attach-quantity-input.mjs +8 -7
- package/dist/core/cart/attach-quantity-input.mjs.map +1 -1
- package/dist/core/cart/buyer-identity-sync.d.mts +7 -6
- package/dist/core/cart/buyer-identity-sync.mjs.map +1 -1
- package/dist/core/cart/cart.d.mts +59 -46
- package/dist/core/cart/cart.mjs +46 -29
- package/dist/core/cart/cart.mjs.map +1 -1
- package/dist/core/cart/cookie.d.mts +8 -4
- package/dist/core/cart/cookie.mjs +8 -4
- package/dist/core/cart/cookie.mjs.map +1 -1
- package/dist/core/cart/form.d.mts +34 -20
- package/dist/core/cart/form.mjs +6 -4
- package/dist/core/cart/form.mjs.map +1 -1
- package/dist/core/cart/get-cart.d.mts +27 -15
- package/dist/core/cart/get-cart.mjs +13 -8
- package/dist/core/cart/get-cart.mjs.map +1 -1
- package/dist/core/cart/quantity.d.mts +16 -5
- package/dist/core/cart/quantity.mjs +16 -5
- package/dist/core/cart/quantity.mjs.map +1 -1
- package/dist/core/cart/queries.d.mts +25 -19
- package/dist/core/cart/queries.mjs +15 -1
- package/dist/core/cart/queries.mjs.map +1 -1
- package/dist/core/cart/server-handlers.d.mts +82 -45
- package/dist/core/cart/server-handlers.mjs +4 -0
- package/dist/core/cart/server-handlers.mjs.map +1 -1
- package/dist/core/cart/state.d.mts +110 -64
- package/dist/core/cart/state.mjs +24 -6
- package/dist/core/cart/state.mjs.map +1 -1
- package/dist/core/collection/collection.d.mts +52 -53
- package/dist/core/collection/collection.mjs +5 -3
- package/dist/core/collection/collection.mjs.map +1 -1
- package/dist/core/collection/reconciler.d.mts +23 -16
- package/dist/core/collection/reconciler.mjs +8 -4
- package/dist/core/collection/reconciler.mjs.map +1 -1
- package/dist/core/collection/state.d.mts +31 -26
- package/dist/core/collection/state.mjs +4 -3
- package/dist/core/collection/state.mjs.map +1 -1
- package/dist/core/collection/url.d.mts +70 -29
- package/dist/core/collection/url.mjs +63 -25
- package/dist/core/collection/url.mjs.map +1 -1
- package/dist/core/constants.d.mts +1 -0
- package/dist/core/constants.mjs +1 -0
- package/dist/core/constants.mjs.map +1 -1
- package/dist/core/logging/logging.d.mts +14 -8
- package/dist/core/logging/logging.mjs +15 -10
- package/dist/core/logging/logging.mjs.map +1 -1
- package/dist/core/logging/types.d.mts +28 -11
- package/dist/core/logging/types.mjs.map +1 -1
- package/dist/core/money/format.d.mts +6 -4
- package/dist/core/money/format.mjs +19 -9
- package/dist/core/money/format.mjs.map +1 -1
- package/dist/core/money/types.d.mts +41 -25
- package/dist/core/predictive-search/form.d.mts +37 -7
- package/dist/core/predictive-search/form.mjs +21 -3
- package/dist/core/predictive-search/form.mjs.map +1 -1
- package/dist/core/predictive-search/queries.d.mts +18 -30
- package/dist/core/predictive-search/queries.mjs +7 -3
- package/dist/core/predictive-search/queries.mjs.map +1 -1
- package/dist/core/predictive-search/search.d.mts +25 -27
- package/dist/core/predictive-search/search.mjs +20 -19
- package/dist/core/predictive-search/search.mjs.map +1 -1
- package/dist/core/predictive-search/server-handlers.d.mts +25 -26
- package/dist/core/predictive-search/server-handlers.mjs +4 -0
- package/dist/core/predictive-search/server-handlers.mjs.map +1 -1
- package/dist/core/predictive-search/store.d.mts +65 -24
- package/dist/core/predictive-search/store.mjs +12 -1
- package/dist/core/predictive-search/store.mjs.map +1 -1
- package/dist/core/predictive-search/url.d.mts +36 -37
- package/dist/core/predictive-search/url.mjs +14 -6
- package/dist/core/predictive-search/url.mjs.map +1 -1
- package/dist/core/product/form.d.mts +63 -16
- package/dist/core/product/form.mjs +8 -2
- package/dist/core/product/form.mjs.map +1 -1
- package/dist/core/product/options.d.mts +8 -10
- package/dist/core/product/options.mjs +8 -10
- package/dist/core/product/options.mjs.map +1 -1
- package/dist/core/product/product-form.d.mts +77 -29
- package/dist/core/product/product-form.mjs +32 -10
- package/dist/core/product/product-form.mjs.map +1 -1
- package/dist/core/product/state.d.mts +55 -32
- package/dist/core/product/url.d.mts +19 -13
- package/dist/core/product/url.mjs +10 -10
- package/dist/core/product/url.mjs.map +1 -1
- package/dist/core/request-context.d.mts +77 -19
- package/dist/core/request-context.mjs +5 -1
- package/dist/core/request-context.mjs.map +1 -1
- package/dist/core/request-routing/handle-shopify-redirects.d.mts +12 -4
- package/dist/core/request-routing/handle-shopify-redirects.mjs +9 -2
- package/dist/core/request-routing/handle-shopify-redirects.mjs.map +1 -1
- package/dist/core/request-routing/handle-shopify-routes.d.mts +5 -5
- package/dist/core/request-routing/handle-shopify-routes.mjs +7 -5
- package/dist/core/request-routing/handle-shopify-routes.mjs.map +1 -1
- package/dist/core/request-routing/interceptors/proxy.mjs +79 -43
- package/dist/core/request-routing/interceptors/proxy.mjs.map +1 -1
- package/dist/core/request-routing/interceptors/ucp-profile-proxy.mjs +69 -0
- package/dist/core/request-routing/interceptors/ucp-profile-proxy.mjs.map +1 -0
- package/dist/core/request-routing/interceptors/url-redirects.mjs +6 -1
- package/dist/core/request-routing/interceptors/url-redirects.mjs.map +1 -1
- package/dist/core/request-routing/interceptors/well-known.mjs +1 -1
- package/dist/core/request-routing/interceptors/well-known.mjs.map +1 -1
- package/dist/core/request-routing/registered-routes.d.mts +12 -0
- package/dist/core/request-routing/registered-routes.mjs +12 -0
- package/dist/core/request-routing/registered-routes.mjs.map +1 -1
- package/dist/core/request-routing/route-types.d.mts +43 -18
- package/dist/core/shop-pay/shop-pay.d.mts +71 -35
- package/dist/core/shop-pay/shop-pay.mjs +36 -10
- package/dist/core/shop-pay/shop-pay.mjs.map +1 -1
- package/dist/core/shopify-scripts/index.d.mts +15 -5
- package/dist/core/shopify-scripts/index.mjs +15 -5
- package/dist/core/shopify-scripts/index.mjs.map +1 -1
- package/dist/core/shopify-scripts/initialize.d.mts +12 -4
- package/dist/core/shopify-scripts/initialize.mjs +12 -4
- package/dist/core/shopify-scripts/initialize.mjs.map +1 -1
- package/dist/core/shopify-scripts/types.d.mts +58 -25
- package/dist/core/standard-routes/build.d.mts +11 -12
- package/dist/core/standard-routes/build.mjs +11 -12
- package/dist/core/standard-routes/build.mjs.map +1 -1
- package/dist/core/standard-routes/types.d.mts +30 -24
- package/dist/core/url.mjs +2 -1
- package/dist/core/url.mjs.map +1 -1
- package/dist/customer-account/client.d.mts +36 -69
- package/dist/customer-account/client.mjs +7 -8
- package/dist/customer-account/client.mjs.map +1 -1
- package/dist/customer-account/errors.d.mts +45 -36
- package/dist/customer-account/errors.mjs +21 -36
- package/dist/customer-account/errors.mjs.map +1 -1
- package/dist/customer-account/graphql.d.mts +11 -23
- package/dist/customer-account/graphql.mjs +3 -9
- package/dist/customer-account/graphql.mjs.map +1 -1
- package/dist/customer-account/session.d.mts +130 -100
- package/dist/customer-account/session.mjs +32 -10
- package/dist/customer-account/session.mjs.map +1 -1
- package/dist/customer-account/type-resolver.d.mts +7 -8
- package/dist/development/client/client.d.mts +18 -15
- package/dist/development/client/client.mjs +8 -3
- package/dist/development/client/client.mjs.map +1 -1
- package/dist/development/client/errors.d.mts +35 -13
- package/dist/development/client/errors.mjs +23 -13
- package/dist/development/client/errors.mjs.map +1 -1
- package/dist/development/client/types.d.mts +140 -90
- package/dist/development/core/analytics/cart-tracker.d.mts +19 -10
- package/dist/development/core/analytics/cart-tracker.mjs +18 -10
- package/dist/development/core/analytics/cart-tracker.mjs.map +1 -1
- package/dist/development/core/analytics/events.d.mts +17 -11
- package/dist/development/core/analytics/events.mjs +13 -4
- package/dist/development/core/analytics/events.mjs.map +1 -1
- package/dist/development/core/analytics/types.d.mts +207 -118
- package/dist/development/core/analytics/utils/flatten-connection.d.mts +11 -9
- package/dist/development/core/analytics/utils/flatten-connection.mjs +7 -6
- package/dist/development/core/analytics/utils/flatten-connection.mjs.map +1 -1
- package/dist/development/core/cache/fetch-with-cache.d.mts +24 -4
- package/dist/development/core/cache/fetch-with-cache.mjs +17 -2
- package/dist/development/core/cache/fetch-with-cache.mjs.map +1 -1
- package/dist/development/core/cache/key.d.mts +2 -0
- package/dist/development/core/cache/key.mjs.map +1 -1
- package/dist/development/core/cache/run-with-cache.d.mts +56 -8
- package/dist/development/core/cache/run-with-cache.mjs +17 -6
- package/dist/development/core/cache/run-with-cache.mjs.map +1 -1
- package/dist/development/core/cache/store.d.mts +8 -6
- package/dist/development/core/cache/store.mjs.map +1 -1
- package/dist/development/core/cache/strategies.d.mts +27 -2
- package/dist/development/core/cache/strategies.mjs +6 -0
- package/dist/development/core/cache/strategies.mjs.map +1 -1
- package/dist/development/core/cart/actions.d.mts +37 -30
- package/dist/development/core/cart/actions.mjs +21 -9
- package/dist/development/core/cart/actions.mjs.map +1 -1
- package/dist/development/core/cart/attach-quantity-input.d.mts +8 -7
- package/dist/development/core/cart/attach-quantity-input.mjs +8 -7
- package/dist/development/core/cart/attach-quantity-input.mjs.map +1 -1
- package/dist/development/core/cart/buyer-identity-sync.d.mts +6 -5
- package/dist/development/core/cart/buyer-identity-sync.mjs.map +1 -1
- package/dist/development/core/cart/cart.d.mts +59 -46
- package/dist/development/core/cart/cart.mjs +46 -29
- package/dist/development/core/cart/cart.mjs.map +1 -1
- package/dist/development/core/cart/cookie.d.mts +8 -4
- package/dist/development/core/cart/cookie.mjs +8 -4
- package/dist/development/core/cart/cookie.mjs.map +1 -1
- package/dist/development/core/cart/form.d.mts +34 -20
- package/dist/development/core/cart/form.mjs +6 -4
- package/dist/development/core/cart/form.mjs.map +1 -1
- package/dist/development/core/cart/get-cart.d.mts +27 -15
- package/dist/development/core/cart/get-cart.mjs +13 -8
- package/dist/development/core/cart/get-cart.mjs.map +1 -1
- package/dist/development/core/cart/quantity.d.mts +16 -5
- package/dist/development/core/cart/quantity.mjs +16 -5
- package/dist/development/core/cart/quantity.mjs.map +1 -1
- package/dist/development/core/cart/queries.d.mts +25 -19
- package/dist/development/core/cart/queries.mjs +15 -1
- package/dist/development/core/cart/queries.mjs.map +1 -1
- package/dist/development/core/cart/server-handlers.d.mts +82 -45
- package/dist/development/core/cart/server-handlers.mjs +4 -0
- package/dist/development/core/cart/server-handlers.mjs.map +1 -1
- package/dist/development/core/cart/state.d.mts +110 -64
- package/dist/development/core/cart/state.mjs +24 -6
- package/dist/development/core/cart/state.mjs.map +1 -1
- package/dist/development/core/collection/collection.d.mts +52 -53
- package/dist/development/core/collection/collection.mjs +5 -3
- package/dist/development/core/collection/collection.mjs.map +1 -1
- package/dist/development/core/collection/reconciler.d.mts +23 -16
- package/dist/development/core/collection/reconciler.mjs +8 -4
- package/dist/development/core/collection/reconciler.mjs.map +1 -1
- package/dist/development/core/collection/state.d.mts +31 -26
- package/dist/development/core/collection/state.mjs +4 -3
- package/dist/development/core/collection/state.mjs.map +1 -1
- package/dist/development/core/collection/url.d.mts +70 -29
- package/dist/development/core/collection/url.mjs +63 -25
- package/dist/development/core/collection/url.mjs.map +1 -1
- package/dist/development/core/constants.mjs.map +1 -1
- package/dist/development/core/logging/logging.d.mts +14 -8
- package/dist/development/core/logging/logging.mjs +15 -10
- package/dist/development/core/logging/logging.mjs.map +1 -1
- package/dist/development/core/logging/types.d.mts +28 -11
- package/dist/development/core/logging/types.mjs.map +1 -1
- package/dist/development/core/money/format.d.mts +6 -4
- package/dist/development/core/money/format.mjs +19 -9
- package/dist/development/core/money/format.mjs.map +1 -1
- package/dist/development/core/money/types.d.mts +41 -25
- package/dist/development/core/predictive-search/form.d.mts +37 -7
- package/dist/development/core/predictive-search/form.mjs +21 -3
- package/dist/development/core/predictive-search/form.mjs.map +1 -1
- package/dist/development/core/predictive-search/queries.d.mts +18 -30
- package/dist/development/core/predictive-search/queries.mjs +7 -3
- package/dist/development/core/predictive-search/queries.mjs.map +1 -1
- package/dist/development/core/predictive-search/search.d.mts +25 -27
- package/dist/development/core/predictive-search/search.mjs +20 -19
- package/dist/development/core/predictive-search/search.mjs.map +1 -1
- package/dist/development/core/predictive-search/server-handlers.d.mts +25 -26
- package/dist/development/core/predictive-search/server-handlers.mjs +4 -0
- package/dist/development/core/predictive-search/server-handlers.mjs.map +1 -1
- package/dist/development/core/predictive-search/store.d.mts +65 -24
- package/dist/development/core/predictive-search/store.mjs +12 -1
- package/dist/development/core/predictive-search/store.mjs.map +1 -1
- package/dist/development/core/predictive-search/url.d.mts +36 -37
- package/dist/development/core/predictive-search/url.mjs +14 -6
- package/dist/development/core/predictive-search/url.mjs.map +1 -1
- package/dist/development/core/product/form.d.mts +63 -16
- package/dist/development/core/product/form.mjs +8 -2
- package/dist/development/core/product/form.mjs.map +1 -1
- package/dist/development/core/product/options.d.mts +8 -10
- package/dist/development/core/product/options.mjs +8 -10
- package/dist/development/core/product/options.mjs.map +1 -1
- package/dist/development/core/product/product-form.d.mts +77 -29
- package/dist/development/core/product/product-form.mjs +32 -10
- package/dist/development/core/product/product-form.mjs.map +1 -1
- package/dist/development/core/product/state.d.mts +55 -32
- package/dist/development/core/product/url.d.mts +19 -13
- package/dist/development/core/product/url.mjs +10 -10
- package/dist/development/core/product/url.mjs.map +1 -1
- package/dist/development/core/request-context.d.mts +77 -19
- package/dist/development/core/request-context.mjs +5 -1
- package/dist/development/core/request-context.mjs.map +1 -1
- package/dist/development/core/request-routing/handle-shopify-redirects.d.mts +12 -4
- package/dist/development/core/request-routing/handle-shopify-redirects.mjs +9 -2
- package/dist/development/core/request-routing/handle-shopify-redirects.mjs.map +1 -1
- package/dist/development/core/request-routing/handle-shopify-routes.development.d.mts +9 -1
- package/dist/development/core/request-routing/handle-shopify-routes.development.mjs +7 -0
- package/dist/development/core/request-routing/handle-shopify-routes.development.mjs.map +1 -1
- package/dist/development/core/request-routing/handle-shopify-routes.mjs +7 -5
- package/dist/development/core/request-routing/handle-shopify-routes.mjs.map +1 -1
- package/dist/development/core/request-routing/interceptors/proxy.mjs +79 -43
- package/dist/development/core/request-routing/interceptors/proxy.mjs.map +1 -1
- package/dist/development/core/request-routing/interceptors/ucp-profile-proxy.mjs +69 -0
- package/dist/development/core/request-routing/interceptors/ucp-profile-proxy.mjs.map +1 -0
- package/dist/development/core/request-routing/interceptors/url-redirects.mjs +6 -1
- package/dist/development/core/request-routing/interceptors/url-redirects.mjs.map +1 -1
- package/dist/development/core/request-routing/interceptors/well-known.mjs +1 -1
- package/dist/development/core/request-routing/interceptors/well-known.mjs.map +1 -1
- package/dist/development/core/request-routing/registered-routes.d.mts +12 -0
- package/dist/development/core/request-routing/registered-routes.mjs +12 -0
- package/dist/development/core/request-routing/registered-routes.mjs.map +1 -1
- package/dist/development/core/request-routing/route-types.d.mts +43 -18
- package/dist/development/core/shop-pay/shop-pay.d.mts +71 -35
- package/dist/development/core/shop-pay/shop-pay.mjs +36 -10
- package/dist/development/core/shop-pay/shop-pay.mjs.map +1 -1
- package/dist/development/core/shopify-scripts/index.d.mts +15 -5
- package/dist/development/core/shopify-scripts/index.mjs +15 -5
- package/dist/development/core/shopify-scripts/index.mjs.map +1 -1
- package/dist/development/core/shopify-scripts/initialize.d.mts +12 -4
- package/dist/development/core/shopify-scripts/initialize.mjs +12 -4
- package/dist/development/core/shopify-scripts/initialize.mjs.map +1 -1
- package/dist/development/core/shopify-scripts/types.d.mts +58 -25
- package/dist/development/core/standard-routes/build.d.mts +11 -12
- package/dist/development/core/standard-routes/build.mjs +11 -12
- package/dist/development/core/standard-routes/build.mjs.map +1 -1
- package/dist/development/core/standard-routes/types.d.mts +30 -24
- package/dist/development/core/url.mjs +2 -1
- package/dist/development/core/url.mjs.map +1 -1
- package/dist/development/customer-account/session.d.mts +45 -54
- package/dist/development/customer-account/session.mjs +20 -4
- package/dist/development/customer-account/session.mjs.map +1 -1
- package/dist/development/globals.d.mts +20 -11
- package/dist/development/graphql/generated/storefront-api-types.d.mts +127 -1
- package/dist/development/graphql/graphql.d.mts +17 -16
- package/dist/development/graphql/graphql.mjs +7 -8
- package/dist/development/graphql/graphql.mjs.map +1 -1
- package/dist/development/graphql/type-resolver.d.mts +15 -8
- package/dist/development/react/cart.d.mts +78 -32
- package/dist/development/react/cart.mjs +56 -29
- package/dist/development/react/cart.mjs.map +1 -1
- package/dist/development/react/collection.d.mts +40 -22
- package/dist/development/react/collection.mjs +27 -7
- package/dist/development/react/collection.mjs.map +1 -1
- package/dist/development/react/predictive-search.d.mts +65 -50
- package/dist/development/react/predictive-search.mjs +23 -21
- package/dist/development/react/predictive-search.mjs.map +1 -1
- package/dist/development/react/product.d.mts +45 -16
- package/dist/development/react/product.mjs +13 -11
- package/dist/development/react/product.mjs.map +1 -1
- package/dist/development/react/shop-pay.d.mts +15 -0
- package/dist/development/react/shop-pay.mjs +9 -0
- package/dist/development/react/shop-pay.mjs.map +1 -1
- package/dist/development/react/shopify-scripts.d.mts +23 -2
- package/dist/development/react/shopify-scripts.mjs +9 -0
- package/dist/development/react/shopify-scripts.mjs.map +1 -1
- package/dist/development/vue/cart.d.mts +28 -23
- package/dist/development/vue/cart.mjs +42 -25
- package/dist/development/vue/cart.mjs.map +1 -1
- package/dist/development/vue/collection.d.mts +20 -12
- package/dist/development/vue/collection.mjs +15 -7
- package/dist/development/vue/collection.mjs.map +1 -1
- package/dist/development/vue/index.d.mts +2 -2
- package/dist/development/vue/index.mjs +2 -2
- package/dist/development/vue/predictive-search.d.mts +31 -36
- package/dist/development/vue/predictive-search.mjs +16 -22
- package/dist/development/vue/predictive-search.mjs.map +1 -1
- package/dist/development/vue/product.d.mts +16 -15
- package/dist/development/vue/product.mjs +11 -11
- package/dist/development/vue/product.mjs.map +1 -1
- package/dist/development/vue/shop-pay.d.mts +14 -17
- package/dist/development/vue/shop-pay.mjs +8 -0
- package/dist/development/vue/shop-pay.mjs.map +1 -1
- package/dist/development/vue/shopify-scripts.d.mts +11 -0
- package/dist/development/vue/shopify-scripts.mjs +6 -0
- package/dist/development/vue/shopify-scripts.mjs.map +1 -1
- package/dist/globals.d.mts +20 -11
- package/dist/graphql/generated/storefront-api-types.d.mts +127 -1
- package/dist/graphql/graphql.d.mts +17 -16
- package/dist/graphql/graphql.mjs +7 -8
- package/dist/graphql/graphql.mjs.map +1 -1
- package/dist/graphql/type-resolver.d.mts +15 -8
- package/dist/react/cart.d.mts +78 -32
- package/dist/react/cart.mjs +56 -29
- package/dist/react/cart.mjs.map +1 -1
- package/dist/react/collection.d.mts +40 -22
- package/dist/react/collection.mjs +27 -7
- package/dist/react/collection.mjs.map +1 -1
- package/dist/react/predictive-search.d.mts +65 -50
- package/dist/react/predictive-search.mjs +23 -21
- package/dist/react/predictive-search.mjs.map +1 -1
- package/dist/react/product.d.mts +45 -16
- package/dist/react/product.mjs +13 -11
- package/dist/react/product.mjs.map +1 -1
- package/dist/react/shop-pay.d.mts +15 -0
- package/dist/react/shop-pay.mjs +9 -0
- package/dist/react/shop-pay.mjs.map +1 -1
- package/dist/react/shopify-scripts.d.mts +23 -2
- package/dist/react/shopify-scripts.mjs +9 -0
- package/dist/react/shopify-scripts.mjs.map +1 -1
- package/dist/ts-plugin/index.cjs +6 -0
- package/dist/ts-plugin/index.cjs.map +1 -1
- package/dist/ts-plugin/index.d.cts +6 -0
- package/dist/vite/local-https.d.mts +51 -17
- package/dist/vite/local-https.mjs +26 -5
- package/dist/vite/local-https.mjs.map +1 -1
- package/dist/vue/cart.d.mts +28 -23
- package/dist/vue/cart.mjs +42 -25
- package/dist/vue/cart.mjs.map +1 -1
- package/dist/vue/collection.d.mts +20 -12
- package/dist/vue/collection.mjs +15 -7
- package/dist/vue/collection.mjs.map +1 -1
- package/dist/vue/index.d.mts +2 -2
- package/dist/vue/index.mjs +2 -2
- package/dist/vue/predictive-search.d.mts +31 -36
- package/dist/vue/predictive-search.mjs +16 -22
- package/dist/vue/predictive-search.mjs.map +1 -1
- package/dist/vue/product.d.mts +16 -15
- package/dist/vue/product.mjs +11 -11
- package/dist/vue/product.mjs.map +1 -1
- package/dist/vue/shop-pay.d.mts +14 -17
- package/dist/vue/shop-pay.mjs +8 -0
- package/dist/vue/shop-pay.mjs.map +1 -1
- package/dist/vue/shopify-scripts.d.mts +11 -0
- package/dist/vue/shopify-scripts.mjs +6 -0
- package/dist/vue/shopify-scripts.mjs.map +1 -1
- package/package.json +3 -1
- package/skills/hydrogen-analytics/SKILL.md +1 -1
- package/skills/hydrogen-cart-ui/SKILL.md +28 -2
- package/skills/hydrogen-collection-browser/SKILL.md +9 -1
- package/skills/hydrogen-collection-browser/references/nextjs.md +1 -1
- package/skills/hydrogen-collection-browser/references/nuxt.md +1 -1
- package/skills/hydrogen-collection-browser/references/react.md +151 -32
- package/skills/hydrogen-customer-account/SKILL.md +2 -0
- package/skills/hydrogen-request-handlers/SKILL.md +21 -11
- package/skills/hydrogen-setup/references/analytics.md +14 -8
- package/skills/hydrogen-setup/steps/1-inspect-app.md +2 -2
- package/skills/hydrogen-setup/steps/6-product-detail-page.md +21 -11
- package/skills/hydrogen-storefront-client/SKILL.md +1 -1
- package/skills/hydrogen-storefront-client/references/caching.md +2 -0
- package/skills/hydrogen-variant-form/SKILL.md +25 -7
- package/skills/hydrogen-variant-form/references/nextjs.md +39 -4
- package/skills/hydrogen-variant-form/references/nuxt.md +83 -42
- package/skills/hydrogen-variant-form/references/react.md +45 -9
|
@@ -7,24 +7,37 @@ interface StorefrontApiErrorOptions {
|
|
|
7
7
|
variables?: Record<string, unknown>;
|
|
8
8
|
}
|
|
9
9
|
/**
|
|
10
|
-
*
|
|
11
|
-
*
|
|
10
|
+
* Signals that a Storefront API request failed. The client throws the error for an HTTP error
|
|
11
|
+
* status, a network failure, or a response body that isn't a JSON object.
|
|
12
12
|
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
13
|
+
* GraphQL errors, including `THROTTLED`, don't throw. Read GraphQL errors from the result's
|
|
14
|
+
* `errors` field.
|
|
15
|
+
*
|
|
16
|
+
* When the request context's signal or the call's `signal` aborts before the call, the client
|
|
17
|
+
* throws the abort reason and sends no request. An `AbortError` during the request reaches your
|
|
18
|
+
* code unchanged. Other abort reasons during the request throw a `StorefrontApiError`.
|
|
19
|
+
*
|
|
20
|
+
* @publicDocs
|
|
15
21
|
*/
|
|
16
22
|
declare class StorefrontApiError extends Error {
|
|
17
|
-
/**
|
|
23
|
+
/** The `x-request-id` header of the Storefront API response, when the response has one. Include the ID in support requests. */
|
|
18
24
|
readonly requestId?: string;
|
|
19
|
-
/** HTTP
|
|
25
|
+
/** The HTTP status code of the response, when the request reached the server. */
|
|
20
26
|
readonly status?: number;
|
|
21
|
-
/** The GraphQL query
|
|
27
|
+
/** The GraphQL query that failed. Hydrogen sets the value only in development builds. */
|
|
22
28
|
readonly queryText?: string;
|
|
23
|
-
/** The variables sent with the request.
|
|
29
|
+
/** The variables that the client sent with the request. Hydrogen sets the value only in development builds. */
|
|
24
30
|
readonly variables?: Record<string, unknown>;
|
|
31
|
+
/** `StorefrontApiError`. `StorefrontTimeoutError` sets its own class name. */
|
|
32
|
+
name: string;
|
|
33
|
+
/** Describes the failure, such as the HTTP status that the API returned. */
|
|
34
|
+
message: string;
|
|
35
|
+
/** The stack trace, when the JavaScript runtime records one. */
|
|
36
|
+
stack?: string;
|
|
25
37
|
constructor(message: string, options?: StorefrontApiErrorOptions);
|
|
38
|
+
/** Makes `Object.prototype.toString` report the error name, such as `[object StorefrontApiError]`. */
|
|
26
39
|
get [Symbol.toStringTag](): string;
|
|
27
|
-
/**
|
|
40
|
+
/** Returns the error name, message, request ID, and status for logging. The output leaves out the query text, variables, cause, and stack. */
|
|
28
41
|
toJSON(): {
|
|
29
42
|
name: string;
|
|
30
43
|
message: string;
|
|
@@ -33,14 +46,23 @@ declare class StorefrontApiError extends Error {
|
|
|
33
46
|
};
|
|
34
47
|
}
|
|
35
48
|
/**
|
|
36
|
-
*
|
|
49
|
+
* Signals that a Storefront API request ran longer than the client's `defaultTimeoutInMs` setting.
|
|
50
|
+
* Aborts from the request context or the call's `signal` throw other errors.
|
|
51
|
+
*
|
|
52
|
+
* `StorefrontTimeoutError` extends `StorefrontApiError`. Check for `StorefrontTimeoutError` first when
|
|
53
|
+
* you handle both errors.
|
|
37
54
|
*
|
|
38
|
-
*
|
|
39
|
-
* Aborts from the request context or a per-call `signal` are rethrown as-is, not wrapped.
|
|
55
|
+
* @publicDocs
|
|
40
56
|
*/
|
|
41
57
|
declare class StorefrontTimeoutError extends StorefrontApiError {
|
|
42
|
-
/** The timeout
|
|
58
|
+
/** The timeout that the request exceeded, in milliseconds. */
|
|
43
59
|
readonly timeoutInMs: number;
|
|
60
|
+
/** Always `StorefrontTimeoutError`. */
|
|
61
|
+
name: string;
|
|
62
|
+
/** States the timeout, such as `"Storefront API request timed out after 30000ms"`. */
|
|
63
|
+
message: string;
|
|
64
|
+
/** The stack trace, when the JavaScript runtime records one. */
|
|
65
|
+
stack?: string;
|
|
44
66
|
constructor(timeoutInMs: number, options?: Omit<StorefrontApiErrorOptions, "cause">);
|
|
45
67
|
}
|
|
46
68
|
//#endregion
|
|
@@ -1,19 +1,25 @@
|
|
|
1
1
|
//#region src/client/errors.ts
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
3
|
+
* Signals that a Storefront API request failed. The client throws the error for an HTTP error
|
|
4
|
+
* status, a network failure, or a response body that isn't a JSON object.
|
|
5
5
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
6
|
+
* GraphQL errors, including `THROTTLED`, don't throw. Read GraphQL errors from the result's
|
|
7
|
+
* `errors` field.
|
|
8
|
+
*
|
|
9
|
+
* When the request context's signal or the call's `signal` aborts before the call, the client
|
|
10
|
+
* throws the abort reason and sends no request. An `AbortError` during the request reaches your
|
|
11
|
+
* code unchanged. Other abort reasons during the request throw a `StorefrontApiError`.
|
|
12
|
+
*
|
|
13
|
+
* @publicDocs
|
|
8
14
|
*/
|
|
9
15
|
var StorefrontApiError = class extends Error {
|
|
10
|
-
/**
|
|
16
|
+
/** The `x-request-id` header of the Storefront API response, when the response has one. Include the ID in support requests. */
|
|
11
17
|
requestId;
|
|
12
|
-
/** HTTP
|
|
18
|
+
/** The HTTP status code of the response, when the request reached the server. */
|
|
13
19
|
status;
|
|
14
|
-
/** The GraphQL query
|
|
20
|
+
/** The GraphQL query that failed. Hydrogen sets the value only in development builds. */
|
|
15
21
|
queryText;
|
|
16
|
-
/** The variables sent with the request.
|
|
22
|
+
/** The variables that the client sent with the request. Hydrogen sets the value only in development builds. */
|
|
17
23
|
variables;
|
|
18
24
|
constructor(message, options) {
|
|
19
25
|
super(message, options?.cause ? { cause: options.cause } : void 0);
|
|
@@ -23,10 +29,11 @@ var StorefrontApiError = class extends Error {
|
|
|
23
29
|
this.queryText = options?.queryText;
|
|
24
30
|
this.variables = options?.variables;
|
|
25
31
|
}
|
|
32
|
+
/** Makes `Object.prototype.toString` report the error name, such as `[object StorefrontApiError]`. */
|
|
26
33
|
get [Symbol.toStringTag]() {
|
|
27
34
|
return this.name;
|
|
28
35
|
}
|
|
29
|
-
/**
|
|
36
|
+
/** Returns the error name, message, request ID, and status for logging. The output leaves out the query text, variables, cause, and stack. */
|
|
30
37
|
toJSON() {
|
|
31
38
|
return {
|
|
32
39
|
name: this.name,
|
|
@@ -37,13 +44,16 @@ var StorefrontApiError = class extends Error {
|
|
|
37
44
|
}
|
|
38
45
|
};
|
|
39
46
|
/**
|
|
40
|
-
*
|
|
47
|
+
* Signals that a Storefront API request ran longer than the client's `defaultTimeoutInMs` setting.
|
|
48
|
+
* Aborts from the request context or the call's `signal` throw other errors.
|
|
49
|
+
*
|
|
50
|
+
* `StorefrontTimeoutError` extends `StorefrontApiError`. Check for `StorefrontTimeoutError` first when
|
|
51
|
+
* you handle both errors.
|
|
41
52
|
*
|
|
42
|
-
*
|
|
43
|
-
* Aborts from the request context or a per-call `signal` are rethrown as-is, not wrapped.
|
|
53
|
+
* @publicDocs
|
|
44
54
|
*/
|
|
45
55
|
var StorefrontTimeoutError = class extends StorefrontApiError {
|
|
46
|
-
/** The timeout
|
|
56
|
+
/** The timeout that the request exceeded, in milliseconds. */
|
|
47
57
|
timeoutInMs;
|
|
48
58
|
constructor(timeoutInMs, options) {
|
|
49
59
|
super(`Storefront API request timed out after ${timeoutInMs}ms`, options);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.mjs","names":[],"sources":["../../../src/client/errors.ts"],"sourcesContent":["interface StorefrontApiErrorOptions {\n requestId?: string;\n status?: number;\n cause?: unknown;\n queryText?: string;\n variables?: Record<string, unknown>;\n}\n\n/**\n *
|
|
1
|
+
{"version":3,"file":"errors.mjs","names":[],"sources":["../../../src/client/errors.ts"],"sourcesContent":["interface StorefrontApiErrorOptions {\n requestId?: string;\n status?: number;\n cause?: unknown;\n queryText?: string;\n variables?: Record<string, unknown>;\n}\n\n/**\n * Signals that a Storefront API request failed. The client throws the error for an HTTP error\n * status, a network failure, or a response body that isn't a JSON object.\n *\n * GraphQL errors, including `THROTTLED`, don't throw. Read GraphQL errors from the result's\n * `errors` field.\n *\n * When the request context's signal or the call's `signal` aborts before the call, the client\n * throws the abort reason and sends no request. An `AbortError` during the request reaches your\n * code unchanged. Other abort reasons during the request throw a `StorefrontApiError`.\n *\n * @publicDocs\n */\nexport class StorefrontApiError extends Error {\n /** The `x-request-id` header of the Storefront API response, when the response has one. Include the ID in support requests. */\n readonly requestId?: string;\n /** The HTTP status code of the response, when the request reached the server. */\n readonly status?: number;\n /** The GraphQL query that failed. Hydrogen sets the value only in development builds. */\n readonly queryText?: string;\n /** The variables that the client sent with the request. Hydrogen sets the value only in development builds. */\n readonly variables?: Record<string, unknown>;\n\n /** `StorefrontApiError`. `StorefrontTimeoutError` sets its own class name. */\n declare name: string;\n /** Describes the failure, such as the HTTP status that the API returned. */\n declare message: string;\n /** The stack trace, when the JavaScript runtime records one. */\n declare stack?: string;\n\n constructor(message: string, options?: StorefrontApiErrorOptions) {\n super(message, options?.cause ? { cause: options.cause } : undefined);\n this.name = \"StorefrontApiError\";\n this.requestId = options?.requestId;\n this.status = options?.status;\n\n if (__DEV__) {\n this.queryText = options?.queryText;\n this.variables = options?.variables;\n }\n }\n\n /** Makes `Object.prototype.toString` report the error name, such as `[object StorefrontApiError]`. */\n get [Symbol.toStringTag]() {\n return this.name;\n }\n\n /** Returns the error name, message, request ID, and status for logging. The output leaves out the query text, variables, cause, and stack. */\n toJSON(): { name: string; message: string; requestId?: string; status?: number } {\n return {\n name: this.name,\n message: this.message,\n ...(this.requestId != null && { requestId: this.requestId }),\n ...(this.status != null && { status: this.status }),\n };\n }\n}\n\n/**\n * Signals that a Storefront API request ran longer than the client's `defaultTimeoutInMs` setting.\n * Aborts from the request context or the call's `signal` throw other errors.\n *\n * `StorefrontTimeoutError` extends `StorefrontApiError`. Check for `StorefrontTimeoutError` first when\n * you handle both errors.\n *\n * @publicDocs\n */\nexport class StorefrontTimeoutError extends StorefrontApiError {\n /** The timeout that the request exceeded, in milliseconds. */\n readonly timeoutInMs: number;\n\n /** Always `StorefrontTimeoutError`. */\n declare name: string;\n /** States the timeout, such as `\"Storefront API request timed out after 30000ms\"`. */\n declare message: string;\n /** The stack trace, when the JavaScript runtime records one. */\n declare stack?: string;\n\n constructor(timeoutInMs: number, options?: Omit<StorefrontApiErrorOptions, \"cause\">) {\n super(`Storefront API request timed out after ${timeoutInMs}ms`, options);\n this.name = \"StorefrontTimeoutError\";\n this.timeoutInMs = timeoutInMs;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AAqBA,IAAa,qBAAb,cAAwC,MAAM;;CAE5C,AAAS;;CAET,AAAS;;CAET,AAAS;;CAET,AAAS;CAST,YAAY,SAAiB,SAAqC;AAChE,QAAM,SAAS,SAAS,QAAQ,EAAE,OAAO,QAAQ,OAAO,GAAG,OAAU;AACrE,OAAK,OAAO;AACZ,OAAK,YAAY,SAAS;AAC1B,OAAK,SAAS,SAAS;AAGrB,OAAK,YAAY,SAAS;AAC1B,OAAK,YAAY,SAAS;;;CAK9B,KAAK,OAAO,eAAe;AACzB,SAAO,KAAK;;;CAId,SAAiF;AAC/E,SAAO;GACL,MAAM,KAAK;GACX,SAAS,KAAK;GACd,GAAI,KAAK,aAAa,QAAQ,EAAE,WAAW,KAAK,WAAW;GAC3D,GAAI,KAAK,UAAU,QAAQ,EAAE,QAAQ,KAAK,QAAQ;GACnD;;;;;;;;;;;;AAaL,IAAa,yBAAb,cAA4C,mBAAmB;;CAE7D,AAAS;CAST,YAAY,aAAqB,SAAoD;AACnF,QAAM,0CAA0C,YAAY,KAAK,QAAQ;AACzE,OAAK,OAAO;AACZ,OAAK,cAAc"}
|
|
@@ -5,106 +5,121 @@ import { AnyStorefrontQueryString, SourceOf, StorefrontQueryString } from "../gr
|
|
|
5
5
|
import { ResultOf, TadaDocumentNode, VariablesOf } from "gql.tada";
|
|
6
6
|
|
|
7
7
|
//#region src/client/types.d.ts
|
|
8
|
+
/** A document that the client's GraphQL method accepts, from `gql` or from `gql`.tada. */
|
|
8
9
|
type DocLike = TadaDocumentNode<any, any> | AnyStorefrontQueryString;
|
|
10
|
+
/** The typed document that Hydrogen infers from a plain query string. */
|
|
9
11
|
type InferredDoc<T extends string> = StorefrontQueryString<InferResult<T>, InferVariables<T>, T>;
|
|
12
|
+
/** The typed document for a GraphQL call. Hydrogen infers the types when you pass a plain query string. */
|
|
10
13
|
type ResolveDoc<D> = D extends DocLike ? D : D extends string ? InferredDoc<D> : never;
|
|
14
|
+
/** The query text of a document as a string literal type. A plain string resolves to itself. */
|
|
11
15
|
type SourceText<Doc> = [SourceOf<Doc>] extends [never] ? Doc extends string ? Doc : never : SourceOf<Doc>;
|
|
16
|
+
/** The operation kind of a document, such as `query`. Resolves to `unknown` when the query text isn't a string literal type. */
|
|
12
17
|
type OperationKindOfDoc<Doc> = [SourceText<Doc>] extends [never] ? "unknown" : string extends SourceText<Doc> ? "unknown" : InferOperationKind<SourceText<Doc>>;
|
|
18
|
+
/** Offers the `cache` option only for documents that TypeScript recognizes as queries. */
|
|
13
19
|
type GraphqlExtraOptionsForDoc<Doc, Extra extends Record<string, unknown>> = OperationKindOfDoc<Doc> extends "query" ? Extra : Omit<Extra, "cache">;
|
|
20
|
+
/** The result type of a `gql` document or a `gql`.tada document node. */
|
|
14
21
|
type ResultOfDoc<Doc> = Doc extends StorefrontQueryString<infer Result, infer _Variables, string> ? Result : Doc extends TadaDocumentNode<any, any> ? ResultOf<Doc> : never;
|
|
15
22
|
type VariablesOfDoc<Doc> = Doc extends StorefrontQueryString<infer _Result, infer Variables, string> ? Variables : Doc extends TadaDocumentNode<any, any> ? VariablesOf<Doc> : never;
|
|
16
23
|
type StorefrontApiResultOf<Doc extends DocLike> = ResultOf<Doc>;
|
|
17
24
|
type StorefrontApiVariablesOf<Doc extends DocLike> = VariablesOf<Doc>;
|
|
18
25
|
/**
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
* Present on the `errors` arm of {@link StorefrontGraphqlResult}.
|
|
26
|
+
* A GraphQL error from the Storefront API. The result of a GraphQL call lists GraphQL errors
|
|
27
|
+
* in its `errors` field.
|
|
23
28
|
*/
|
|
24
29
|
interface GraphQLFormattedError {
|
|
25
|
-
/**
|
|
30
|
+
/** The error message. */
|
|
26
31
|
readonly message: string;
|
|
27
|
-
/**
|
|
32
|
+
/** The lines and columns in the query where the error occurs. */
|
|
28
33
|
readonly locations?: ReadonlyArray<{
|
|
29
34
|
line: number;
|
|
30
35
|
column: number;
|
|
31
36
|
}>;
|
|
32
|
-
/**
|
|
37
|
+
/** The path to the response field that failed. */
|
|
33
38
|
readonly path?: ReadonlyArray<string | number>;
|
|
34
|
-
/**
|
|
39
|
+
/** Extra details that the Storefront API adds to the error. */
|
|
35
40
|
readonly extensions?: Record<string, unknown>;
|
|
36
41
|
}
|
|
37
42
|
type CommonOptions = {
|
|
38
|
-
/** Shopify store domain — e.g. `"my-store.myshopify.com"`. Normalized internally. */storeDomain: string;
|
|
39
43
|
/**
|
|
40
|
-
*
|
|
41
|
-
*
|
|
44
|
+
* Your store's domain, such as `my-store.myshopify.com`. Hydrogen adds `https://` when the
|
|
45
|
+
* domain has no protocol, and removes trailing slashes. `createStorefrontClient` throws an error
|
|
46
|
+
* for an empty domain.
|
|
47
|
+
*/
|
|
48
|
+
storeDomain: string;
|
|
49
|
+
/**
|
|
50
|
+
* Your Hydrogen storefront's ID. The client sends the ID in the `Shopify-Storefront-Id` header
|
|
51
|
+
* of every request.
|
|
42
52
|
*/
|
|
43
53
|
storefrontId?: string;
|
|
44
54
|
/**
|
|
45
|
-
* Storefront API version
|
|
46
|
-
*
|
|
47
|
-
* version
|
|
48
|
-
*
|
|
49
|
-
|
|
55
|
+
* The Storefront API version that the client queries. Defaults to the version that Hydrogen
|
|
56
|
+
* bundles. To send some queries to another version, such as `unstable`, create a second client
|
|
57
|
+
* with that version. Type inference always uses Hydrogen's bundled schema. Write your own types
|
|
58
|
+
* for fields outside the bundled schema.
|
|
59
|
+
*/
|
|
60
|
+
apiVersion?: string;
|
|
61
|
+
/**
|
|
62
|
+
* How long a request can run before the client throws a `StorefrontTimeoutError`, in
|
|
63
|
+
* milliseconds. Defaults to `30000`. Set `0` to turn off the timeout. Stale-while-revalidate
|
|
64
|
+
* refreshes use the same timeout, or 30,000 when the timeout is `0`. `createStorefrontClient`
|
|
65
|
+
* throws an error for a negative value.
|
|
50
66
|
*/
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
67
|
+
defaultTimeoutInMs?: number;
|
|
68
|
+
/**
|
|
69
|
+
* The cache that stores query results. The client caches only queries that pass a `cache`
|
|
70
|
+
* strategy. The client never caches mutations or results with GraphQL errors.
|
|
71
|
+
*/
|
|
72
|
+
cache?: CacheInstance; /** Keeps the runtime alive while the client writes to the cache in the background, such as a worker's `waitUntil` function. Without the function, each cached query waits for its cache write before it resolves. */
|
|
54
73
|
waitUntil?: WaitUntil;
|
|
55
74
|
};
|
|
75
|
+
/** A fetch function, or any function with a compatible signature that resolves to a `Response`. */
|
|
56
76
|
type AnyFetch = typeof globalThis.fetch | ((...args: never[]) => Promise<Response>);
|
|
57
77
|
/**
|
|
58
|
-
*
|
|
59
|
-
*
|
|
78
|
+
* Options for a public client, which runs in the browser or a mobile app. Pass a public access
|
|
79
|
+
* token, or omit the token for tokenless access.
|
|
60
80
|
*
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
* product tags, metaobjects, metafields, menus, and customers.
|
|
81
|
+
* Tokenless access can't read some Storefront API fields, including product tags, metaobjects,
|
|
82
|
+
* metafields, menus, and customers.
|
|
64
83
|
*/
|
|
65
84
|
interface PublicClientOptions<Fetch extends AnyFetch | undefined = typeof globalThis.fetch> extends CommonOptions {
|
|
66
|
-
/**
|
|
85
|
+
/** The fetch function that the client calls. Defaults to `globalThis.fetch`. `createStorefrontClient` throws an error when neither exists. */
|
|
67
86
|
fetch?: Fetch;
|
|
68
|
-
/**
|
|
87
|
+
/** Your public Storefront API access token. Omit the token for tokenless access. `createStorefrontClient` throws an error for an empty string. */
|
|
69
88
|
publicStorefrontToken?: string | undefined;
|
|
70
89
|
}
|
|
71
90
|
/**
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
* Best for: SSR/server-side requests where you control the fetch
|
|
77
|
-
* layer and can forward trusted buyer context.
|
|
78
|
-
* Token-based access is required for some Storefront API fields, including
|
|
79
|
-
* product tags, metaobjects, metafields, menus, and customers.
|
|
91
|
+
* Options for a private client, which runs during server-side rendering and forwards the
|
|
92
|
+
* customer's IP address to the Storefront API. Set `buyerIp` on the request context before you
|
|
93
|
+
* create the client.
|
|
80
94
|
*/
|
|
81
95
|
interface PrivateClientOptions<Fetch extends AnyFetch | undefined = typeof globalThis.fetch> extends CommonOptions {
|
|
82
|
-
/**
|
|
96
|
+
/** The fetch function that the client calls. Defaults to `globalThis.fetch`. `createStorefrontClient` throws an error when neither exists. */
|
|
83
97
|
fetch?: Fetch;
|
|
84
|
-
/**
|
|
98
|
+
/** Your private Storefront API access token. Keep the token out of browser code. `createStorefrontClient` throws an error when the token is missing. */
|
|
85
99
|
privateStorefrontToken: string;
|
|
86
100
|
}
|
|
87
101
|
/**
|
|
88
|
-
*
|
|
89
|
-
*
|
|
90
|
-
*
|
|
91
|
-
* Best for: background jobs, webhooks, or server contexts where no
|
|
92
|
-
* shopper identity is available.
|
|
102
|
+
* Options for a private client without buyer context, for background jobs, webhooks, and other
|
|
103
|
+
* server code with no customer. The client sends a private access token and no customer IP address.
|
|
93
104
|
*/
|
|
94
105
|
interface PrivateNoBuyerContextClientOptions<Fetch extends AnyFetch | undefined = typeof globalThis.fetch> extends CommonOptions {
|
|
95
|
-
/**
|
|
106
|
+
/** The fetch function that the client calls. Defaults to `globalThis.fetch`. `createStorefrontClient` throws an error when neither exists. */
|
|
96
107
|
fetch?: Fetch;
|
|
97
|
-
/**
|
|
108
|
+
/** Your private Storefront API access token. Keep the token out of browser code. `createStorefrontClient` throws an error when the token is missing. */
|
|
98
109
|
privateStorefrontToken: string;
|
|
99
110
|
}
|
|
100
|
-
/**
|
|
111
|
+
/**
|
|
112
|
+
* The store settings that you pass as `config` when you create a client. The options depend on the client type.
|
|
113
|
+
*
|
|
114
|
+
* @publicDocs
|
|
115
|
+
*/
|
|
101
116
|
type StorefrontClientOptions = PublicClientOptions | PrivateClientOptions | PrivateNoBuyerContextClientOptions;
|
|
102
117
|
/**
|
|
103
|
-
*
|
|
118
|
+
* The arguments for createStorefrontClient. Set `type` to choose the client, then pass a request
|
|
119
|
+
* context and the matching store settings.
|
|
104
120
|
*
|
|
105
|
-
*
|
|
106
|
-
* `
|
|
107
|
-
* and `"private_no_buyer_context"` requires a private token; `buyerIp` is not forwarded.
|
|
121
|
+
* A public client takes a public token or none. A private client takes a private token and a
|
|
122
|
+
* request context with `buyerIp`. A private client without buyer context takes a private token.
|
|
108
123
|
*/
|
|
109
124
|
type CreateStorefrontClientArgs<RequestContext extends ShopifyRequestContext = ShopifyRequestContext, Type extends ClientType = ClientType, CacheConfig extends CacheInstance | undefined = CacheInstance | undefined> = {
|
|
110
125
|
type: "public" & Type;
|
|
@@ -126,39 +141,41 @@ type CreateStorefrontClientArgs<RequestContext extends ShopifyRequestContext = S
|
|
|
126
141
|
};
|
|
127
142
|
};
|
|
128
143
|
type AutoAddedVariableNames = "country" | "language";
|
|
144
|
+
/** The variables that you pass for a document, without `country` and `language`. The client fills both from the request context. */
|
|
129
145
|
type UserVariables<Doc> = Omit<VariablesOfDoc<Doc>, AutoAddedVariableNames>;
|
|
146
|
+
/** Resolves to `true` when an object type has no required keys. */
|
|
130
147
|
type HasNoRequiredKeys<T> = Record<string, never> extends T ? true : false;
|
|
131
|
-
/**
|
|
148
|
+
/**
|
|
149
|
+
* Options that every Storefront API GraphQL call accepts.
|
|
150
|
+
*
|
|
151
|
+
* @publicDocs
|
|
152
|
+
*/
|
|
132
153
|
type StorefrontGraphqlOptions = {
|
|
133
|
-
/**
|
|
154
|
+
/**
|
|
155
|
+
* Cancels the request when the signal aborts. The request context's signal and the client timeout
|
|
156
|
+
* also cancel the request. The signal doesn't cancel a stale-while-revalidate refresh.
|
|
157
|
+
*/
|
|
158
|
+
signal?: AbortSignal;
|
|
134
159
|
};
|
|
160
|
+
/** The options for a GraphQL call. The call needs `variables` only when the document declares a required variable. */
|
|
135
161
|
type MergedOptions<Doc extends DocLike, Extra extends Record<string, unknown>> = Extra & StorefrontGraphqlOptions & (HasNoRequiredKeys<UserVariables<Doc>> extends true ? {
|
|
136
162
|
variables?: UserVariables<Doc>;
|
|
137
163
|
} : {
|
|
138
164
|
variables: UserVariables<Doc>;
|
|
139
165
|
});
|
|
140
166
|
/**
|
|
141
|
-
*
|
|
142
|
-
*
|
|
143
|
-
*
|
|
144
|
-
* variables, or `[options?]` (optional) when all variables are optional or
|
|
145
|
-
* auto-injected (e.g. `$country`, `$language`).
|
|
167
|
+
* The options argument of a GraphQL call. Pass the options argument when the document declares a
|
|
168
|
+
* required variable. You can leave the options argument out when every variable is optional, or
|
|
169
|
+
* when the only required variables are `$country` and `$language`, which the client fills.
|
|
146
170
|
*/
|
|
147
171
|
type GqlRestParam<Doc extends DocLike, Extra extends Record<string, unknown> = {}> = HasNoRequiredKeys<MergedOptions<Doc, GraphqlExtraOptionsForDoc<Doc, Extra>>> extends true ? [options?: MergedOptions<Doc, GraphqlExtraOptionsForDoc<Doc, Extra>>] : [options: MergedOptions<Doc, GraphqlExtraOptionsForDoc<Doc, Extra>>];
|
|
148
172
|
/**
|
|
149
|
-
*
|
|
150
|
-
*
|
|
151
|
-
* Discriminated on `errors`:
|
|
173
|
+
* The result of a GraphQL call, with the data, any GraphQL errors, and the response headers. Check
|
|
174
|
+
* `errors` before you read `data`.
|
|
152
175
|
*
|
|
153
|
-
*
|
|
154
|
-
*
|
|
155
|
-
*
|
|
156
|
-
* partial (field-level error absorbed by a nullable ancestor). Always
|
|
157
|
-
* inspect `errors` first.
|
|
158
|
-
*
|
|
159
|
-
* `Partial` is deliberately not used: a non-null `data` never has absent
|
|
160
|
-
* top-level keys — failures surface as `null` values already covered by the
|
|
161
|
-
* schema types.
|
|
176
|
+
* Without errors, `data` holds the full result, typed from your document. With errors, `data` is
|
|
177
|
+
* `null` after a request error or after a failed non-null field at the root. Otherwise, `data`
|
|
178
|
+
* holds a partial result, and `null` replaces each failed field or its nearest nullable parent.
|
|
162
179
|
*/
|
|
163
180
|
type StorefrontGraphqlResult<Doc extends DocLike> = {
|
|
164
181
|
data: ResultOfDoc<Doc>;
|
|
@@ -169,41 +186,73 @@ type StorefrontGraphqlResult<Doc extends DocLike> = {
|
|
|
169
186
|
errors: GraphQLFormattedError[];
|
|
170
187
|
headers: Headers;
|
|
171
188
|
};
|
|
172
|
-
/** Base callable signature of `StorefrontClient.graphql` without per-client extra options. Accepts a `gql()` document or a plain string. */
|
|
173
|
-
type StorefrontGraphql = <const Doc extends DocLike | string>(doc: Doc, ...options: GqlRestParam<ResolveDoc<Doc>>) => Promise<StorefrontGraphqlResult<ResolveDoc<Doc>>>;
|
|
174
|
-
type ClientType = /** Public access token or tokenless access. Best for: browser requests. */"public" /** Private token with trusted buyer context. Best for: SSR. */ | "private" /** Private token without buyer context. Best for: background jobs, webhooks. */ | "private_no_buyer_context";
|
|
175
189
|
/**
|
|
176
|
-
*
|
|
190
|
+
* Runs a Storefront API query or mutation. Pass a `gql` document or a plain query string.
|
|
191
|
+
*
|
|
192
|
+
* @publicDocs
|
|
193
|
+
*/
|
|
194
|
+
type StorefrontGraphql =
|
|
195
|
+
/**
|
|
196
|
+
* @param doc - The `gql` document or query string to run.
|
|
197
|
+
* @param options - The variables and abort signal for the call. Pass the options when the document declares a required variable.
|
|
198
|
+
* @returns The response data, any GraphQL errors, and the response headers.
|
|
199
|
+
*/
|
|
200
|
+
<const Doc extends DocLike | string>(doc: Doc, ...options: GqlRestParam<ResolveDoc<Doc>>) => Promise<StorefrontGraphqlResult<ResolveDoc<Doc>>>;
|
|
201
|
+
/**
|
|
202
|
+
* Chooses the kind of Storefront API client to create. Use `public` in the browser, with a public access token or none. Use `private` during server-side rendering, with a private token and the customer's IP address. Use `private_no_buyer_context` in background jobs and webhooks, with a private token and no customer.
|
|
177
203
|
*
|
|
178
|
-
*
|
|
179
|
-
|
|
204
|
+
* @publicDocs
|
|
205
|
+
*/
|
|
206
|
+
type ClientType = /** Runs in the browser with a public access token or none. */"public" /** Runs during server-side rendering with a private token and the customer's IP address. */ | "private" /** Runs in background jobs and webhooks with a private token and no customer. */ | "private_no_buyer_context";
|
|
207
|
+
/**
|
|
208
|
+
* A Storefront API client. Call `graphql()` with a document to run a query or mutation and get a
|
|
209
|
+
* typed result.
|
|
180
210
|
*/
|
|
181
211
|
type StorefrontClient<Extra extends Record<string, unknown> = {}, Type extends ClientType = ClientType, RequestContext extends ShopifyRequestContext = ShopifyRequestContext> = {
|
|
182
|
-
/**
|
|
212
|
+
/** The client type that you passed to `createStorefrontClient`. */type: Type; /** The country and language that the client sends for `$country` and `$language` variables. */
|
|
183
213
|
i18n: RequestContext["i18n"];
|
|
184
214
|
/**
|
|
185
|
-
*
|
|
215
|
+
* Runs a Storefront API query or mutation and returns a typed result. Pass a `gql` document or a
|
|
216
|
+
* plain query string. When the operation declares `$country` or `$language`, the client sets the
|
|
217
|
+
* variable from the request context and overrides any value you pass.
|
|
186
218
|
*
|
|
187
|
-
*
|
|
188
|
-
*
|
|
189
|
-
*
|
|
219
|
+
* The method throws an error when a query passes a `cache` strategy and the client has no cache,
|
|
220
|
+
* or when the strategy uses `private` mode. A catch block for `StorefrontApiError` doesn't catch
|
|
221
|
+
* this configuration error. To cache customer-specific data, use `createRunWithCache` with a key
|
|
222
|
+
* unique to the customer.
|
|
190
223
|
*/
|
|
191
|
-
graphql: <const Doc extends DocLike | string>(doc: Doc, ...options: GqlRestParam<ResolveDoc<Doc>, Extra>) => Promise<StorefrontGraphqlResult<ResolveDoc<Doc>>>; /**
|
|
192
|
-
apiUrl: string; /**
|
|
193
|
-
storeUrl: string; /**
|
|
194
|
-
storefrontId?: string; /** The request context
|
|
224
|
+
graphql: <const Doc extends DocLike | string>(doc: Doc, ...options: GqlRestParam<ResolveDoc<Doc>, Extra>) => Promise<StorefrontGraphqlResult<ResolveDoc<Doc>>>; /** The Storefront API GraphQL endpoint that the client calls. */
|
|
225
|
+
apiUrl: string; /** Your store's URL with its protocol, such as `https://my-store.myshopify.com`. */
|
|
226
|
+
storeUrl: string; /** The storefront ID from the client options. */
|
|
227
|
+
storefrontId?: string; /** The request context that you passed to `createStorefrontClient`. */
|
|
195
228
|
requestContext: RequestContext;
|
|
196
229
|
};
|
|
197
|
-
/**
|
|
230
|
+
/**
|
|
231
|
+
* The type of a client that you create with `type: "public"`.
|
|
232
|
+
*
|
|
233
|
+
* @publicDocs
|
|
234
|
+
*/
|
|
198
235
|
type PublicStorefrontClient<Extra extends Record<string, unknown> = {}, RequestContext extends ShopifyRequestContext = ShopifyRequestContext> = StorefrontClient<Extra, "public", RequestContext>;
|
|
199
|
-
/**
|
|
236
|
+
/**
|
|
237
|
+
* The type of a client that you create with `type: "private"`. The client's request context includes `buyerIp`.
|
|
238
|
+
*
|
|
239
|
+
* @publicDocs
|
|
240
|
+
*/
|
|
200
241
|
type PrivateStorefrontClient<Extra extends Record<string, unknown> = {}, RequestContext extends ShopifyRequestContextWithBuyerIp = ShopifyRequestContextWithBuyerIp> = StorefrontClient<Extra, "private", RequestContext>;
|
|
201
|
-
/**
|
|
242
|
+
/**
|
|
243
|
+
* The type of a private client with the default request context. Use the type to annotate a private client without naming your request context type.
|
|
244
|
+
*
|
|
245
|
+
* @publicDocs
|
|
246
|
+
*/
|
|
202
247
|
type RequestScopedPrivateStorefrontClient<Extra extends Record<string, unknown> = {}> = PrivateStorefrontClient<Extra, ShopifyRequestContextWithBuyerIp>;
|
|
203
|
-
/**
|
|
248
|
+
/**
|
|
249
|
+
* The type of a client that you create with `type: "private_no_buyer_context"`, for background jobs and webhooks.
|
|
250
|
+
*
|
|
251
|
+
* @publicDocs
|
|
252
|
+
*/
|
|
204
253
|
type PrivateNoBuyerContextStorefrontClient<Extra extends Record<string, unknown> = {}, RequestContext extends ShopifyRequestContext = ShopifyRequestContext> = StorefrontClient<Extra, "private_no_buyer_context", RequestContext>;
|
|
205
254
|
/**
|
|
206
|
-
*
|
|
255
|
+
* Type helpers that read the result and variables types of a Storefront API document.
|
|
207
256
|
*
|
|
208
257
|
* @example
|
|
209
258
|
* ```ts
|
|
@@ -214,13 +263,14 @@ type PrivateNoBuyerContextStorefrontClient<Extra extends Record<string, unknown>
|
|
|
214
263
|
* type Product = StorefrontApi.ResultOf<typeof PRODUCT_QUERY>;
|
|
215
264
|
* type Vars = StorefrontApi.VariablesOf<typeof PRODUCT_QUERY>;
|
|
216
265
|
* ```
|
|
266
|
+
* @publicDocs
|
|
217
267
|
*/
|
|
218
268
|
declare namespace StorefrontApi {
|
|
219
|
-
/**
|
|
269
|
+
/** The result type of a document. */
|
|
220
270
|
type ResultOf<Doc extends DocLike> = StorefrontApiResultOf<Doc>;
|
|
221
|
-
/**
|
|
271
|
+
/** The variables type of a document. */
|
|
222
272
|
type VariablesOf<Doc extends DocLike> = StorefrontApiVariablesOf<Doc>;
|
|
223
|
-
/** A typed Storefront API document
|
|
273
|
+
/** A typed Storefront API document from `gql`, or a gql.tada document node. */
|
|
224
274
|
type DocumentNode = DocLike;
|
|
225
275
|
}
|
|
226
276
|
//#endregion
|
|
@@ -1,20 +1,29 @@
|
|
|
1
1
|
import { CartStore } from "../cart/cart.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/core/analytics/cart-tracker.d.ts
|
|
4
|
+
/** A cart store, or any object with the cart store's `getState()` and `subscribe()` methods. */
|
|
4
5
|
type CartAnalyticsStore = Pick<CartStore, "getState" | "subscribe">;
|
|
5
6
|
/**
|
|
6
|
-
*
|
|
7
|
+
* Publishes cart analytics events when the server confirms a change to the customer's cart. In React, call `useCartAnalytics`.
|
|
7
8
|
*
|
|
8
|
-
*
|
|
9
|
-
* `product_added_to_cart`
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* page loads and tabs). A store filled from your own cart query must select
|
|
13
|
-
* `updatedAt`, or deduplication can't work.
|
|
9
|
+
* The function publishes `cart_updated` when the cart's update time changes, plus
|
|
10
|
+
* `product_added_to_cart` or `product_removed_from_cart` for each added line, removed
|
|
11
|
+
* line, and quantity change. The function waits until no cart change or reload is in flight.
|
|
12
|
+
* Analytics payloads leave out cart lines without merchandise.
|
|
14
13
|
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
14
|
+
* The function stores the last published cart update in local storage under `cartLastUpdatedAt`
|
|
15
|
+
* to avoid repeat events across page loads and tabs. A store that you fill from your own cart query
|
|
16
|
+
* must select `updatedAt`. Without the update time, the function publishes on every confirmed cart state.
|
|
17
|
+
* The function also sets `window.Shopify.currency.active` to the cart's currency.
|
|
18
|
+
*
|
|
19
|
+
* The function throws when the Shopify analytics bus isn't available, including during server rendering.
|
|
20
|
+
* Render `ShopifyScripts`, then start tracking in a client-only effect, such as `useEffect` or `onMounted`.
|
|
21
|
+
*
|
|
22
|
+
* @param store The cart store to track.
|
|
23
|
+
* @throws {Error} If `window.Shopify.analytics` isn't set, including on the server.
|
|
24
|
+
* Render Shopify's script tags first.
|
|
25
|
+
* @returns A function that stops tracking.
|
|
26
|
+
* @publicDocs
|
|
18
27
|
*/
|
|
19
28
|
declare function trackCartAnalytics(store: CartAnalyticsStore): () => void;
|
|
20
29
|
//#endregion
|
|
@@ -3,18 +3,26 @@ import { flattenConnection } from "./utils/flatten-connection.mjs";
|
|
|
3
3
|
|
|
4
4
|
//#region src/core/analytics/cart-tracker.ts
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
6
|
+
* Publishes cart analytics events when the server confirms a change to the customer's cart. In React, call `useCartAnalytics`.
|
|
7
7
|
*
|
|
8
|
-
*
|
|
9
|
-
* `product_added_to_cart`
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* page loads and tabs). A store filled from your own cart query must select
|
|
13
|
-
* `updatedAt`, or deduplication can't work.
|
|
8
|
+
* The function publishes `cart_updated` when the cart's update time changes, plus
|
|
9
|
+
* `product_added_to_cart` or `product_removed_from_cart` for each added line, removed
|
|
10
|
+
* line, and quantity change. The function waits until no cart change or reload is in flight.
|
|
11
|
+
* Analytics payloads leave out cart lines without merchandise.
|
|
14
12
|
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
13
|
+
* The function stores the last published cart update in local storage under `cartLastUpdatedAt`
|
|
14
|
+
* to avoid repeat events across page loads and tabs. A store that you fill from your own cart query
|
|
15
|
+
* must select `updatedAt`. Without the update time, the function publishes on every confirmed cart state.
|
|
16
|
+
* The function also sets `window.Shopify.currency.active` to the cart's currency.
|
|
17
|
+
*
|
|
18
|
+
* The function throws when the Shopify analytics bus isn't available, including during server rendering.
|
|
19
|
+
* Render `ShopifyScripts`, then start tracking in a client-only effect, such as `useEffect` or `onMounted`.
|
|
20
|
+
*
|
|
21
|
+
* @param store The cart store to track.
|
|
22
|
+
* @throws {Error} If `window.Shopify.analytics` isn't set, including on the server.
|
|
23
|
+
* Render Shopify's script tags first.
|
|
24
|
+
* @returns A function that stops tracking.
|
|
25
|
+
* @publicDocs
|
|
18
26
|
*/
|
|
19
27
|
function trackCartAnalytics(store) {
|
|
20
28
|
const analytics = getGlobalAnalytics();
|