@shopware/nuxt-module 1.5.0 → 1.5.2

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
@@ -5,13 +5,13 @@
5
5
  [![](https://img.shields.io/github/issues/shopware/frontends/nuxt-module?label=nuxt-module%20issues&logo=github)](https://github.com/shopware/frontends/issues?q=is%3Aopen+is%3Aissue+label%3Anuxt-module)
6
6
  [![](https://img.shields.io/github/license/shopware/frontends?color=blue)](#)
7
7
 
8
- Nuxt [module](https://nuxt.com/docs/guide/going-further/modules) that allows you to set up a Nuxt 3 project with Shopware Frontends. It provides the composables and api-client packages.
8
+ Nuxt [module](https://nuxt.com/docs/guide/going-further/modules) that allows you to set up a Nuxt project with Shopware Frontends. It provides the composables and api-client packages.
9
9
 
10
- If you want to use these packages with a different Vue.js framework, see [the guide](https://frontends.shopware.com/getting-started/templates/custom-vue-project.html) for using Shopware Frontends in a custom project.
10
+ If you want to use these packages with a different Vue.js framework, see [the guide](https://developer.shopware.com/frontends/introduction/templates/custom-vue-project.html) for using Shopware Frontends in a custom project.
11
11
 
12
12
  ## Features
13
13
 
14
- - Business logic covered by [Composables](https://npmjs.com/package/@shopware/composables) package. Registering all composable functions globally. [See the reference](https://frontends.shopware.com/packages/composables.html).
14
+ - Business logic covered by [Composables](https://npmjs.com/package/@shopware/composables) package. Registering all composable functions globally. [See the reference](https://developer.shopware.com/frontends/packages/composables.html).
15
15
  - Shopware context shared in Nuxt application.
16
16
  - Configured [API Client](https://npmjs.com/package/@shopware/api-client) package.
17
17
 
@@ -41,7 +41,7 @@ export default defineNuxtConfig({
41
41
  // set the module config
42
42
  shopware: {
43
43
  // connect to your Shopware 6 API instance
44
- endpoint: "https://demo-frontends.shopware.store",
44
+ endpoint: "https://demo-frontends.shopware.store/store-api/",
45
45
  accessToken: "SWSCBHFSNTVMAWNZDNFKSHLAYW",
46
46
  },
47
47
  // or directly in the runtime config
@@ -49,7 +49,7 @@ export default defineNuxtConfig({
49
49
  runtimeConfig: {
50
50
  public: {
51
51
  shopware: {
52
- endpoint: "https://demo-frontends.shopware.store",
52
+ endpoint: "https://demo-frontends.shopware.store/store-api/",
53
53
  accessToken: "SWSCBHFSNTVMAWNZDNFKSHLAYW",
54
54
  },
55
55
  },
@@ -67,7 +67,7 @@ Now you can use any composable function you need without extra import:
67
67
  <script setup>
68
68
  const { login } = useUser();
69
69
  const { refreshSessionContext } = useSessionContext();
70
- refreshSessionContext();
70
+ await refreshSessionContext();
71
71
  </script>
72
72
  ```
73
73
 
@@ -149,34 +149,27 @@ The API Client instance is aware of your custom API types thanks to declaring `#
149
149
 
150
150
  ## Links
151
151
 
152
- - [📘 Documentation](https://frontends.shopware.com)
152
+ - [📘 Documentation](https://developer.shopware.com/frontends)
153
153
 
154
154
  - [📦 API Gen - Types Generator for Shopware 6 OpenAPI Schema](https://npmjs.com/@shopware/api-gen)
155
155
 
156
156
  - [📦 API Client - REST API Client for Shopware 6](https://npmjs.com/@shopware/api-client)
157
157
 
158
158
  - [👥 Community](https://discord.com/channels/1308047705309708348/1405501315160739951) (`#composable-frontend`)
159
+
159
160
  <!-- AUTO GENERATED CHANGELOG -->
160
161
 
161
162
  ## Changelog
162
163
 
163
164
  Full changelog for stable version is available [here](https://github.com/shopware/frontends/blob/main/packages/nuxt-module/CHANGELOG.md)
164
165
 
165
- ### Latest changes: 1.5.0
166
-
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.
172
-
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.
166
+ ### Latest changes: 1.5.2
176
167
 
177
168
  ### Patch Changes
178
169
 
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.
170
+ - [#2598](https://github.com/shopware/frontends/pull/2598) [`204c8f4`](https://github.com/shopware/frontends/commit/204c8f45f737e724db6d00b80c5faef8ddb77cb4) Thanks [@dependabot](https://github.com/apps/dependabot)! - Fix Nuxt plugin injection typing for Nuxt 4.5 and maintenance mode error handling.
180
171
 
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
172
+ - Updated dependencies [[`2ddf156`](https://github.com/shopware/frontends/commit/2ddf156805b2941fe2069e78453fb3c4eb6d44ac), [`204c8f4`](https://github.com/shopware/frontends/commit/204c8f45f737e724db6d00b80c5faef8ddb77cb4), [`7020545`](https://github.com/shopware/frontends/commit/70205458cb9357a068029d0aaef41898ab94b354), [`183c183`](https://github.com/shopware/frontends/commit/183c183f905486c27fa770fd0f4cd9993e86c20e), [`458494e`](https://github.com/shopware/frontends/commit/458494e8bd2be88d4fbf161636a109c8f4efc443), [`183c183`](https://github.com/shopware/frontends/commit/183c183f905486c27fa770fd0f4cd9993e86c20e), [`183c183`](https://github.com/shopware/frontends/commit/183c183f905486c27fa770fd0f4cd9993e86c20e), [`8913956`](https://github.com/shopware/frontends/commit/89139563924163e57cafdd9770fe603f2dbd8cba), [`458494e`](https://github.com/shopware/frontends/commit/458494e8bd2be88d4fbf161636a109c8f4efc443)]:
173
+ - @shopware/helpers@1.8.0
174
+ - @shopware/composables@1.13.0
175
+ - @shopware/api-client@1.6.0
package/dist/index.mjs CHANGED
@@ -87,7 +87,7 @@ const index = defineNuxtModule({
87
87
  icon: "fa6-brands:shopware",
88
88
  view: {
89
89
  type: "iframe",
90
- src: "https://frontends.shopware.com/"
90
+ src: "https://developer.shopware.com/frontends/"
91
91
  }
92
92
  });
93
93
  addCustomTab({
@@ -96,7 +96,7 @@ const index = defineNuxtModule({
96
96
  icon: "carbon:assembly-cluster",
97
97
  view: {
98
98
  type: "iframe",
99
- src: "https://frontends.shopware.com/getting-started/cms/"
99
+ src: "https://developer.shopware.com/frontends/guides/cms/"
100
100
  }
101
101
  });
102
102
  }
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@shopware/nuxt-module",
3
- "version": "1.5.0",
3
+ "version": "1.5.2",
4
4
  "description": "Nuxt 3 module for Shopware Frontends",
5
5
  "author": "Shopware",
6
6
  "repository": {
7
7
  "type": "git",
8
8
  "url": "git+https://github.com/shopware/frontends.git"
9
9
  },
10
- "homepage": "https://frontends.shopware.com/framework/internal-structure.html#nuxt-module",
10
+ "homepage": "https://developer.shopware.com/frontends/concepts/internal-structure.html#nuxt-module",
11
11
  "keywords": [
12
12
  "Nuxt",
13
13
  "Shopware",
@@ -34,20 +34,20 @@
34
34
  "index.cjs"
35
35
  ],
36
36
  "dependencies": {
37
- "@nuxt/kit": "4.4.8",
37
+ "@nuxt/kit": "4.5.2",
38
38
  "defu": "6.1.7",
39
39
  "h3": "1.15.11",
40
40
  "js-cookie": "3.0.7",
41
- "@shopware/composables": "1.12.0",
42
- "@shopware/helpers": "1.7.1",
43
- "@shopware/api-client": "1.5.0"
41
+ "@shopware/composables": "1.13.0",
42
+ "@shopware/helpers": "1.8.0",
43
+ "@shopware/api-client": "1.6.0"
44
44
  },
45
45
  "devDependencies": {
46
- "@nuxt/schema": "4.4.8",
46
+ "@nuxt/schema": "4.5.2",
47
47
  "@typescript/native-preview": "7.0.0-dev.20260205.1",
48
- "nuxt": "4.4.8",
48
+ "nuxt": "4.5.2",
49
49
  "unbuild": "3.6.1",
50
- "vitest": "4.1.9",
50
+ "vitest": "4.1.10",
51
51
  "tsconfig": "0.0.0"
52
52
  },
53
53
  "scripts": {
package/plugin.ts CHANGED
@@ -1,9 +1,11 @@
1
1
  import { createAPIClient } from "@shopware/api-client";
2
2
  import { isMaintenanceMode } from "@shopware/helpers";
3
3
  import { getCookie } from "h3";
4
+ import type { H3Event } from "h3";
4
5
  import Cookies from "js-cookie";
5
6
  import { ref } from "vue";
6
7
 
8
+ import type { Plugin } from "#app";
7
9
  import {
8
10
  createShopwareContext,
9
11
  defineNuxtPlugin,
@@ -16,19 +18,46 @@ import type { ApiClient } from "#shopware";
16
18
 
17
19
  import type { ShopwareNuxtOptions } from "./src";
18
20
 
19
- declare module "#app" {
20
- interface NuxtApp {
21
- $shopwareApiClient: ApiClient;
21
+ type ShopwarePluginInjections = {
22
+ shopwareApiClient: ApiClient;
23
+ };
24
+
25
+ type ShopwarePluginNuxtApp = {
26
+ ssrContext?: {
27
+ event: H3Event;
28
+ };
29
+ vueApp: {
30
+ provide: (name: string, value: unknown) => void;
31
+ };
32
+ };
33
+
34
+ type ApiError = {
35
+ code?: string;
36
+ };
37
+
38
+ function isApiError(error: unknown): error is ApiError {
39
+ if (!error || typeof error !== "object") {
40
+ return false;
22
41
  }
42
+
43
+ const { code } = error as { code?: unknown };
44
+
45
+ return code === undefined || typeof code === "string";
23
46
  }
24
47
 
25
- declare module "vue" {
26
- interface ComponentCustomProperties {
27
- $shopwareApiClient: ApiClient;
48
+ function getApiErrors(data: unknown): ApiError[] {
49
+ if (!data || typeof data !== "object" || !("errors" in data)) {
50
+ return [];
28
51
  }
52
+
53
+ const { errors } = data as { errors?: unknown };
54
+
55
+ return Array.isArray(errors) ? errors.filter(isApiError) : [];
29
56
  }
30
57
 
31
- export default defineNuxtPlugin((NuxtApp) => {
58
+ function setupShopwarePlugin(NuxtApp: ShopwarePluginNuxtApp): {
59
+ provide: ShopwarePluginInjections;
60
+ } {
32
61
  const runtimeConfig = useRuntimeConfig();
33
62
 
34
63
  const shopwareRuntimeConfigPublic = runtimeConfig.public
@@ -99,8 +128,7 @@ export default defineNuxtPlugin((NuxtApp) => {
99
128
  });
100
129
 
101
130
  apiClient.hook("onResponseError", (response) => {
102
- // @ts-expect-error TODO: check maintenance mode and fix typongs here
103
- const error = isMaintenanceMode(response._data?.errors ?? []);
131
+ const error = isMaintenanceMode(getApiErrors(response._data));
104
132
  if (error) {
105
133
  throw showError({
106
134
  statusCode: 503,
@@ -142,4 +170,9 @@ export default defineNuxtPlugin((NuxtApp) => {
142
170
  shopwareApiClient: apiClient as ApiClient,
143
171
  },
144
172
  };
145
- });
173
+ }
174
+
175
+ const shopwarePlugin: Plugin<ShopwarePluginInjections> =
176
+ defineNuxtPlugin<ShopwarePluginInjections>(setupShopwarePlugin);
177
+
178
+ export default shopwarePlugin;