@shopware/nuxt-module 1.4.3 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -132,8 +132,9 @@ declare module "#shopware" {
132
132
  // import("@shopware/api-client/store-api-types").components["schemas"];
133
133
 
134
134
  // Or use your locally generated types (placed in ./api-types folder):
135
- export type operations = import("./api-types/storeApiTypes").operations;
136
- export type Schemas = import("./api-types/storeApiTypes").components["schemas"];
135
+ export type operations = import("./api-types/storeApiTypes").operations;
136
+ export type Schemas =
137
+ import("./api-types/storeApiTypes").components["schemas"];
137
138
 
138
139
  // Export your own Api Client definition:
139
140
  export type ApiClient = ReturnType<typeof createAPIClient<operations>>;
@@ -144,7 +145,7 @@ Import your custom types from local files and export them as shown above. This a
144
145
 
145
146
  ### Apply custom types for `@shopware/api-client`
146
147
 
147
- The API Client instance is aware of your custom API types thanks to declaring `#shopware` module from the step above. So now, whenever `apiClient` instance is used, the proper types are registered.
148
+ The API Client instance is aware of your custom API types thanks to declaring `#shopware` module from the step above. So now, whenever `apiClient` instance is used, the proper types are registered.
148
149
 
149
150
  ## Links
150
151
 
@@ -161,15 +162,21 @@ Import your custom types from local files and export them as shown above. This a
161
162
 
162
163
  Full changelog for stable version is available [here](https://github.com/shopware/frontends/blob/main/packages/nuxt-module/CHANGELOG.md)
163
164
 
164
- ### Latest changes: 1.4.3
165
+ ### Latest changes: 1.5.0
165
166
 
166
- ### Patch Changes
167
+ ### Minor Changes
168
+
169
+ - [#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.
170
+
171
+ 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.
167
172
 
168
- - [#2232](https://github.com/shopware/frontends/pull/2232) [`f52c2da`](https://github.com/shopware/frontends/commit/f52c2da685c0c5085e6579aea37f86b6ce1d8281) Thanks [@patzick](https://github.com/patzick)! - bump h3 version after security audit
173
+ Affected composables: `useNavigation`, `useNavigationSearch`, `useCountries`, `useUser` (country + salutation lookups), `useSalutations`, `useInternationalization`, `useProductConfigurator`, `useProductSearch`, and `useCategorySearch.advancedSearch`.
174
+
175
+ `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.
176
+
177
+ ### Patch Changes
169
178
 
170
- - [#2321](https://github.com/shopware/frontends/pull/2321) [`5a785cc`](https://github.com/shopware/frontends/commit/5a785ccff72c4fe95ec3f774eeb7053e8b1e55fa) Thanks [@mkucmus](https://github.com/mkucmus)! - Auto-inject `#shopware` types via `addTypeTemplate`, skip if project provides own `shopware.d.ts`
179
+ - [#2488](https://github.com/shopware/frontends/pull/2488) [`c56b89e`](https://github.com/shopware/frontends/commit/c56b89e16a9fbd9283e40a4e2c0f7cc6034226a1) Thanks [@mkucmus](https://github.com/mkucmus)! - Register the `#shopware` types in every TypeScript context (app, server/nitro, node, shared) instead of only the app one. This fixes `Cannot find module '#shopware'` in server-side code (e.g. `server/` routes and API builders) when a project uses the Nuxt 4 project-references `tsconfig.json` layout. Projects that ship their own `shopware.d.ts` are referenced in place so their relative imports keep resolving.
171
180
 
172
- - Updated dependencies [[`9604f22`](https://github.com/shopware/frontends/commit/9604f22678150d04c3c3156fd8ee2ce440c8c8bf), [`b40305f`](https://github.com/shopware/frontends/commit/b40305f9e2ec51f29c279650e411bb773438faed), [`432dd24`](https://github.com/shopware/frontends/commit/432dd246571dfa8c149293da97d5bb16f505e54c), [`b5f7e2a`](https://github.com/shopware/frontends/commit/b5f7e2a20c9dfdde1690e9006252d847f732bc0a), [`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)]:
173
- - @shopware/api-client@1.5.0
174
- - @shopware/composables@1.11.0
175
- - @shopware/helpers@1.7.0
181
+ - Updated dependencies [[`8be060d`](https://github.com/shopware/frontends/commit/8be060de825ca799f98a8f045a5e7fea61f5d1a2), [`5678fb0`](https://github.com/shopware/frontends/commit/5678fb008cbd86eaddd061e004de89e6f45bb7ec), [`22611e5`](https://github.com/shopware/frontends/commit/22611e542b8f42a4f34dce5186f628f9a17f457b)]:
182
+ - @shopware/composables@1.12.0
package/dist/index.d.mts CHANGED
@@ -23,6 +23,18 @@ type ShopwareNuxtOptions = {
23
23
  * @default false
24
24
  */
25
25
  useUserContextInSSR?: boolean;
26
+ /**
27
+ * Read anonymous Store API data through cacheable GET routes instead of POST.
28
+ * Criteria is compressed into the `_criteria` query param, which lets CDNs /
29
+ * reverse proxies / the browser cache the responses.
30
+ *
31
+ * Requires a Shopware backend that supports the GET read routes and the
32
+ * `_criteria` query param. Leave disabled unless your caching layer is set up.
33
+ *
34
+ * @default false
35
+ */
36
+ cacheableReads?: boolean;
26
37
  };
27
38
 
28
- export { type ShopwareNuxtOptions, _default as default };
39
+ export { _default as default };
40
+ export type { ShopwareNuxtOptions };
package/dist/index.d.ts CHANGED
@@ -23,6 +23,18 @@ type ShopwareNuxtOptions = {
23
23
  * @default false
24
24
  */
25
25
  useUserContextInSSR?: boolean;
26
+ /**
27
+ * Read anonymous Store API data through cacheable GET routes instead of POST.
28
+ * Criteria is compressed into the `_criteria` query param, which lets CDNs /
29
+ * reverse proxies / the browser cache the responses.
30
+ *
31
+ * Requires a Shopware backend that supports the GET read routes and the
32
+ * `_criteria` query param. Leave disabled unless your caching layer is set up.
33
+ *
34
+ * @default false
35
+ */
36
+ cacheableReads?: boolean;
26
37
  };
27
38
 
28
- export { type ShopwareNuxtOptions, _default as default };
39
+ export { _default as default };
40
+ export type { ShopwareNuxtOptions };
package/dist/index.mjs CHANGED
@@ -21,33 +21,65 @@ const index = defineNuxtModule({
21
21
  async setup(options, nuxt) {
22
22
  const logger = useLogger(MODULE_ID);
23
23
  const resolver = createResolver(import.meta.url);
24
- const shopwareConfig = nuxt.options.runtimeConfig?.public?.shopware ?? void 0;
24
+ nuxt.options.runtimeConfig.shopware = defu(
25
+ nuxt.options.runtimeConfig.shopware || {},
26
+ options || {}
27
+ );
25
28
  nuxt.options.runtimeConfig.public.shopware = defu(
26
29
  nuxt.options.runtimeConfig.public.shopware || {},
27
30
  options || {}
28
31
  );
29
- if (isConfigDeprecated(shopwareConfig)) {
32
+ const resolvedPublicShopwareConfig = nuxt.options.runtimeConfig.public.shopware;
33
+ const resolvedPrivateShopwareConfig = nuxt.options.runtimeConfig.shopware;
34
+ if (isConfigDeprecated(resolvedPublicShopwareConfig) || isConfigDeprecated(resolvedPrivateShopwareConfig)) {
30
35
  logger.warn(
31
36
  "You are using deprecated configuration (shopwareEndpoint or shopwareAccessToken). 'shopware' prefix is not needed anymore. Please update your _nuxt.config.ts_ "
32
37
  );
33
38
  }
34
- if (shopwareConfig?.endpoint) {
35
- logger.info(
36
- `You are using SSR Shopware API endpoint: ${shopwareConfig.endpoint}`
39
+ const envPublicEndpoint = process.env.NUXT_PUBLIC_SHOPWARE_ENDPOINT || process.env.NUXT_PUBLIC_SHOPWARE_SHOPWARE_ENDPOINT;
40
+ const envPrivateEndpoint = process.env.NUXT_SHOPWARE_ENDPOINT || process.env.NUXT_SHOPWARE_SHOPWARE_ENDPOINT;
41
+ const csrEndpoint = envPublicEndpoint || resolvedPublicShopwareConfig?.endpoint || resolvedPublicShopwareConfig?.shopwareEndpoint;
42
+ const ssrEndpoint = envPrivateEndpoint || resolvedPrivateShopwareConfig?.endpoint || resolvedPrivateShopwareConfig?.shopwareEndpoint || csrEndpoint;
43
+ if (ssrEndpoint) {
44
+ nuxt.options.runtimeConfig.shopware = defu(
45
+ nuxt.options.runtimeConfig.shopware || {},
46
+ {
47
+ endpoint: ssrEndpoint
48
+ }
37
49
  );
38
50
  }
39
- logger.info(
40
- `CSR Shopware API endpoint: ${shopwareConfig?.endpoint ?? shopwareConfig?.shopwareEndpoint}`
41
- );
51
+ if (ssrEndpoint) {
52
+ logger.info(`You are using SSR Shopware API endpoint: ${ssrEndpoint}`);
53
+ }
54
+ logger.info(`CSR Shopware API endpoint: ${csrEndpoint}`);
42
55
  addPlugin({
43
56
  src: resolver.resolve("../plugin.ts")
44
57
  });
45
58
  const projectShopwareTypes = resolve(nuxt.options.rootDir, "shopware.d.ts");
46
- if (!existsSync(projectShopwareTypes)) {
47
- addTypeTemplate({
48
- filename: "shopware.d.ts",
49
- src: resolver.resolve("../shopware.d.ts")
50
- });
59
+ const shopwareTypeContexts = {
60
+ nuxt: true,
61
+ nitro: true,
62
+ node: true,
63
+ shared: true
64
+ };
65
+ if (existsSync(projectShopwareTypes)) {
66
+ const referencePath = projectShopwareTypes.replace(/\\/g, "/");
67
+ addTypeTemplate(
68
+ {
69
+ filename: "shopware.d.ts",
70
+ getContents: () => `/// <reference path="${referencePath}" />
71
+ `
72
+ },
73
+ shopwareTypeContexts
74
+ );
75
+ } else {
76
+ addTypeTemplate(
77
+ {
78
+ filename: "shopware.d.ts",
79
+ src: resolver.resolve("../shopware.d.ts")
80
+ },
81
+ shopwareTypeContexts
82
+ );
51
83
  }
52
84
  addCustomTab({
53
85
  name: "shopware-frontends",
@@ -58,6 +90,15 @@ const index = defineNuxtModule({
58
90
  src: "https://frontends.shopware.com/"
59
91
  }
60
92
  });
93
+ addCustomTab({
94
+ name: "shopware-cms",
95
+ title: "CMS Elements",
96
+ icon: "carbon:assembly-cluster",
97
+ view: {
98
+ type: "iframe",
99
+ src: "https://frontends.shopware.com/getting-started/cms/"
100
+ }
101
+ });
61
102
  }
62
103
  });
63
104
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shopware/nuxt-module",
3
- "version": "1.4.3",
3
+ "version": "1.5.0",
4
4
  "description": "Nuxt 3 module for Shopware Frontends",
5
5
  "author": "Shopware",
6
6
  "repository": {
@@ -34,28 +34,27 @@
34
34
  "index.cjs"
35
35
  ],
36
36
  "dependencies": {
37
- "@nuxt/kit": "4.2.2",
38
- "defu": "6.1.4",
39
- "h3": "1.15.9",
40
- "js-cookie": "3.0.5",
41
- "@shopware/composables": "1.11.0",
42
- "@shopware/helpers": "1.7.0",
37
+ "@nuxt/kit": "4.4.8",
38
+ "defu": "6.1.7",
39
+ "h3": "1.15.11",
40
+ "js-cookie": "3.0.7",
41
+ "@shopware/composables": "1.12.0",
42
+ "@shopware/helpers": "1.7.1",
43
43
  "@shopware/api-client": "1.5.0"
44
44
  },
45
45
  "devDependencies": {
46
- "@biomejs/biome": "1.8.3",
47
- "@nuxt/schema": "4.2.2",
48
- "@typescript/native-preview": "7.0.0-dev.20260111.1",
49
- "nuxt": "4.2.2",
50
- "unbuild": "2.0.0",
51
- "vitest": "4.0.18",
46
+ "@nuxt/schema": "4.4.8",
47
+ "@typescript/native-preview": "7.0.0-dev.20260205.1",
48
+ "nuxt": "4.4.8",
49
+ "unbuild": "3.6.1",
50
+ "vitest": "4.1.9",
52
51
  "tsconfig": "0.0.0"
53
52
  },
54
53
  "scripts": {
55
54
  "build": "unbuild",
56
55
  "dev": "unbuild --stub",
57
- "lint": "biome check .",
58
- "lint:fix": "biome check . --write && pnpm run typecheck",
56
+ "lint": "oxlint . && oxfmt --check .",
57
+ "lint:fix": "oxlint --fix . && oxfmt --write . && pnpm run typecheck",
59
58
  "typecheck": "tsgo --noEmit",
60
59
  "test": "vitest run"
61
60
  }
package/plugin.ts CHANGED
@@ -3,6 +3,7 @@ import { isMaintenanceMode } from "@shopware/helpers";
3
3
  import { getCookie } from "h3";
4
4
  import Cookies from "js-cookie";
5
5
  import { ref } from "vue";
6
+
6
7
  import {
7
8
  createShopwareContext,
8
9
  defineNuxtPlugin,
@@ -12,6 +13,7 @@ import {
12
13
  useState,
13
14
  } from "#imports";
14
15
  import type { ApiClient } from "#shopware";
16
+
15
17
  import type { ShopwareNuxtOptions } from "./src";
16
18
 
17
19
  declare module "#app" {
@@ -31,14 +33,18 @@ export default defineNuxtPlugin((NuxtApp) => {
31
33
 
32
34
  const shopwareRuntimeConfigPublic = runtimeConfig.public
33
35
  .shopware as ShopwareNuxtOptions;
34
- const shopwareRuntimeConfig = runtimeConfig.shopware as ShopwareNuxtOptions;
36
+ const shopwareRuntimeConfig = import.meta.server
37
+ ? (runtimeConfig.shopware as ShopwareNuxtOptions)
38
+ : undefined;
35
39
 
36
40
  const shopwareEndpointCSR =
37
41
  shopwareRuntimeConfigPublic?.endpoint ??
38
42
  shopwareRuntimeConfigPublic?.shopwareEndpoint;
39
43
 
40
44
  const shopwareEndpointSSR =
41
- (NuxtApp.ssrContext && shopwareRuntimeConfig?.endpoint) ||
45
+ (NuxtApp.ssrContext &&
46
+ (shopwareRuntimeConfig?.endpoint ??
47
+ shopwareRuntimeConfig?.shopwareEndpoint)) ||
42
48
  shopwareEndpointCSR;
43
49
 
44
50
  const shopwareEndpoint = import.meta.server
@@ -68,6 +74,10 @@ export default defineNuxtPlugin((NuxtApp) => {
68
74
  headers?: Record<string, string>;
69
75
  };
70
76
 
77
+ const privateApiClientConfig = import.meta.server
78
+ ? (runtimeConfig.apiClientConfig as ApiClientConfig)
79
+ : undefined;
80
+
71
81
  const apiClient = createAPIClient({
72
82
  baseURL: shopwareEndpoint,
73
83
  accessToken: shopwareAccessToken,
@@ -75,8 +85,7 @@ export default defineNuxtPlugin((NuxtApp) => {
75
85
  ? contextTokenFromCookie
76
86
  : "",
77
87
  defaultHeaders:
78
- (NuxtApp.ssrContext &&
79
- (runtimeConfig.apiClientConfig as ApiClientConfig)?.headers) ||
88
+ (NuxtApp.ssrContext && privateApiClientConfig?.headers) ||
80
89
  (runtimeConfig.public?.apiClientConfig as ApiClientConfig)?.headers,
81
90
  });
82
91
 
@@ -113,11 +122,12 @@ export default defineNuxtPlugin((NuxtApp) => {
113
122
  NuxtApp.vueApp.provide("apiClient", apiClient);
114
123
  // Shopware context
115
124
  // TODO fix type App<Element>
116
- // biome-ignore lint: ignore type error
125
+ // TODO: Improve this typing.
117
126
  const shopwareContext = createShopwareContext(NuxtApp.vueApp as any, {
118
127
  enableDevtools: true,
119
128
  devStorefrontUrl: shopwareRuntimeConfigPublic?.devStorefrontUrl || null,
120
129
  browserLocale,
130
+ cacheableReads: shopwareRuntimeConfigPublic?.cacheableReads ?? false,
121
131
  });
122
132
  NuxtApp.vueApp.provide("shopware", shopwareContext);
123
133