@shopware/composables 1.11.0 → 1.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (99) hide show
  1. package/README.md +11 -8
  2. package/dist/index.d.mts +29 -3
  3. package/dist/index.d.ts +29 -3
  4. package/dist/index.mjs +138 -79
  5. package/package.json +16 -16
  6. package/src/cms/useCmsElementConfig.test.ts +1 -0
  7. package/src/cms/useCmsElementConfig.ts +1 -0
  8. package/src/cms/useCmsElementImage.test.ts +1 -0
  9. package/src/cms/useCmsElementImage.ts +2 -0
  10. package/src/cms/useCmsElementProductBox.test.ts +1 -0
  11. package/src/cms/useCmsElementProductBox.ts +2 -0
  12. package/src/createShopwareContext.test.ts +1 -0
  13. package/src/createShopwareContext.ts +8 -0
  14. package/src/devtools/plugin.ts +13 -13
  15. package/src/helpers/ContextError.spec.ts +1 -0
  16. package/src/index.test.ts +2 -0
  17. package/src/index.ts +1 -0
  18. package/src/types/cmsElementTypes.ts +1 -0
  19. package/src/useAddToCart/useAddToCart.test.ts +1 -0
  20. package/src/useAddToCart/useAddToCart.ts +1 -0
  21. package/src/useAddress/useAddress.test.ts +2 -0
  22. package/src/useAddress/useAddress.ts +1 -0
  23. package/src/useB2bQuoteManagement/useB2bQuoteManagement.test.ts +1 -0
  24. package/src/useBreadcrumbs/useBreadcrumbs.test.ts +2 -0
  25. package/src/useBreadcrumbs/useBreadcrumbs.ts +1 -0
  26. package/src/useCart/useCart.test.ts +2 -0
  27. package/src/useCart/useCart.ts +1 -0
  28. package/src/useCartErrorParamsResolver/useCartErrorParamsResolver.test.ts +1 -0
  29. package/src/useCartItem/useCartItem.test.ts +2 -0
  30. package/src/useCartItem/useCartItem.ts +1 -0
  31. package/src/useCartNotification/useCartNotification.test.ts +2 -0
  32. package/src/useCategory/useCategory.test.ts +2 -0
  33. package/src/useCategory/useCategory.ts +2 -0
  34. package/src/useCategorySearch/useCategorySearch.test.ts +29 -0
  35. package/src/useCategorySearch/useCategorySearch.ts +15 -7
  36. package/src/useCheckout/useCheckout.test.ts +1 -0
  37. package/src/useCheckout/useCheckout.ts +1 -0
  38. package/src/useCmsBlock/useCmsBlock.test.ts +2 -0
  39. package/src/useCmsMeta/useCmsMeta.test.ts +2 -0
  40. package/src/useCmsMeta/useCmsMeta.ts +1 -0
  41. package/src/useCmsSection/useCmsSection.test.ts +2 -0
  42. package/src/useCmsTranslations/useCmsTranslations.test.ts +2 -0
  43. package/src/useCountries/useCountries.test.ts +19 -0
  44. package/src/useCountries/useCountries.ts +14 -7
  45. package/src/useCustomerOrders/useCustomerOrders.test.ts +1 -0
  46. package/src/useCustomerOrders/useCustomerOrders.ts +1 -0
  47. package/src/useCustomerPassword/useCustomerPassword.test.ts +1 -0
  48. package/src/useDefaultOrderAssociations/useDefaultOrderAssociations.test.ts +1 -0
  49. package/src/useInternationalization/useInternationalization.test.ts +14 -1
  50. package/src/useInternationalization/useInternationalization.ts +5 -3
  51. package/src/useLandingSearch/useLandingSearch.test.ts +1 -0
  52. package/src/useLandingSearch/useLandingSearch.ts +1 -0
  53. package/src/useListing/useListing.test.ts +2 -0
  54. package/src/useListing/useListing.ts +3 -2
  55. package/src/useLocalWishlist/useLocalWishlist.test.ts +1 -0
  56. package/src/useNavigation/useNavigation.test.ts +24 -1
  57. package/src/useNavigation/useNavigation.ts +36 -14
  58. package/src/useNavigationContext/useNavigationContext.test.ts +1 -0
  59. package/src/useNavigationContext/useNavigationContext.ts +1 -0
  60. package/src/useNavigationSearch/useNavigationSearch.test.ts +125 -2
  61. package/src/useNavigationSearch/useNavigationSearch.ts +38 -21
  62. package/src/useNewsletter/useNewsletter.test.ts +5 -1
  63. package/src/useNewsletter/useNewsletter.ts +5 -1
  64. package/src/useNotifications/useNotifications.test.ts +1 -0
  65. package/src/useOrderDetails/useOrderDetails.test.ts +1 -0
  66. package/src/useOrderDetails/useOrderDetails.ts +1 -0
  67. package/src/useOrderPayment/useOrderPayment.test.ts +2 -0
  68. package/src/useOrderPayment/useOrderPayment.ts +1 -0
  69. package/src/usePrice/usePrice.test.ts +2 -0
  70. package/src/usePrice/usePrice.ts +1 -0
  71. package/src/useProduct/useProduct.test.ts +2 -0
  72. package/src/useProduct/useProduct.ts +2 -0
  73. package/src/useProductAssociations/useProductAssociations.spec.ts +48 -0
  74. package/src/useProductAssociations/useProductAssociations.ts +7 -3
  75. package/src/useProductConfigurator/useProductConfigurator.spec.ts +24 -0
  76. package/src/useProductConfigurator/useProductConfigurator.ts +20 -13
  77. package/src/useProductPrice/useProductPrice.test.ts +2 -0
  78. package/src/useProductPrice/useProductPrice.ts +1 -0
  79. package/src/useProductReviews/useProductReviews.test.ts +1 -0
  80. package/src/useProductReviews/useProductReviews.ts +1 -0
  81. package/src/useProductSearch/useProductSearch.test.ts +24 -1
  82. package/src/useProductSearch/useProductSearch.ts +24 -11
  83. package/src/useProductSearchSuggest/useProductSearchSuggest.test.ts +1 -0
  84. package/src/useProductSearchSuggest/useProductSearchSuggest.ts +1 -0
  85. package/src/useProductWishlist/useProductWishlist.test.ts +2 -0
  86. package/src/useProductWishlist/useProductWishlist.ts +1 -0
  87. package/src/useSalutations/useSalutations.spec.ts +15 -0
  88. package/src/useSalutations/useSalutations.ts +5 -2
  89. package/src/useSessionContext/useSessionContext.test.ts +18 -0
  90. package/src/useSessionContext/useSessionContext.ts +10 -0
  91. package/src/useShopwareContext/useShopwareContext.test.ts +1 -0
  92. package/src/useShopwareContext/useShopwareContext.ts +13 -0
  93. package/src/useSyncWishlist/useSyncWishlist.test.ts +1 -0
  94. package/src/useSyncWishlist/useSyncWishlist.ts +1 -0
  95. package/src/useUrlResolver/useUrlResolver.test.ts +1 -0
  96. package/src/useUser/useUser.test.ts +35 -2
  97. package/src/useUser/useUser.ts +34 -25
  98. package/src/useWishlist/useWishlist.test.ts +2 -0
  99. package/src/useWishlist/useWishlist.ts +1 -0
package/README.md CHANGED
@@ -123,6 +123,7 @@ Let's get back to the step where the `api-client` was initialized:
123
123
  ```ts [apiClient.ts]
124
124
  import { createAPIClient } from "@shopware/api-client";
125
125
  import Cookies from "js-cookie";
126
+
126
127
  import type { operations } from "#shopware";
127
128
 
128
129
  const shopwareEndpoint = "https://demo-frontends.shopware.store/store-api";
@@ -165,18 +166,20 @@ All composable functions are fully typed with TypeScript and they are registed g
165
166
 
166
167
  Full changelog for stable version is available [here](https://github.com/shopware/frontends/blob/main/packages/composables/CHANGELOG.md)
167
168
 
168
- ### Latest changes: 1.11.0
169
+ ### Latest changes: 1.12.0
169
170
 
170
171
  ### Minor Changes
171
172
 
172
- - [#2318](https://github.com/shopware/frontends/pull/2318) [`b40305f`](https://github.com/shopware/frontends/commit/b40305f9e2ec51f29c279650e411bb773438faed) Thanks [@mdanilowicz](https://github.com/mdanilowicz)! - `useProductPrice` now returns `hasListPrice` (boolean indicating whether the product has a list price set). `isListPrice` is deprecated and aliased to `hasListPrice`; use `hasListPrice` in new code.
173
+ - [#2486](https://github.com/shopware/frontends/pull/2486) [`5678fb0`](https://github.com/shopware/frontends/commit/5678fb008cbd86eaddd061e004de89e6f45bb7ec) Thanks [@mkucmus](https://github.com/mkucmus)! - `useSessionContext`: expose `currentLocaleCode` — the active language's locale code (e.g. `"en-GB"`), read directly from the context's `languageInfo`. The current locale can now be derived from the session context alone, without loading the full language list via `useInternationalization().getAvailableLanguages()` just to map the current `languageId` to a locale.
173
174
 
174
- ### Patch Changes
175
+ - [#2473](https://github.com/shopware/frontends/pull/2473) [`22611e5`](https://github.com/shopware/frontends/commit/22611e542b8f42a4f34dce5186f628f9a17f457b) Thanks [@mkucmus](https://github.com/mkucmus)! - Add an opt-in `cacheableReads` flag that routes anonymous Store API reads through their cacheable GET variants instead of POST. Criteria is compressed into the `_criteria` query param via `encodeForQuery` from `@shopware/api-client/helpers`, which lets CDNs / reverse proxies / the browser cache the responses.
176
+
177
+ Disabled by default — fully backwards compatible. Enable it in `nuxt.config` (`shopware: { cacheableReads: true }`) or via `createShopwareContext(app, { cacheableReads: true })` for non-Nuxt setups. It is surfaced on the Shopware context and read by the affected composables; public composable signatures are unchanged.
175
178
 
176
- - [#2275](https://github.com/shopware/frontends/pull/2275) [`432dd24`](https://github.com/shopware/frontends/commit/432dd246571dfa8c149293da97d5bb16f505e54c) Thanks [@mkucmus](https://github.com/mkucmus)! - Guard against undefined config in `useCmsElementConfig`.
179
+ Affected composables: `useNavigation`, `useNavigationSearch`, `useCountries`, `useUser` (country + salutation lookups), `useSalutations`, `useInternationalization`, `useProductConfigurator`, `useProductSearch`, and `useCategorySearch.advancedSearch`.
177
180
 
178
- - [#2263](https://github.com/shopware/frontends/pull/2263) [`b5f7e2a`](https://github.com/shopware/frontends/commit/b5f7e2a20c9dfdde1690e9006252d847f732bc0a) Thanks [@mkucmus](https://github.com/mkucmus)! - Fixed `getDocumentFile` return type in `useOrderDetails` to correctly return `Blob | string` instead of `Document` schema.
181
+ `useListing` (product-listing), single-category `useCategorySearch.search`, and `useLandingSearch` remain POST for now: the generated Store API schema does not type `_criteria` on those GET routes (a Shopware OpenAPI gap). The backend does honor `_criteria` on product-listing GET at runtime, so that one can be migrated later once the types are augmented.
182
+
183
+ ### Patch Changes
179
184
 
180
- - Updated dependencies [[`9604f22`](https://github.com/shopware/frontends/commit/9604f22678150d04c3c3156fd8ee2ce440c8c8bf), [`b5f7e2a`](https://github.com/shopware/frontends/commit/b5f7e2a20c9dfdde1690e9006252d847f732bc0a), [`9604f22`](https://github.com/shopware/frontends/commit/9604f22678150d04c3c3156fd8ee2ce440c8c8bf), [`a871c7b`](https://github.com/shopware/frontends/commit/a871c7b6256b75c2e40d93fc0354ba1971420062), [`c9bde38`](https://github.com/shopware/frontends/commit/c9bde38d497d5c6c2fbd97700a362eb44ce8881f)]:
181
- - @shopware/api-client@1.5.0
182
- - @shopware/helpers@1.7.0
185
+ - [#2462](https://github.com/shopware/frontends/pull/2462) [`8be060d`](https://github.com/shopware/frontends/commit/8be060de825ca799f98a8f045a5e7fea61f5d1a2) Thanks [@mkucmus](https://github.com/mkucmus)! - `useProductAssociations`: add optional `includeSeoUrls` option. When `true`, the cross-selling request sends `sw-include-seo-urls: true` so returned products include the `seoUrls` association. Defaults to `false` to avoid extra backend overhead.
package/dist/index.d.mts CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as vue from 'vue';
2
2
  import { CSSProperties, ComputedRef, AnchorHTMLAttributes, ImgHTMLAttributes, App, EffectScope, Ref } from 'vue';
3
3
  import { createAPIClient, ApiError } from '@shopware/api-client';
4
- import { operations as operations$1, components } from '@shopware/api-client/store-api-types';
4
+ import { components, operations as operations$1 } from '@shopware/api-client/store-api-types';
5
5
  import * as _shopware_api_client_api_types from '@shopware/api-client/api-types';
6
6
  import { getListingFilters, TierPrice } from '@shopware/helpers';
7
7
 
@@ -421,6 +421,13 @@ declare function createShopwareContext(app: App, options: {
421
421
  devStorefrontUrl?: string | null;
422
422
  enableDevtools?: boolean;
423
423
  browserLocale?: string;
424
+ /**
425
+ * Opt in to reading data via cacheable GET Store API routes instead of
426
+ * POST. Surfaced on the Shopware context as `cacheableReads`.
427
+ *
428
+ * @default false
429
+ */
430
+ cacheableReads?: boolean;
424
431
  }): vue.Raw<{
425
432
  install(app: App): void;
426
433
  _a: App<any>;
@@ -430,6 +437,7 @@ declare function createShopwareContext(app: App, options: {
430
437
  interceptors: {};
431
438
  } | undefined;
432
439
  browserLocale: string;
440
+ cacheableReads: boolean;
433
441
  }>;
434
442
 
435
443
  type UseAddressReturn = {
@@ -1374,7 +1382,7 @@ type UseNewsletterReturn = {
1374
1382
  * Subscribes the user to the newsletter
1375
1383
  * @param params {@link operations['subscribeToNewsletter post /newsletter/subscribe']['body']}
1376
1384
  */
1377
- newsletterSubscribe(params: Omit<operations["subscribeToNewsletter post /newsletter/subscribe"]["body"], "storefrontUrl">): Promise<void>;
1385
+ newsletterSubscribe(params: Omit<operations["subscribeToNewsletter post /newsletter/subscribe"]["body"], "storefrontUrl">): Promise<operations["subscribeToNewsletter post /newsletter/subscribe"]["response"]>;
1378
1386
  /**
1379
1387
  * Removes the email from the newsletter
1380
1388
  * @param email
@@ -1715,6 +1723,7 @@ type UseProductAssociationsReturn = {
1715
1723
  */
1716
1724
  declare function useProductAssociations(product: ComputedRef<Schemas["Product"]>, options: {
1717
1725
  associationContext: "cross-selling" | "reviews";
1726
+ includeSeoUrls?: boolean;
1718
1727
  }): UseProductAssociationsReturn;
1719
1728
 
1720
1729
  type UseProductConfiguratorReturn = {
@@ -2018,6 +2027,12 @@ type UseSessionContextReturn = {
2018
2027
  * current language code
2019
2028
  */
2020
2029
  currentLanguageId: ComputedRef<string | undefined>;
2030
+ /**
2031
+ * Locale code of the active language (e.g. `"en-GB"`), read from the
2032
+ * context's `languageInfo`. Available from the session context alone — no
2033
+ * separate language list request is required to detect the current locale.
2034
+ */
2035
+ currentLocaleCode: ComputedRef<string | undefined>;
2021
2036
  /**
2022
2037
  * current context's customer object
2023
2038
  */
@@ -2042,6 +2057,16 @@ type ShopwareContext = {
2042
2057
  * If not provided, it will be "en-US"
2043
2058
  */
2044
2059
  browserLocale: string;
2060
+ /**
2061
+ * When `true`, composables read data through the cacheable GET variants of
2062
+ * the Store API (criteria compressed into the `_criteria` query param)
2063
+ * instead of POST, so the responses can be cached by HTTP infrastructure
2064
+ * (CDN, reverse proxy, browser). Requires a backend that supports the GET
2065
+ * read routes.
2066
+ *
2067
+ * @default false
2068
+ */
2069
+ cacheableReads: boolean;
2045
2070
  };
2046
2071
  /**
2047
2072
  * @public
@@ -2343,4 +2368,5 @@ declare function getDefaultApiParams(): {
2343
2368
  [composableName: string]: unknown;
2344
2369
  };
2345
2370
 
2346
- export { type BoxLayout, type Breadcrumb, type ChangePaymentShippingMethodParams, type CmsBlockCategoryNavigation, type CmsBlockCenterText, type CmsBlockCrossSelling, type CmsBlockForm, type CmsBlockGalleryBuybox, type CmsBlockHtml, type CmsBlockImage, type CmsBlockImageBubbleRow, type CmsBlockImageCover, type CmsBlockImageFourColumn, type CmsBlockImageGallery, type CmsBlockImageGalleryBig, type CmsBlockImageHighlightRow, type CmsBlockImageSimpleGrid, type CmsBlockImageSlider, type CmsBlockImageText, type CmsBlockImageTextBubble, type CmsBlockImageTextCover, type CmsBlockImageTextGallery, type CmsBlockImageTextRow, type CmsBlockImageThreeColumn, type CmsBlockImageThreeCover, type CmsBlockImageTwoColumn, type CmsBlockProductDescriptionReviews, type CmsBlockProductHeading, type CmsBlockProductListing, type CmsBlockProductSlider, type CmsBlockProductThreeColumn, type CmsBlockSidebarFilter, type CmsBlockText, type CmsBlockTextHero, type CmsBlockTextOnImage, type CmsBlockTextTeaser, type CmsBlockTextTeaserSection, type CmsBlockTextThreeColumn, type CmsBlockTextTwoColumn, type CmsBlockVimeoVideo, type CmsBlockYoutubeVideo, type CmsElementBuyBox, type CmsElementCategoryNavigation, type CmsElementCrossSelling, type CmsElementForm, type CmsElementHtml, type CmsElementImage, type CmsElementImageGallery, type CmsElementImageSlider, type CmsElementManufacturerLogo, type CmsElementProductBox, type CmsElementProductDescriptionReviews, type CmsElementProductListing, type CmsElementProductName, type CmsElementProductSlider, type CmsElementSidebarFilter, type CmsElementText, type CmsElementVimeoVideo, type CmsElementYoutubeVideo, type CmsSectionBlock, type CmsSectionDefault, type CmsSectionSidebar, type DisplayMode, type ElementConfig, type ErrorObjectParam, type ImageContainerAttrs, type ListingType, type Notification, type NotificationOptions, type Position, type RouteObject, type ShopwareContext, type ShortcutFilterParam, type SliderElementConfig, type SourceType, type UseAddToCartReturn, type UseAddressReturn, type UseBreadcrumbsReturn, type UseCartErrorParamsResolver, type UseCartItemReturn, type UseCartReturn, type UseCategoryReturn, type UseCategorySearchReturn, type UseCheckoutReturn, type UseCmsBlockReturn, type UseCmsElementImage, type UseCmsMetaReturn, type UseCountriesReturn, type UseCustomerOrdersReturn, type UseCustomerPasswordReturn, type UseInternationalizationReturn, type UseLandingSearchReturn, type UseListingReturn, type UseLocalWishlistReturn, type UseNavigationContextReturn, type UseNavigationReturn, type UseNavigationSearchReturn, type UseNewsletterReturn, type UseNotificationsReturn, type UseOrderDetailsReturn, type UseOrderPaymentReturn, type UsePriceReturn, type UseProductAssociationsReturn, type UseProductConfiguratorReturn, type UseProductPriceReturn, type UseProductReturn, type UseProductReviewsReturn, type UseProductSearchReturn, type UseProductSearchSuggestReturn, type UseProductWishlistReturn, type UseSalutationsReturn, type UseSessionContextReturn, type UseSyncWishlistReturn, type UseUserReturn, type UseWishlistReturn, type VerticalAlign, createCategoryListingContext, createListingComposable, createShopwareContext, getDefaultApiParams, resolveCmsComponent, useAddToCart, useAddress, useB2bQuoteManagement, useBreadcrumbs, useCart, useCartErrorParamsResolver, useCartFunction, useCartItem, useCartNotification, type useCartNotificationReturn, useCategory, useCategoryListing, useCategorySearch, useCheckout, useCmsBlock, useCmsElementConfig, useCmsElementImage, useCmsMeta, useCmsSection, useCmsTranslations, useContext, useCountries, useCustomerOrders, useCustomerPassword, useDefaultOrderAssociations, useInternationalization, useLandingSearch, useListing, useLocalWishlist, useNavigation, useNavigationContext, useNavigationSearch, useNewsletter, useNotifications, useOrderDetails, useOrderPayment, usePrice, useProduct, useProductAssociations, useProductConfigurator, useProductPrice, useProductReviews, useProductSearch, useProductSearchListing, useProductSearchSuggest, useProductWishlist, useSalutations, useSessionContext, useShopwareContext, useSyncWishlist, useUrlResolver, useUser, useWishlist };
2371
+ export { createCategoryListingContext, createListingComposable, createShopwareContext, getDefaultApiParams, resolveCmsComponent, useAddToCart, useAddress, useB2bQuoteManagement, useBreadcrumbs, useCart, useCartErrorParamsResolver, useCartFunction, useCartItem, useCartNotification, useCategory, useCategoryListing, useCategorySearch, useCheckout, useCmsBlock, useCmsElementConfig, useCmsElementImage, useCmsMeta, useCmsSection, useCmsTranslations, useContext, useCountries, useCustomerOrders, useCustomerPassword, useDefaultOrderAssociations, useInternationalization, useLandingSearch, useListing, useLocalWishlist, useNavigation, useNavigationContext, useNavigationSearch, useNewsletter, useNotifications, useOrderDetails, useOrderPayment, usePrice, useProduct, useProductAssociations, useProductConfigurator, useProductPrice, useProductReviews, useProductSearch, useProductSearchListing, useProductSearchSuggest, useProductWishlist, useSalutations, useSessionContext, useShopwareContext, useSyncWishlist, useUrlResolver, useUser, useWishlist };
2372
+ export type { BoxLayout, Breadcrumb, ChangePaymentShippingMethodParams, CmsBlockCategoryNavigation, CmsBlockCenterText, CmsBlockCrossSelling, CmsBlockForm, CmsBlockGalleryBuybox, CmsBlockHtml, CmsBlockImage, CmsBlockImageBubbleRow, CmsBlockImageCover, CmsBlockImageFourColumn, CmsBlockImageGallery, CmsBlockImageGalleryBig, CmsBlockImageHighlightRow, CmsBlockImageSimpleGrid, CmsBlockImageSlider, CmsBlockImageText, CmsBlockImageTextBubble, CmsBlockImageTextCover, CmsBlockImageTextGallery, CmsBlockImageTextRow, CmsBlockImageThreeColumn, CmsBlockImageThreeCover, CmsBlockImageTwoColumn, CmsBlockProductDescriptionReviews, CmsBlockProductHeading, CmsBlockProductListing, CmsBlockProductSlider, CmsBlockProductThreeColumn, CmsBlockSidebarFilter, CmsBlockText, CmsBlockTextHero, CmsBlockTextOnImage, CmsBlockTextTeaser, CmsBlockTextTeaserSection, CmsBlockTextThreeColumn, CmsBlockTextTwoColumn, CmsBlockVimeoVideo, CmsBlockYoutubeVideo, CmsElementBuyBox, CmsElementCategoryNavigation, CmsElementCrossSelling, CmsElementForm, CmsElementHtml, CmsElementImage, CmsElementImageGallery, CmsElementImageSlider, CmsElementManufacturerLogo, CmsElementProductBox, CmsElementProductDescriptionReviews, CmsElementProductListing, CmsElementProductName, CmsElementProductSlider, CmsElementSidebarFilter, CmsElementText, CmsElementVimeoVideo, CmsElementYoutubeVideo, CmsSectionBlock, CmsSectionDefault, CmsSectionSidebar, DisplayMode, ElementConfig, ErrorObjectParam, ImageContainerAttrs, ListingType, Notification, NotificationOptions, Position, RouteObject, ShopwareContext, ShortcutFilterParam, SliderElementConfig, SourceType, UseAddToCartReturn, UseAddressReturn, UseBreadcrumbsReturn, UseCartErrorParamsResolver, UseCartItemReturn, UseCartReturn, UseCategoryReturn, UseCategorySearchReturn, UseCheckoutReturn, UseCmsBlockReturn, UseCmsElementImage, UseCmsMetaReturn, UseCountriesReturn, UseCustomerOrdersReturn, UseCustomerPasswordReturn, UseInternationalizationReturn, UseLandingSearchReturn, UseListingReturn, UseLocalWishlistReturn, UseNavigationContextReturn, UseNavigationReturn, UseNavigationSearchReturn, UseNewsletterReturn, UseNotificationsReturn, UseOrderDetailsReturn, UseOrderPaymentReturn, UsePriceReturn, UseProductAssociationsReturn, UseProductConfiguratorReturn, UseProductPriceReturn, UseProductReturn, UseProductReviewsReturn, UseProductSearchReturn, UseProductSearchSuggestReturn, UseProductWishlistReturn, UseSalutationsReturn, UseSessionContextReturn, UseSyncWishlistReturn, UseUserReturn, UseWishlistReturn, VerticalAlign, useCartNotificationReturn };
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as vue from 'vue';
2
2
  import { CSSProperties, ComputedRef, AnchorHTMLAttributes, ImgHTMLAttributes, App, EffectScope, Ref } from 'vue';
3
3
  import { createAPIClient, ApiError } from '@shopware/api-client';
4
- import { operations as operations$1, components } from '@shopware/api-client/store-api-types';
4
+ import { components, operations as operations$1 } from '@shopware/api-client/store-api-types';
5
5
  import * as _shopware_api_client_api_types from '@shopware/api-client/api-types';
6
6
  import { getListingFilters, TierPrice } from '@shopware/helpers';
7
7
 
@@ -421,6 +421,13 @@ declare function createShopwareContext(app: App, options: {
421
421
  devStorefrontUrl?: string | null;
422
422
  enableDevtools?: boolean;
423
423
  browserLocale?: string;
424
+ /**
425
+ * Opt in to reading data via cacheable GET Store API routes instead of
426
+ * POST. Surfaced on the Shopware context as `cacheableReads`.
427
+ *
428
+ * @default false
429
+ */
430
+ cacheableReads?: boolean;
424
431
  }): vue.Raw<{
425
432
  install(app: App): void;
426
433
  _a: App<any>;
@@ -430,6 +437,7 @@ declare function createShopwareContext(app: App, options: {
430
437
  interceptors: {};
431
438
  } | undefined;
432
439
  browserLocale: string;
440
+ cacheableReads: boolean;
433
441
  }>;
434
442
 
435
443
  type UseAddressReturn = {
@@ -1374,7 +1382,7 @@ type UseNewsletterReturn = {
1374
1382
  * Subscribes the user to the newsletter
1375
1383
  * @param params {@link operations['subscribeToNewsletter post /newsletter/subscribe']['body']}
1376
1384
  */
1377
- newsletterSubscribe(params: Omit<operations["subscribeToNewsletter post /newsletter/subscribe"]["body"], "storefrontUrl">): Promise<void>;
1385
+ newsletterSubscribe(params: Omit<operations["subscribeToNewsletter post /newsletter/subscribe"]["body"], "storefrontUrl">): Promise<operations["subscribeToNewsletter post /newsletter/subscribe"]["response"]>;
1378
1386
  /**
1379
1387
  * Removes the email from the newsletter
1380
1388
  * @param email
@@ -1715,6 +1723,7 @@ type UseProductAssociationsReturn = {
1715
1723
  */
1716
1724
  declare function useProductAssociations(product: ComputedRef<Schemas["Product"]>, options: {
1717
1725
  associationContext: "cross-selling" | "reviews";
1726
+ includeSeoUrls?: boolean;
1718
1727
  }): UseProductAssociationsReturn;
1719
1728
 
1720
1729
  type UseProductConfiguratorReturn = {
@@ -2018,6 +2027,12 @@ type UseSessionContextReturn = {
2018
2027
  * current language code
2019
2028
  */
2020
2029
  currentLanguageId: ComputedRef<string | undefined>;
2030
+ /**
2031
+ * Locale code of the active language (e.g. `"en-GB"`), read from the
2032
+ * context's `languageInfo`. Available from the session context alone — no
2033
+ * separate language list request is required to detect the current locale.
2034
+ */
2035
+ currentLocaleCode: ComputedRef<string | undefined>;
2021
2036
  /**
2022
2037
  * current context's customer object
2023
2038
  */
@@ -2042,6 +2057,16 @@ type ShopwareContext = {
2042
2057
  * If not provided, it will be "en-US"
2043
2058
  */
2044
2059
  browserLocale: string;
2060
+ /**
2061
+ * When `true`, composables read data through the cacheable GET variants of
2062
+ * the Store API (criteria compressed into the `_criteria` query param)
2063
+ * instead of POST, so the responses can be cached by HTTP infrastructure
2064
+ * (CDN, reverse proxy, browser). Requires a backend that supports the GET
2065
+ * read routes.
2066
+ *
2067
+ * @default false
2068
+ */
2069
+ cacheableReads: boolean;
2045
2070
  };
2046
2071
  /**
2047
2072
  * @public
@@ -2343,4 +2368,5 @@ declare function getDefaultApiParams(): {
2343
2368
  [composableName: string]: unknown;
2344
2369
  };
2345
2370
 
2346
- export { type BoxLayout, type Breadcrumb, type ChangePaymentShippingMethodParams, type CmsBlockCategoryNavigation, type CmsBlockCenterText, type CmsBlockCrossSelling, type CmsBlockForm, type CmsBlockGalleryBuybox, type CmsBlockHtml, type CmsBlockImage, type CmsBlockImageBubbleRow, type CmsBlockImageCover, type CmsBlockImageFourColumn, type CmsBlockImageGallery, type CmsBlockImageGalleryBig, type CmsBlockImageHighlightRow, type CmsBlockImageSimpleGrid, type CmsBlockImageSlider, type CmsBlockImageText, type CmsBlockImageTextBubble, type CmsBlockImageTextCover, type CmsBlockImageTextGallery, type CmsBlockImageTextRow, type CmsBlockImageThreeColumn, type CmsBlockImageThreeCover, type CmsBlockImageTwoColumn, type CmsBlockProductDescriptionReviews, type CmsBlockProductHeading, type CmsBlockProductListing, type CmsBlockProductSlider, type CmsBlockProductThreeColumn, type CmsBlockSidebarFilter, type CmsBlockText, type CmsBlockTextHero, type CmsBlockTextOnImage, type CmsBlockTextTeaser, type CmsBlockTextTeaserSection, type CmsBlockTextThreeColumn, type CmsBlockTextTwoColumn, type CmsBlockVimeoVideo, type CmsBlockYoutubeVideo, type CmsElementBuyBox, type CmsElementCategoryNavigation, type CmsElementCrossSelling, type CmsElementForm, type CmsElementHtml, type CmsElementImage, type CmsElementImageGallery, type CmsElementImageSlider, type CmsElementManufacturerLogo, type CmsElementProductBox, type CmsElementProductDescriptionReviews, type CmsElementProductListing, type CmsElementProductName, type CmsElementProductSlider, type CmsElementSidebarFilter, type CmsElementText, type CmsElementVimeoVideo, type CmsElementYoutubeVideo, type CmsSectionBlock, type CmsSectionDefault, type CmsSectionSidebar, type DisplayMode, type ElementConfig, type ErrorObjectParam, type ImageContainerAttrs, type ListingType, type Notification, type NotificationOptions, type Position, type RouteObject, type ShopwareContext, type ShortcutFilterParam, type SliderElementConfig, type SourceType, type UseAddToCartReturn, type UseAddressReturn, type UseBreadcrumbsReturn, type UseCartErrorParamsResolver, type UseCartItemReturn, type UseCartReturn, type UseCategoryReturn, type UseCategorySearchReturn, type UseCheckoutReturn, type UseCmsBlockReturn, type UseCmsElementImage, type UseCmsMetaReturn, type UseCountriesReturn, type UseCustomerOrdersReturn, type UseCustomerPasswordReturn, type UseInternationalizationReturn, type UseLandingSearchReturn, type UseListingReturn, type UseLocalWishlistReturn, type UseNavigationContextReturn, type UseNavigationReturn, type UseNavigationSearchReturn, type UseNewsletterReturn, type UseNotificationsReturn, type UseOrderDetailsReturn, type UseOrderPaymentReturn, type UsePriceReturn, type UseProductAssociationsReturn, type UseProductConfiguratorReturn, type UseProductPriceReturn, type UseProductReturn, type UseProductReviewsReturn, type UseProductSearchReturn, type UseProductSearchSuggestReturn, type UseProductWishlistReturn, type UseSalutationsReturn, type UseSessionContextReturn, type UseSyncWishlistReturn, type UseUserReturn, type UseWishlistReturn, type VerticalAlign, createCategoryListingContext, createListingComposable, createShopwareContext, getDefaultApiParams, resolveCmsComponent, useAddToCart, useAddress, useB2bQuoteManagement, useBreadcrumbs, useCart, useCartErrorParamsResolver, useCartFunction, useCartItem, useCartNotification, type useCartNotificationReturn, useCategory, useCategoryListing, useCategorySearch, useCheckout, useCmsBlock, useCmsElementConfig, useCmsElementImage, useCmsMeta, useCmsSection, useCmsTranslations, useContext, useCountries, useCustomerOrders, useCustomerPassword, useDefaultOrderAssociations, useInternationalization, useLandingSearch, useListing, useLocalWishlist, useNavigation, useNavigationContext, useNavigationSearch, useNewsletter, useNotifications, useOrderDetails, useOrderPayment, usePrice, useProduct, useProductAssociations, useProductConfigurator, useProductPrice, useProductReviews, useProductSearch, useProductSearchListing, useProductSearchSuggest, useProductWishlist, useSalutations, useSessionContext, useShopwareContext, useSyncWishlist, useUrlResolver, useUser, useWishlist };
2371
+ export { createCategoryListingContext, createListingComposable, createShopwareContext, getDefaultApiParams, resolveCmsComponent, useAddToCart, useAddress, useB2bQuoteManagement, useBreadcrumbs, useCart, useCartErrorParamsResolver, useCartFunction, useCartItem, useCartNotification, useCategory, useCategoryListing, useCategorySearch, useCheckout, useCmsBlock, useCmsElementConfig, useCmsElementImage, useCmsMeta, useCmsSection, useCmsTranslations, useContext, useCountries, useCustomerOrders, useCustomerPassword, useDefaultOrderAssociations, useInternationalization, useLandingSearch, useListing, useLocalWishlist, useNavigation, useNavigationContext, useNavigationSearch, useNewsletter, useNotifications, useOrderDetails, useOrderPayment, usePrice, useProduct, useProductAssociations, useProductConfigurator, useProductPrice, useProductReviews, useProductSearch, useProductSearchListing, useProductSearchSuggest, useProductWishlist, useSalutations, useSessionContext, useShopwareContext, useSyncWishlist, useUrlResolver, useUser, useWishlist };
2372
+ export type { BoxLayout, Breadcrumb, ChangePaymentShippingMethodParams, CmsBlockCategoryNavigation, CmsBlockCenterText, CmsBlockCrossSelling, CmsBlockForm, CmsBlockGalleryBuybox, CmsBlockHtml, CmsBlockImage, CmsBlockImageBubbleRow, CmsBlockImageCover, CmsBlockImageFourColumn, CmsBlockImageGallery, CmsBlockImageGalleryBig, CmsBlockImageHighlightRow, CmsBlockImageSimpleGrid, CmsBlockImageSlider, CmsBlockImageText, CmsBlockImageTextBubble, CmsBlockImageTextCover, CmsBlockImageTextGallery, CmsBlockImageTextRow, CmsBlockImageThreeColumn, CmsBlockImageThreeCover, CmsBlockImageTwoColumn, CmsBlockProductDescriptionReviews, CmsBlockProductHeading, CmsBlockProductListing, CmsBlockProductSlider, CmsBlockProductThreeColumn, CmsBlockSidebarFilter, CmsBlockText, CmsBlockTextHero, CmsBlockTextOnImage, CmsBlockTextTeaser, CmsBlockTextTeaserSection, CmsBlockTextThreeColumn, CmsBlockTextTwoColumn, CmsBlockVimeoVideo, CmsBlockYoutubeVideo, CmsElementBuyBox, CmsElementCategoryNavigation, CmsElementCrossSelling, CmsElementForm, CmsElementHtml, CmsElementImage, CmsElementImageGallery, CmsElementImageSlider, CmsElementManufacturerLogo, CmsElementProductBox, CmsElementProductDescriptionReviews, CmsElementProductListing, CmsElementProductName, CmsElementProductSlider, CmsElementSidebarFilter, CmsElementText, CmsElementVimeoVideo, CmsElementYoutubeVideo, CmsSectionBlock, CmsSectionDefault, CmsSectionSidebar, DisplayMode, ElementConfig, ErrorObjectParam, ImageContainerAttrs, ListingType, Notification, NotificationOptions, Position, RouteObject, ShopwareContext, ShortcutFilterParam, SliderElementConfig, SourceType, UseAddToCartReturn, UseAddressReturn, UseBreadcrumbsReturn, UseCartErrorParamsResolver, UseCartItemReturn, UseCartReturn, UseCategoryReturn, UseCategorySearchReturn, UseCheckoutReturn, UseCmsBlockReturn, UseCmsElementImage, UseCmsMetaReturn, UseCountriesReturn, UseCustomerOrdersReturn, UseCustomerPasswordReturn, UseInternationalizationReturn, UseLandingSearchReturn, UseListingReturn, UseLocalWishlistReturn, UseNavigationContextReturn, UseNavigationReturn, UseNavigationSearchReturn, UseNewsletterReturn, UseNotificationsReturn, UseOrderDetailsReturn, UseOrderPaymentReturn, UsePriceReturn, UseProductAssociationsReturn, UseProductConfiguratorReturn, UseProductPriceReturn, UseProductReturn, UseProductReviewsReturn, UseProductSearchReturn, UseProductSearchSuggestReturn, UseProductWishlistReturn, UseSalutationsReturn, UseSessionContextReturn, UseSyncWishlistReturn, UseUserReturn, UseWishlistReturn, VerticalAlign, useCartNotificationReturn };
package/dist/index.mjs CHANGED
@@ -1,8 +1,9 @@
1
1
  import { pascalCase } from 'scule';
2
2
  import { computed, effectScope, reactive, markRaw, inject, ref, provide, unref, onMounted, watch, resolveComponent } from 'vue';
3
- import { urlIsAbsolute, relativeUrlSlash, getSrcSetForMedia, getMainImageUrl, getTranslatedProperty, getListingFilters, getProductTierPrices, buildUrlPrefix } from '@shopware/helpers';
3
+ import { urlIsAbsolute, relativeUrlSlash, getSrcSetForMedia, getMainImageUrl, getTranslatedProperty, getListingFilters, isTechnicalPath, normalizePath, getRouteFromPathInfo, getProductTierPrices, buildUrlPrefix } from '@shopware/helpers';
4
4
  import { ApiClientError } from '@shopware/api-client';
5
5
  import { createSharedComposable, injectLocal, provideLocal, createInjectionState, syncRefs } from '@vueuse/core';
6
+ import { encodeForQuery } from '@shopware/api-client/helpers';
6
7
  import { defu } from 'defu';
7
8
 
8
9
  function useCmsElementImage(element) {
@@ -86,7 +87,8 @@ function createShopwareContext(app, options) {
86
87
  _e: scope,
87
88
  devStorefrontUrl: options.devStorefrontUrl,
88
89
  state,
89
- browserLocale: options.browserLocale || "en-US"
90
+ browserLocale: options.browserLocale || "en-US",
91
+ cacheableReads: options.cacheableReads ?? false
90
92
  });
91
93
  if (options?.enableDevtools && typeof window !== "undefined") ;
92
94
  return shopwarePlugin;
@@ -522,7 +524,7 @@ const cmsAssociations = {
522
524
  };
523
525
 
524
526
  function useCategorySearch() {
525
- const { apiClient } = useShopwareContext();
527
+ const { apiClient, cacheableReads } = useShopwareContext();
526
528
  async function search(categoryId, options) {
527
529
  const associations = options?.withCmsAssociations ? cmsAssociations : {};
528
530
  const result = await apiClient.invoke(
@@ -544,11 +546,14 @@ function useCategorySearch() {
544
546
  }
545
547
  async function advancedSearch(options) {
546
548
  const associations = options?.withCmsAssociations ? cmsAssociations.associations : {};
547
- const result = await apiClient.invoke("readCategoryList post /category", {
548
- body: {
549
- associations,
550
- ...options?.query
551
- }
549
+ const criteria = {
550
+ associations,
551
+ ...options?.query
552
+ };
553
+ const result = cacheableReads ? await apiClient.invoke("readCategoryListGet get /category", {
554
+ query: { _criteria: encodeForQuery(criteria) }
555
+ }) : await apiClient.invoke("readCategoryList post /category", {
556
+ body: criteria
552
557
  });
553
558
  return result.data.elements ?? [];
554
559
  }
@@ -698,16 +703,19 @@ function useContext(injectionName, params) {
698
703
  }
699
704
 
700
705
  function useCountries() {
701
- const { apiClient } = useShopwareContext();
706
+ const { apiClient, cacheableReads } = useShopwareContext();
702
707
  const _sharedCountries = inject("swCountries", ref());
703
708
  provide("swCountries", _sharedCountries);
704
709
  async function fetchCountries() {
705
- const result = await apiClient.invoke("readCountry post /country", {
706
- body: {
707
- associations: {
708
- states: {}
709
- }
710
+ const criteria = {
711
+ associations: {
712
+ states: {}
710
713
  }
714
+ };
715
+ const result = cacheableReads ? await apiClient.invoke("readCountryGet get /country", {
716
+ query: { _criteria: encodeForQuery(criteria) }
717
+ }) : await apiClient.invoke("readCountry post /country", {
718
+ body: criteria
711
719
  });
712
720
  _sharedCountries.value = result.data.elements;
713
721
  return result.data;
@@ -835,8 +843,7 @@ function useDefaultOrderAssociations() {
835
843
  }
836
844
 
837
845
  function useInternationalization(pathResolver) {
838
- const { devStorefrontUrl } = useShopwareContext();
839
- const { apiClient } = useShopwareContext();
846
+ const { devStorefrontUrl, apiClient, cacheableReads } = useShopwareContext();
840
847
  const _storeLanguages = useContext("swLanguages");
841
848
  const _storeCurrentLanguage = useContext(
842
849
  "swLanguagesCurrentLanguage"
@@ -846,7 +853,7 @@ function useInternationalization(pathResolver) {
846
853
  return devStorefrontUrl ?? window.location.origin ?? "";
847
854
  }
848
855
  async function getAvailableLanguages() {
849
- const { data } = await apiClient.invoke("readLanguages post /language");
856
+ const { data } = cacheableReads ? await apiClient.invoke("readLanguagesGet get /language") : await apiClient.invoke("readLanguages post /language");
850
857
  _storeLanguages.value = data.elements;
851
858
  return data;
852
859
  }
@@ -1262,7 +1269,7 @@ function useLocalWishlist() {
1262
1269
 
1263
1270
  function useNavigation(params) {
1264
1271
  const type = params?.type || "main-navigation";
1265
- const { apiClient } = useShopwareContext();
1272
+ const { apiClient, cacheableReads } = useShopwareContext();
1266
1273
  const sharedElements = inject(
1267
1274
  `swNavigation-${type}`,
1268
1275
  ref([])
@@ -1271,7 +1278,24 @@ function useNavigation(params) {
1271
1278
  const navigationElements = computed(() => sharedElements.value);
1272
1279
  async function loadNavigationElements(params2) {
1273
1280
  try {
1274
- const navigationResponse = await apiClient.invoke(
1281
+ const { buildTree, depth, ...criteria } = params2;
1282
+ const navigationResponse = cacheableReads ? await apiClient.invoke(
1283
+ "readNavigationGet get /navigation/{activeId}/{rootId}",
1284
+ {
1285
+ headers: {
1286
+ "sw-include-seo-urls": true
1287
+ },
1288
+ pathParams: {
1289
+ activeId: type,
1290
+ rootId: type
1291
+ },
1292
+ query: {
1293
+ _criteria: encodeForQuery(criteria),
1294
+ buildTree,
1295
+ depth
1296
+ }
1297
+ }
1298
+ ) : await apiClient.invoke(
1275
1299
  "readNavigation post /navigation/{activeId}/{rootId}",
1276
1300
  {
1277
1301
  headers: {
@@ -1310,7 +1334,7 @@ function useNavigationContext(context) {
1310
1334
  }
1311
1335
 
1312
1336
  function useNavigationSearch() {
1313
- const { apiClient } = useShopwareContext();
1337
+ const { apiClient, cacheableReads } = useShopwareContext();
1314
1338
  const { sessionContext } = useSessionContext();
1315
1339
  async function resolvePath(path) {
1316
1340
  if (path === "/") {
@@ -1320,20 +1344,31 @@ function useNavigationSearch() {
1320
1344
  foreignKey: categoryId
1321
1345
  };
1322
1346
  }
1323
- const isTechnicalUrl = path.startsWith("/navigation/") || path.startsWith("/detail/") || path.startsWith("/landingPage/");
1324
- const normalizedPath = isTechnicalUrl ? path.endsWith("/") ? path.slice(0, -1) : path : path.substring(1);
1325
- const seoResult = await apiClient.invoke("readSeoUrl post /seo-url", {
1326
- body: {
1327
- filter: [
1328
- {
1329
- type: "equals",
1330
- field: isTechnicalUrl ? "pathInfo" : "seoPathInfo",
1331
- value: normalizedPath
1332
- }
1333
- ]
1334
- }
1347
+ const isTechnicalUrl = isTechnicalPath(path);
1348
+ const normalizedPath = isTechnicalUrl ? normalizePath(path) : path.substring(1);
1349
+ const criteria = {
1350
+ filter: [
1351
+ {
1352
+ type: "equals",
1353
+ field: isTechnicalUrl ? "pathInfo" : "seoPathInfo",
1354
+ value: normalizedPath
1355
+ }
1356
+ ]
1357
+ };
1358
+ const seoResult = cacheableReads ? await apiClient.invoke("readSeoUrlGet get /seo-url", {
1359
+ query: { _criteria: encodeForQuery(criteria) }
1360
+ }) : await apiClient.invoke("readSeoUrl post /seo-url", {
1361
+ body: criteria
1335
1362
  });
1336
- return seoResult.data.elements?.[0] ?? null;
1363
+ const element = seoResult.data.elements?.[0];
1364
+ if (element) {
1365
+ return element;
1366
+ }
1367
+ const fallback = getRouteFromPathInfo(path);
1368
+ if (fallback) {
1369
+ return fallback;
1370
+ }
1371
+ return null;
1337
1372
  }
1338
1373
  return {
1339
1374
  resolvePath
@@ -1356,6 +1391,7 @@ function useNewsletter() {
1356
1391
  }
1357
1392
  }
1358
1393
  );
1394
+ newsletterStatus.value = result.data.status;
1359
1395
  return result.data;
1360
1396
  }
1361
1397
  async function newsletterUnsubscribe(email) {
@@ -1404,7 +1440,7 @@ function useNotifications() {
1404
1440
  _notifications.value = [];
1405
1441
  }
1406
1442
  function geterateId() {
1407
- return +`${( new Date()).getTime()}${Math.random() * 1e3}`;
1443
+ return +`${(/* @__PURE__ */ new Date()).getTime()}${Math.random() * 1e3}`;
1408
1444
  }
1409
1445
  async function pushNotification(message, options) {
1410
1446
  const timeout = options.timeout || 2500;
@@ -1730,7 +1766,6 @@ function useProduct(product, configurator) {
1730
1766
  function useProductAssociations(product, options) {
1731
1767
  if (!product.value)
1732
1768
  throw new Error("[useProductAssociations]: Product is not provided.");
1733
- options.associationContext;
1734
1769
  const { apiClient } = useShopwareContext();
1735
1770
  const isLoading = ref(false);
1736
1771
  const associations = ref([]);
@@ -1740,6 +1775,11 @@ function useProductAssociations(product, options) {
1740
1775
  const response = await apiClient.invoke(
1741
1776
  "readProductCrossSellings post /product/{productId}/cross-selling",
1742
1777
  {
1778
+ ...options.includeSeoUrls && {
1779
+ headers: {
1780
+ "sw-include-seo-urls": true
1781
+ }
1782
+ },
1743
1783
  pathParams: { productId: product.value.id }
1744
1784
  }
1745
1785
  );
@@ -1761,7 +1801,7 @@ function useProductAssociations(product, options) {
1761
1801
  }
1762
1802
 
1763
1803
  function useProductConfigurator() {
1764
- const { apiClient } = useShopwareContext();
1804
+ const { apiClient, cacheableReads } = useShopwareContext();
1765
1805
  const { configurator, product } = useProduct();
1766
1806
  const selected = ref({});
1767
1807
  const isLoadingOptions = ref(!!product.value.options?.length);
@@ -1800,18 +1840,21 @@ function useProductConfigurator() {
1800
1840
  )
1801
1841
  ];
1802
1842
  try {
1803
- const response = await apiClient.invoke("readProduct post /product", {
1804
- body: {
1805
- filter,
1806
- limit: 1,
1807
- includes: {
1808
- product: ["id", "translated", "productNumber", "seoUrls"],
1809
- seo_url: ["seoPathInfo"]
1810
- },
1811
- associations: {
1812
- seoUrls: {}
1813
- }
1843
+ const criteria = {
1844
+ filter,
1845
+ limit: 1,
1846
+ includes: {
1847
+ product: ["id", "translated", "productNumber", "seoUrls"],
1848
+ seo_url: ["seoPathInfo"]
1849
+ },
1850
+ associations: {
1851
+ seoUrls: {}
1814
1852
  }
1853
+ };
1854
+ const response = cacheableReads ? await apiClient.invoke("readProductGet get /product", {
1855
+ query: { _criteria: encodeForQuery(criteria) }
1856
+ }) : await apiClient.invoke("readProduct post /product", {
1857
+ body: criteria
1815
1858
  });
1816
1859
  return response.data.elements?.[0];
1817
1860
  } catch (e) {
@@ -1922,23 +1965,31 @@ function useProductReviews(product) {
1922
1965
  }
1923
1966
 
1924
1967
  function useProductSearch() {
1925
- const { apiClient } = useShopwareContext();
1968
+ const { apiClient, cacheableReads } = useShopwareContext();
1926
1969
  const search = async (productId, options) => {
1927
1970
  const associations = defu(
1928
1971
  options?.withCmsAssociations ? cmsAssociations : {},
1929
1972
  options?.criteria,
1930
1973
  { associations: options?.associations ?? {} }
1931
1974
  );
1932
- const result = await apiClient.invoke(
1933
- "readProductDetail post /product/{productId}",
1975
+ const result = cacheableReads ? await apiClient.invoke(
1976
+ "readProductDetailGet get /product/{productId}",
1934
1977
  {
1935
1978
  headers: {
1936
1979
  "sw-include-seo-urls": true
1937
1980
  },
1938
1981
  pathParams: { productId },
1939
- body: associations
1982
+ query: {
1983
+ _criteria: encodeForQuery(associations)
1984
+ }
1940
1985
  }
1941
- );
1986
+ ) : await apiClient.invoke("readProductDetail post /product/{productId}", {
1987
+ headers: {
1988
+ "sw-include-seo-urls": true
1989
+ },
1990
+ pathParams: { productId },
1991
+ body: associations
1992
+ });
1942
1993
  return result.data;
1943
1994
  };
1944
1995
  return {
@@ -2006,11 +2057,11 @@ function useProductWishlist(productId) {
2006
2057
  }
2007
2058
 
2008
2059
  function useSalutations() {
2009
- const { apiClient } = useShopwareContext();
2060
+ const { apiClient, cacheableReads } = useShopwareContext();
2010
2061
  const _salutations = inject("swSalutations", ref());
2011
2062
  provide("swSalutations", _salutations);
2012
2063
  const fetchSalutations = async () => {
2013
- const result = await apiClient.invoke("readSalutation post /salutation");
2064
+ const result = cacheableReads ? await apiClient.invoke("readSalutationGet get /salutation") : await apiClient.invoke("readSalutation post /salutation");
2014
2065
  _salutations.value = result.data.elements;
2015
2066
  return result.data;
2016
2067
  };
@@ -2153,6 +2204,9 @@ function useSessionContext(newContext) {
2153
2204
  const languageIdChain = computed(
2154
2205
  () => sessionContext.value?.context?.languageIdChain?.[0] || ""
2155
2206
  );
2207
+ const currentLocaleCode = computed(
2208
+ () => sessionContext.value?.languageInfo?.localeCode
2209
+ );
2156
2210
  const taxState = computed(() => sessionContext.value?.context?.taxState);
2157
2211
  const userFromContext = computed(() => sessionContext.value?.customer);
2158
2212
  return {
@@ -2177,6 +2231,7 @@ function useSessionContext(newContext) {
2177
2231
  languageIdChain,
2178
2232
  salesChannelLanguageId: languageId,
2179
2233
  currentLanguageId: languageIdChain,
2234
+ currentLocaleCode,
2180
2235
  setCountry,
2181
2236
  setContext
2182
2237
  };
@@ -2192,7 +2247,8 @@ function useShopwareContext() {
2192
2247
  return {
2193
2248
  apiClient,
2194
2249
  devStorefrontUrl: shopwareContext.devStorefrontUrl,
2195
- browserLocale: shopwareContext.browserLocale || "en-US"
2250
+ browserLocale: shopwareContext.browserLocale || "en-US",
2251
+ cacheableReads: shopwareContext.cacheableReads ?? false
2196
2252
  };
2197
2253
  }
2198
2254
 
@@ -2289,7 +2345,7 @@ function useUrlResolver() {
2289
2345
  }
2290
2346
 
2291
2347
  function useUser() {
2292
- const { apiClient } = useShopwareContext();
2348
+ const { apiClient, cacheableReads } = useShopwareContext();
2293
2349
  const { userFromContext, refreshSessionContext } = useSessionContext();
2294
2350
  const _user = useContext("customer");
2295
2351
  syncRefs(userFromContext, _user, {
@@ -2358,35 +2414,38 @@ function useUser() {
2358
2414
  }
2359
2415
  }
2360
2416
  async function loadCountry(countryId) {
2361
- const countries = await apiClient.invoke("readCountry post /country", {
2362
- body: {
2363
- filter: [
2364
- {
2365
- field: "id",
2366
- type: "equals",
2367
- value: countryId
2368
- }
2369
- ]
2370
- }
2417
+ const criteria = {
2418
+ filter: [
2419
+ {
2420
+ field: "id",
2421
+ type: "equals",
2422
+ value: countryId
2423
+ }
2424
+ ]
2425
+ };
2426
+ const countries = cacheableReads ? await apiClient.invoke("readCountryGet get /country", {
2427
+ query: { _criteria: encodeForQuery(criteria) }
2428
+ }) : await apiClient.invoke("readCountry post /country", {
2429
+ body: criteria
2371
2430
  });
2372
2431
  country.value = countries.data.elements?.[0] ?? null;
2373
2432
  return countries.data;
2374
2433
  }
2375
2434
  async function loadSalutation(salutationId) {
2376
- const salutations = await apiClient.invoke(
2377
- "readSalutation post /salutation",
2378
- {
2379
- body: {
2380
- filter: [
2381
- {
2382
- field: "id",
2383
- type: "equals",
2384
- value: salutationId
2385
- }
2386
- ]
2435
+ const criteria = {
2436
+ filter: [
2437
+ {
2438
+ field: "id",
2439
+ type: "equals",
2440
+ value: salutationId
2387
2441
  }
2388
- }
2389
- );
2442
+ ]
2443
+ };
2444
+ const salutations = cacheableReads ? await apiClient.invoke("readSalutationGet get /salutation", {
2445
+ query: { _criteria: encodeForQuery(criteria) }
2446
+ }) : await apiClient.invoke("readSalutation post /salutation", {
2447
+ body: criteria
2448
+ });
2390
2449
  salutation.value = salutations.data.elements?.[0] ?? null;
2391
2450
  return salutations.data;
2392
2451
  }