@vue-storefront/next 1.0.1 → 1.1.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/CHANGELOG.md +31 -1
- package/dist/client.d.mts +1 -1
- package/dist/client.d.ts +1 -1
- package/dist/index.d.mts +8 -12
- package/dist/index.d.ts +8 -12
- package/dist/index.js +9 -3
- package/dist/index.mjs +10 -4
- package/dist/{types-m9jwrtV3.d.mts → types-C6rAwI5a.d.mts} +2 -1
- package/dist/{types-m9jwrtV3.d.ts → types-C6rAwI5a.d.ts} +2 -1
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,9 +1,39 @@
|
|
|
1
1
|
# Change log
|
|
2
2
|
|
|
3
|
+
## 1.1.0
|
|
4
|
+
|
|
5
|
+
- **[ADDED]** `middlewareModule` to `createSdk` params.
|
|
6
|
+
|
|
7
|
+
```diff [sdk.config.ts]
|
|
8
|
+
- import { UnifiedApiExtension } from "storefront-middleware/types"
|
|
9
|
+
+ import { UnifiedEndpoints } from "storefront-middleware/types"
|
|
10
|
+
|
|
11
|
+
export const { getSdk } = createSdk(
|
|
12
|
+
options,
|
|
13
|
+
- ({ buildModule, middlewareUrl, getRequestHeaders }) => ({
|
|
14
|
+
- commerce: buildModule(unifiedModule<UnifiedApiExtension>, {
|
|
15
|
+
- apiUrl: `${middlewareUrl}/commerce`,
|
|
16
|
+
- requestOptions: {
|
|
17
|
+
- headers: getRequestHeaders,
|
|
18
|
+
+ ({ buildModule, middlewareModule, middlewareUrl, getRequestHeaders }) => ({
|
|
19
|
+
+ commerce: buildModule(middlewareModule<UnifiedEndpoints>, {
|
|
20
|
+
+ apiUrl: `${middlewareUrl}/commerce`,
|
|
21
|
+
+ defaultRequestConfig: {
|
|
22
|
+
+ headers: getRequestHeaders(),
|
|
23
|
+
},
|
|
24
|
+
}),
|
|
25
|
+
})
|
|
26
|
+
);
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## 1.0.2
|
|
30
|
+
|
|
31
|
+
- **[FIXED]** Multi-store URL calculation, now working correctly in the browser.
|
|
32
|
+
|
|
3
33
|
## 1.0.1
|
|
4
34
|
|
|
5
35
|
- **[CHANGED]** Set `@vue-storefront/sdk` as a dependency instead of a peer dependency
|
|
6
36
|
|
|
7
37
|
## 1.0.0
|
|
8
38
|
|
|
9
|
-
- Initialized the package
|
|
39
|
+
- Initialized the package
|
package/dist/client.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { SDKApi } from '@vue-storefront/sdk';
|
|
2
2
|
import React from 'react';
|
|
3
|
-
import { S as SdkProviderProps } from './types-
|
|
3
|
+
import { S as SdkProviderProps } from './types-C6rAwI5a.mjs';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Creates a new SDK context. This function is dedicated for the client-side usage.
|
package/dist/client.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { SDKApi } from '@vue-storefront/sdk';
|
|
2
2
|
import React from 'react';
|
|
3
|
-
import { S as SdkProviderProps } from './types-
|
|
3
|
+
import { S as SdkProviderProps } from './types-C6rAwI5a.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Creates a new SDK context. This function is dedicated for the client-side usage.
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as Config, a as CreateSdkReturn } from './types-
|
|
1
|
+
import { C as Config, a as CreateSdkReturn } from './types-C6rAwI5a.mjs';
|
|
2
2
|
import '@vue-storefront/sdk';
|
|
3
3
|
import 'react';
|
|
4
4
|
|
|
@@ -34,13 +34,9 @@ interface CreateSdkOptions {
|
|
|
34
34
|
* @returns An object containing the `getSdk` function.
|
|
35
35
|
* @example
|
|
36
36
|
* ```tsx
|
|
37
|
-
* import {
|
|
38
|
-
* contentfulModule,
|
|
39
|
-
* ContentfulModuleType,
|
|
40
|
-
* } from "@vsf-enterprise/contentful-sdk";
|
|
41
|
-
* import { unifiedModule } from "@vsf-enterprise/unified-sdk";
|
|
37
|
+
* import { contentfulModule } from "@vsf-enterprise/contentful-sdk";
|
|
42
38
|
* import { CreateSdkOptions, createSdk } from "@vue-storefront/next";
|
|
43
|
-
* import type {
|
|
39
|
+
* import type { UnifiedApiEndpoints } from "../storefront-middleware/types";
|
|
44
40
|
*
|
|
45
41
|
* const options: CreateSdkOptions = {
|
|
46
42
|
* middleware: {
|
|
@@ -50,14 +46,14 @@ interface CreateSdkOptions {
|
|
|
50
46
|
*
|
|
51
47
|
* export const { getSdk, createSdkContext } = createSdk(
|
|
52
48
|
* options,
|
|
53
|
-
* ({ buildModule, middlewareUrl, getRequestHeaders }) => ({
|
|
54
|
-
* unified: buildModule(
|
|
49
|
+
* ({ buildModule, middlewareModule, middlewareUrl, getRequestHeaders }) => ({
|
|
50
|
+
* unified: buildModule(middlewareModule<UnifiedApiEndpoints>, {
|
|
55
51
|
* apiUrl: middlewareUrl + "/commerce",
|
|
56
|
-
*
|
|
57
|
-
* headers: getRequestHeaders,
|
|
52
|
+
* defaultRequestConfig: {
|
|
53
|
+
* headers: getRequestHeaders(),
|
|
58
54
|
* },
|
|
59
55
|
* }),
|
|
60
|
-
* contentful: buildModule
|
|
56
|
+
* contentful: buildModule(contentfulModule, {
|
|
61
57
|
* apiUrl: middlewareUrl + "/cntf",
|
|
62
58
|
* }),
|
|
63
59
|
* }),
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as Config, a as CreateSdkReturn } from './types-
|
|
1
|
+
import { C as Config, a as CreateSdkReturn } from './types-C6rAwI5a.js';
|
|
2
2
|
import '@vue-storefront/sdk';
|
|
3
3
|
import 'react';
|
|
4
4
|
|
|
@@ -34,13 +34,9 @@ interface CreateSdkOptions {
|
|
|
34
34
|
* @returns An object containing the `getSdk` function.
|
|
35
35
|
* @example
|
|
36
36
|
* ```tsx
|
|
37
|
-
* import {
|
|
38
|
-
* contentfulModule,
|
|
39
|
-
* ContentfulModuleType,
|
|
40
|
-
* } from "@vsf-enterprise/contentful-sdk";
|
|
41
|
-
* import { unifiedModule } from "@vsf-enterprise/unified-sdk";
|
|
37
|
+
* import { contentfulModule } from "@vsf-enterprise/contentful-sdk";
|
|
42
38
|
* import { CreateSdkOptions, createSdk } from "@vue-storefront/next";
|
|
43
|
-
* import type {
|
|
39
|
+
* import type { UnifiedApiEndpoints } from "../storefront-middleware/types";
|
|
44
40
|
*
|
|
45
41
|
* const options: CreateSdkOptions = {
|
|
46
42
|
* middleware: {
|
|
@@ -50,14 +46,14 @@ interface CreateSdkOptions {
|
|
|
50
46
|
*
|
|
51
47
|
* export const { getSdk, createSdkContext } = createSdk(
|
|
52
48
|
* options,
|
|
53
|
-
* ({ buildModule, middlewareUrl, getRequestHeaders }) => ({
|
|
54
|
-
* unified: buildModule(
|
|
49
|
+
* ({ buildModule, middlewareModule, middlewareUrl, getRequestHeaders }) => ({
|
|
50
|
+
* unified: buildModule(middlewareModule<UnifiedApiEndpoints>, {
|
|
55
51
|
* apiUrl: middlewareUrl + "/commerce",
|
|
56
|
-
*
|
|
57
|
-
* headers: getRequestHeaders,
|
|
52
|
+
* defaultRequestConfig: {
|
|
53
|
+
* headers: getRequestHeaders(),
|
|
58
54
|
* },
|
|
59
55
|
* }),
|
|
60
|
-
* contentful: buildModule
|
|
56
|
+
* contentful: buildModule(contentfulModule, {
|
|
61
57
|
* apiUrl: middlewareUrl + "/cntf",
|
|
62
58
|
* }),
|
|
63
59
|
* }),
|
package/dist/index.js
CHANGED
|
@@ -45,18 +45,23 @@ function calculateMiddlewareUrl({
|
|
|
45
45
|
options,
|
|
46
46
|
headers
|
|
47
47
|
}) {
|
|
48
|
-
var _a, _b;
|
|
48
|
+
var _a, _b, _c;
|
|
49
49
|
const { apiUrl, ssrApiUrl } = options.middleware;
|
|
50
50
|
if (typeof window !== "undefined") {
|
|
51
|
+
if ((_a = options.multistore) == null ? void 0 : _a.enabled) {
|
|
52
|
+
const url2 = new URL(apiUrl);
|
|
53
|
+
url2.host = window.location.host;
|
|
54
|
+
return url2.href;
|
|
55
|
+
}
|
|
51
56
|
return apiUrl;
|
|
52
57
|
}
|
|
53
58
|
if (ssrApiUrl) {
|
|
54
59
|
return ssrApiUrl;
|
|
55
60
|
}
|
|
56
|
-
if (!((
|
|
61
|
+
if (!((_b = options.multistore) == null ? void 0 : _b.enabled)) {
|
|
57
62
|
return apiUrl;
|
|
58
63
|
}
|
|
59
|
-
const forwardedHost = (
|
|
64
|
+
const forwardedHost = (_c = headers["x-forwarded-host"]) != null ? _c : headers.host;
|
|
60
65
|
const resolvedForwardedHost = forwardedHost && Array.isArray(forwardedHost) ? forwardedHost[0] : forwardedHost;
|
|
61
66
|
const url = new URL(apiUrl);
|
|
62
67
|
url.host = resolvedForwardedHost || new URL(apiUrl).host;
|
|
@@ -106,6 +111,7 @@ function createSdk(options, configDefinition) {
|
|
|
106
111
|
});
|
|
107
112
|
const resolvedConfig = configDefinition({
|
|
108
113
|
buildModule: import_sdk.buildModule,
|
|
114
|
+
middlewareModule: import_sdk.middlewareModule,
|
|
109
115
|
getRequestHeaders,
|
|
110
116
|
middlewareUrl
|
|
111
117
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -8,18 +8,23 @@ function calculateMiddlewareUrl({
|
|
|
8
8
|
options,
|
|
9
9
|
headers
|
|
10
10
|
}) {
|
|
11
|
-
var _a, _b;
|
|
11
|
+
var _a, _b, _c;
|
|
12
12
|
const { apiUrl, ssrApiUrl } = options.middleware;
|
|
13
13
|
if (typeof window !== "undefined") {
|
|
14
|
+
if ((_a = options.multistore) == null ? void 0 : _a.enabled) {
|
|
15
|
+
const url2 = new URL(apiUrl);
|
|
16
|
+
url2.host = window.location.host;
|
|
17
|
+
return url2.href;
|
|
18
|
+
}
|
|
14
19
|
return apiUrl;
|
|
15
20
|
}
|
|
16
21
|
if (ssrApiUrl) {
|
|
17
22
|
return ssrApiUrl;
|
|
18
23
|
}
|
|
19
|
-
if (!((
|
|
24
|
+
if (!((_b = options.multistore) == null ? void 0 : _b.enabled)) {
|
|
20
25
|
return apiUrl;
|
|
21
26
|
}
|
|
22
|
-
const forwardedHost = (
|
|
27
|
+
const forwardedHost = (_c = headers["x-forwarded-host"]) != null ? _c : headers.host;
|
|
23
28
|
const resolvedForwardedHost = forwardedHost && Array.isArray(forwardedHost) ? forwardedHost[0] : forwardedHost;
|
|
24
29
|
const url = new URL(apiUrl);
|
|
25
30
|
url.host = resolvedForwardedHost || new URL(apiUrl).host;
|
|
@@ -37,7 +42,7 @@ function composeMiddlewareUrl({
|
|
|
37
42
|
}
|
|
38
43
|
|
|
39
44
|
// src/sdk/index.tsx
|
|
40
|
-
import { buildModule, initSDK } from "@vue-storefront/sdk";
|
|
45
|
+
import { buildModule, initSDK, middlewareModule } from "@vue-storefront/sdk";
|
|
41
46
|
|
|
42
47
|
// src/sdk/helpers/resolveDynamicContext.ts
|
|
43
48
|
var BLACKLISTED_HEADERS = /* @__PURE__ */ new Set(["host"]);
|
|
@@ -69,6 +74,7 @@ function createSdk(options, configDefinition) {
|
|
|
69
74
|
});
|
|
70
75
|
const resolvedConfig = configDefinition({
|
|
71
76
|
buildModule,
|
|
77
|
+
middlewareModule,
|
|
72
78
|
getRequestHeaders,
|
|
73
79
|
middlewareUrl
|
|
74
80
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SDKApi, buildModule } from '@vue-storefront/sdk';
|
|
1
|
+
import { SDKApi, buildModule, middlewareModule } from '@vue-storefront/sdk';
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
3
|
|
|
4
4
|
type GetSdkContext = {
|
|
@@ -12,6 +12,7 @@ type DynamicContext = {
|
|
|
12
12
|
};
|
|
13
13
|
type StaticContext = {
|
|
14
14
|
buildModule: typeof buildModule;
|
|
15
|
+
middlewareModule: typeof middlewareModule;
|
|
15
16
|
middlewareUrl: string;
|
|
16
17
|
};
|
|
17
18
|
type InjectedContext = DynamicContext & StaticContext;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SDKApi, buildModule } from '@vue-storefront/sdk';
|
|
1
|
+
import { SDKApi, buildModule, middlewareModule } from '@vue-storefront/sdk';
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
3
|
|
|
4
4
|
type GetSdkContext = {
|
|
@@ -12,6 +12,7 @@ type DynamicContext = {
|
|
|
12
12
|
};
|
|
13
13
|
type StaticContext = {
|
|
14
14
|
buildModule: typeof buildModule;
|
|
15
|
+
middlewareModule: typeof middlewareModule;
|
|
15
16
|
middlewareUrl: string;
|
|
16
17
|
};
|
|
17
18
|
type InjectedContext = DynamicContext & StaticContext;
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@vue-storefront/next",
|
|
3
3
|
"description": "Vue Storefront dedicated features for Next.js",
|
|
4
4
|
"license": "MIT",
|
|
5
|
-
"version": "1.0
|
|
5
|
+
"version": "1.1.0",
|
|
6
6
|
"exports": {
|
|
7
7
|
".": {
|
|
8
8
|
"import": "./dist/index.mjs",
|
|
@@ -36,14 +36,14 @@
|
|
|
36
36
|
"dev:pages-router": "cd __tests__/apps/pages-router && yarn dev",
|
|
37
37
|
"dev:middleware": "cd ../../shared/src/__tests__/middleware && yarn dev",
|
|
38
38
|
"lint": "eslint . --ext .ts",
|
|
39
|
-
"test:app-router": "start-server-and-test dev:middleware localhost:4000/test_integration/
|
|
40
|
-
"test:pages-router": "start-server-and-test dev:middleware localhost:4000/test_integration/
|
|
39
|
+
"test:app-router": "start-server-and-test dev:middleware localhost:4000/test_integration/getSuccess dev:app-router localhost:3000 \"yarn test:e2e\"",
|
|
40
|
+
"test:pages-router": "start-server-and-test dev:middleware localhost:4000/test_integration/getSuccess dev:pages-router localhost:3000 \"yarn test:e2e\"",
|
|
41
41
|
"test": "yarn test:app-router && yarn test:pages-router",
|
|
42
42
|
"test:e2e": "cd ../../shared/ && yarn test:e2e",
|
|
43
43
|
"test:unit": "vitest run"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@vue-storefront/sdk": "^1.
|
|
46
|
+
"@vue-storefront/sdk": "^1.4.0"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
49
|
"@types/react": "^18.2.31",
|