@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.
- package/README.md +10 -8
- package/package.json +7 -7
- package/plugin.ts +43 -10
package/README.md
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
[](https://github.com/shopware/frontends/issues?q=is%3Aopen+is%3Aissue+label%3Anuxt-module)
|
|
6
6
|
[](#)
|
|
7
7
|
|
|
8
|
-
Nuxt [module](https://nuxt.com/docs/guide/going-further/modules) that allows you to set up a Nuxt
|
|
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.
|
|
166
|
+
### Latest changes: 1.5.2
|
|
167
167
|
|
|
168
168
|
### Patch Changes
|
|
169
169
|
|
|
170
|
-
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
- @shopware/helpers@1.
|
|
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.
|
|
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.
|
|
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.
|
|
42
|
-
"@shopware/helpers": "1.
|
|
43
|
-
"@shopware/api-client": "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.
|
|
46
|
+
"@nuxt/schema": "4.5.2",
|
|
47
47
|
"@typescript/native-preview": "7.0.0-dev.20260205.1",
|
|
48
|
-
"nuxt": "4.
|
|
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
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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
|
-
|
|
26
|
-
|
|
27
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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;
|