@vue-storefront/nuxt 3.0.3 → 3.1.1
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/dist/module.json +1 -1
- package/dist/module.mjs +5 -0
- package/dist/runtime/defineSdkConfig.template +18 -17
- package/package.json +7 -8
- package/CHANGELOG.md +0 -17
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { defineNuxtModule, createResolver, addTypeTemplate, addImports, addTemplate, addPluginTemplate, addImportsSources } from '@nuxt/kit';
|
|
2
2
|
import { genInlineTypeImport } from 'knitwork';
|
|
3
|
+
import { defu } from 'defu';
|
|
3
4
|
|
|
4
5
|
const module = defineNuxtModule({
|
|
5
6
|
meta: {
|
|
@@ -22,6 +23,10 @@ const module = defineNuxtModule({
|
|
|
22
23
|
const projectRootResolver = createResolver(projectLayer.config.rootDir);
|
|
23
24
|
const buildDirResolver = createResolver(nuxt.options.buildDir);
|
|
24
25
|
const localResolver = createResolver(import.meta.url);
|
|
26
|
+
nuxt.options.runtimeConfig.public.vsf = defu(
|
|
27
|
+
nuxt.options.runtimeConfig.public?.vsf,
|
|
28
|
+
options
|
|
29
|
+
);
|
|
25
30
|
nuxt.options.app.head.meta = [
|
|
26
31
|
...nuxt.options.app.head.meta ?? [],
|
|
27
32
|
{
|
|
@@ -1,11 +1,17 @@
|
|
|
1
|
-
import { buildModule } from "@vue-storefront/sdk";
|
|
1
|
+
import { buildModule, middlewareModule } from "@vue-storefront/sdk";
|
|
2
2
|
import { composeMiddlewareUrl, useNuxtApp, useRequestHeaders } from "#imports";
|
|
3
3
|
import { SdkModuleOptions } from "./vsfModule";
|
|
4
4
|
|
|
5
5
|
type InjectedContext = {
|
|
6
6
|
buildModule: typeof buildModule;
|
|
7
|
+
middlewareModule: typeof middlewareModule;
|
|
7
8
|
middlewareUrl: string;
|
|
9
|
+
/**
|
|
10
|
+
* @deprecated
|
|
11
|
+
* Use `getRequestHeaders` instead.
|
|
12
|
+
*/
|
|
8
13
|
getCookieHeader: () => Record<string, string>;
|
|
14
|
+
getRequestHeaders: () => Record<string, string>;
|
|
9
15
|
};
|
|
10
16
|
|
|
11
17
|
type Config<TConfig> = (context: InjectedContext) => TConfig;
|
|
@@ -23,18 +29,15 @@ const moduleConfig: SdkModuleOptions = <%= options.moduleConfig %>;
|
|
|
23
29
|
* contentfulModule,
|
|
24
30
|
* ContentfulModuleType,
|
|
25
31
|
* } from "@vsf-enterprise/contentful-sdk";
|
|
26
|
-
* import {
|
|
27
|
-
*
|
|
28
|
-
*
|
|
32
|
+
* import type { UnifiedApiEndpoints } from "../storefront-middleware/types";
|
|
33
|
+
*
|
|
29
34
|
* export default defineSdkConfig(
|
|
30
|
-
* ({ buildModule, middlewareUrl, getCookieHeader }) => ({
|
|
31
|
-
* unified: buildModule(
|
|
35
|
+
* ({ buildModule, middlewareModule, middlewareUrl, getCookieHeader }) => ({
|
|
36
|
+
* unified: buildModule(middlewareModule<UnifiedApiEndpoints>, {
|
|
32
37
|
* apiUrl: middlewareUrl + "/commerce",
|
|
33
|
-
*
|
|
34
|
-
* headers: getCookieHeader,
|
|
35
|
-
* },
|
|
38
|
+
* defaultRequestConfig: { headers: { ...getCookieHeader() } },
|
|
36
39
|
* }),
|
|
37
|
-
* contentful: buildModule
|
|
40
|
+
* contentful: buildModule(contentfulModule, {
|
|
38
41
|
* apiUrl: middlewareUrl + "/cntf",
|
|
39
42
|
* }),
|
|
40
43
|
* }),
|
|
@@ -45,24 +48,22 @@ export function defineSdkConfig<TConfig>(config: Config<TConfig>) {
|
|
|
45
48
|
return () => {
|
|
46
49
|
const nuxtApp = useNuxtApp()
|
|
47
50
|
const runtimeConfig = useRuntimeConfig();
|
|
48
|
-
const { middleware, multistore } = runtimeConfig.public;
|
|
49
|
-
const resolvedOptions = {
|
|
50
|
-
middleware: middleware ?? moduleConfig.middleware,
|
|
51
|
-
multistore: multistore ?? moduleConfig.multistore,
|
|
52
|
-
}
|
|
53
51
|
|
|
54
52
|
const requestHeaders = useRequestHeaders(["x-forwarded-host", "host"]);
|
|
55
53
|
const middlewareUrl = composeMiddlewareUrl({
|
|
56
|
-
options:
|
|
54
|
+
options: runtimeConfig.public.vsf,
|
|
57
55
|
headers: requestHeaders,
|
|
58
56
|
});
|
|
59
57
|
|
|
60
58
|
const getCookieHeader = () => useRequestHeaders(["cookie"]);
|
|
59
|
+
const getRequestHeaders = () => useRequestHeaders();
|
|
61
60
|
|
|
62
61
|
return config({
|
|
63
62
|
buildModule,
|
|
63
|
+
middlewareModule,
|
|
64
64
|
middlewareUrl,
|
|
65
|
-
getCookieHeader
|
|
65
|
+
getCookieHeader,
|
|
66
|
+
getRequestHeaders
|
|
66
67
|
});
|
|
67
68
|
}
|
|
68
69
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vue-storefront/nuxt",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.1.1",
|
|
4
4
|
"description": "Vue Storefront dedicated features for Nuxt",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -20,26 +20,25 @@
|
|
|
20
20
|
"build": "nuxt-module-build build && yarn build:app",
|
|
21
21
|
"build:app": "cd __tests__/app && yarn build",
|
|
22
22
|
"dev": "cd __tests__/app && yarn dev",
|
|
23
|
-
"dev:middleware": "cd
|
|
23
|
+
"dev:middleware": "cd ../shared/src/__tests__/middleware && yarn dev",
|
|
24
24
|
"lint": "eslint --ext .vue,.js,.ts .",
|
|
25
|
-
"test": "start-server-and-test dev:middleware localhost:4000/test_integration/
|
|
26
|
-
"test:e2e": "cd
|
|
25
|
+
"test:e2e:run": "start-server-and-test dev:middleware localhost:4000/test_integration/getSuccess dev localhost:3000/ssr \"yarn test:e2e\"",
|
|
26
|
+
"test:e2e": "cd ../shared/ && yarn test:e2e",
|
|
27
27
|
"test:watch": "vitest watch",
|
|
28
28
|
"prepare": "nuxi prepare"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@nuxt/kit": "^3.7.4",
|
|
32
32
|
"@nuxt/schema": "^3.7.4",
|
|
33
|
-
"@vue-storefront/sdk": "^1.
|
|
34
|
-
"knitwork": "^1.0.0"
|
|
33
|
+
"@vue-storefront/sdk": "^1.4.0",
|
|
34
|
+
"knitwork": "^1.0.0",
|
|
35
|
+
"defu": "^6.0.0"
|
|
35
36
|
},
|
|
36
37
|
"devDependencies": {
|
|
37
38
|
"@types/node": "^18.11.17",
|
|
38
39
|
"@nuxt/devtools": "^1.0.0",
|
|
39
40
|
"@nuxt/module-builder": "0.5.2",
|
|
40
|
-
"@nuxt/schema": "3.7.4",
|
|
41
41
|
"@nuxt/test-utils": "3.7.4",
|
|
42
|
-
"@vue-storefront/sdk": "*",
|
|
43
42
|
"nuxt": "3.7.4",
|
|
44
43
|
"start-server-and-test": "^2.0.3",
|
|
45
44
|
"vitest": "^0.34.6"
|
package/CHANGELOG.md
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
# Change log
|
|
2
|
-
|
|
3
|
-
## 3.0.3
|
|
4
|
-
|
|
5
|
-
- **[CHANGED]** `@nuxt/kit` locked `3.7.4` version to `@nuxt/kit@^3.7.4`
|
|
6
|
-
|
|
7
|
-
## 3.0.2
|
|
8
|
-
|
|
9
|
-
- **[FIXED]** Multi-store URL calculation, now working correctly in the browser.
|
|
10
|
-
|
|
11
|
-
## 3.0.1
|
|
12
|
-
|
|
13
|
-
- **[CHANGED]** Set `@vue-storefront/sdk` as a dependency instead of a peer dependency
|
|
14
|
-
|
|
15
|
-
## 3.0.0
|
|
16
|
-
|
|
17
|
-
- **[BREAKING]** Rewritten from scratch. Now the package exports a Nuxt module which allows to initialize the Vue Storefront SDK.
|