@shopware/nuxt-module 1.5.1 → 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.
Files changed (3) hide show
  1. package/README.md +10 -8
  2. package/package.json +7 -7
  3. package/plugin.ts +43 -10
package/README.md CHANGED
@@ -5,7 +5,7 @@
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
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
 
@@ -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
  },
@@ -163,11 +163,13 @@ The API Client instance is aware of your custom API types thanks to declaring `#
163
163
 
164
164
  Full changelog for stable version is available [here](https://github.com/shopware/frontends/blob/main/packages/nuxt-module/CHANGELOG.md)
165
165
 
166
- ### Latest changes: 1.5.1
166
+ ### Latest changes: 1.5.2
167
167
 
168
168
  ### Patch Changes
169
169
 
170
- - Updated dependencies [[`6315350`](https://github.com/shopware/frontends/commit/6315350add0464abef153343897d42f5808f2003), [`b767721`](https://github.com/shopware/frontends/commit/b767721847bf3391f9067eca7a045089fb22fce0), [`f16c5a0`](https://github.com/shopware/frontends/commit/f16c5a0785d6187b73c3edcf37feab7c90bd7988), [`978b02c`](https://github.com/shopware/frontends/commit/978b02c969ca4b16f5fc1d7a953ec4cce3d98173), [`6572aa8`](https://github.com/shopware/frontends/commit/6572aa84431e1f4a34d6cf04e549037692d638a6), [`744833b`](https://github.com/shopware/frontends/commit/744833b9d7d2f8ea1f5dfe65be3fa554dbe4a09f), [`e03c91b`](https://github.com/shopware/frontends/commit/e03c91be172374894d90b7a0111855b76719fee1), [`33facb1`](https://github.com/shopware/frontends/commit/33facb178792c8cb26b47ab984ac48c08ab4b72b), [`9137475`](https://github.com/shopware/frontends/commit/91374753cedb2034385f642e6af11314f2971caa), [`474d3fe`](https://github.com/shopware/frontends/commit/474d3fed346816135b0c7c797990b215a8b691c0), [`38379a5`](https://github.com/shopware/frontends/commit/38379a5d52ab09008774533ef417ebe2cde3f7fd)]:
171
- - @shopware/composables@1.12.1
172
- - @shopware/api-client@1.5.1
173
- - @shopware/helpers@1.7.2
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.
171
+
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shopware/nuxt-module",
3
- "version": "1.5.1",
3
+ "version": "1.5.2",
4
4
  "description": "Nuxt 3 module for Shopware Frontends",
5
5
  "author": "Shopware",
6
6
  "repository": {
@@ -34,18 +34,18 @@
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.1",
42
- "@shopware/helpers": "1.7.2",
43
- "@shopware/api-client": "1.5.1"
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
50
  "vitest": "4.1.10",
51
51
  "tsconfig": "0.0.0"
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;