@vue-storefront/next 2.0.1 → 3.0.0-rc.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/dist/client.d.mts +2 -2
- package/dist/client.d.ts +2 -2
- package/dist/client.js +3 -3
- package/dist/client.mjs +3 -3
- package/dist/index.d.mts +42 -5
- package/dist/index.d.ts +42 -5
- package/dist/index.js +22 -15
- package/dist/index.mjs +20 -14
- package/dist/{types-B1fiGk0-.d.mts → types-CL1oQuKL.d.mts} +32 -24
- package/dist/{types-B1fiGk0-.d.ts → types-CL1oQuKL.d.ts} +32 -24
- package/package.json +5 -5
package/dist/client.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SDKApi } from '@vue-storefront/sdk';
|
|
2
|
-
import { b as CreateSdkContextReturn } from './types-
|
|
2
|
+
import { b as CreateSdkContextReturn } from './types-CL1oQuKL.mjs';
|
|
3
3
|
import 'react';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -20,6 +20,6 @@ import 'react';
|
|
|
20
20
|
* Finally you can use the `useSdk` in any client component of your application.
|
|
21
21
|
* @returns [SdkProvider, useSdk] - The SDK provider and the `useSdk` hook.
|
|
22
22
|
*/
|
|
23
|
-
declare function createSdkContext<TSdk extends SDKApi<any>>(
|
|
23
|
+
declare function createSdkContext<TSdk extends SDKApi<any>>(): CreateSdkContextReturn<TSdk>;
|
|
24
24
|
|
|
25
25
|
export { CreateSdkContextReturn, createSdkContext };
|
package/dist/client.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SDKApi } from '@vue-storefront/sdk';
|
|
2
|
-
import { b as CreateSdkContextReturn } from './types-
|
|
2
|
+
import { b as CreateSdkContextReturn } from './types-CL1oQuKL.js';
|
|
3
3
|
import 'react';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -20,6 +20,6 @@ import 'react';
|
|
|
20
20
|
* Finally you can use the `useSdk` in any client component of your application.
|
|
21
21
|
* @returns [SdkProvider, useSdk] - The SDK provider and the `useSdk` hook.
|
|
22
22
|
*/
|
|
23
|
-
declare function createSdkContext<TSdk extends SDKApi<any>>(
|
|
23
|
+
declare function createSdkContext<TSdk extends SDKApi<any>>(): CreateSdkContextReturn<TSdk>;
|
|
24
24
|
|
|
25
25
|
export { CreateSdkContextReturn, createSdkContext };
|
package/dist/client.js
CHANGED
|
@@ -37,9 +37,9 @@ module.exports = __toCommonJS(client_exports);
|
|
|
37
37
|
// src/sdk/client.tsx
|
|
38
38
|
var import_script = __toESM(require("next/script"));
|
|
39
39
|
var import_react = __toESM(require("react"));
|
|
40
|
-
function createSdkContext(
|
|
41
|
-
const SdkContext = (0, import_react.createContext)(
|
|
42
|
-
function SdkProvider({ children }) {
|
|
40
|
+
function createSdkContext() {
|
|
41
|
+
const SdkContext = (0, import_react.createContext)(null);
|
|
42
|
+
function SdkProvider({ children, sdk }) {
|
|
43
43
|
return /* @__PURE__ */ import_react.default.createElement(SdkContext.Provider, { value: sdk }, /* @__PURE__ */ import_react.default.createElement(import_script.default, { strategy: "beforeInteractive", id: "vsfMetaTag" }, `
|
|
44
44
|
const vsfMetaTag = document.createElement("meta");
|
|
45
45
|
vsfMetaTag.setAttribute("name", "generator");
|
package/dist/client.mjs
CHANGED
|
@@ -4,9 +4,9 @@ import "./chunk-EX6ADWAR.mjs";
|
|
|
4
4
|
// src/sdk/client.tsx
|
|
5
5
|
import Script from "next/script";
|
|
6
6
|
import React, { createContext, useContext } from "react";
|
|
7
|
-
function createSdkContext(
|
|
8
|
-
const SdkContext = createContext(
|
|
9
|
-
function SdkProvider({ children }) {
|
|
7
|
+
function createSdkContext() {
|
|
8
|
+
const SdkContext = createContext(null);
|
|
9
|
+
function SdkProvider({ children, sdk }) {
|
|
10
10
|
return /* @__PURE__ */ React.createElement(SdkContext.Provider, { value: sdk }, /* @__PURE__ */ React.createElement(Script, { strategy: "beforeInteractive", id: "vsfMetaTag" }, `
|
|
11
11
|
const vsfMetaTag = document.createElement("meta");
|
|
12
12
|
vsfMetaTag.setAttribute("name", "generator");
|
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-CL1oQuKL.mjs';
|
|
2
2
|
import '@vue-storefront/sdk';
|
|
3
3
|
import 'react';
|
|
4
4
|
|
|
@@ -13,6 +13,13 @@ interface MiddlewareConfig {
|
|
|
13
13
|
* @example "http://localhost:4000"
|
|
14
14
|
*/
|
|
15
15
|
ssrApiUrl?: string;
|
|
16
|
+
/**
|
|
17
|
+
* This is identifier used to invalidate the cache on CDN when the assets change.
|
|
18
|
+
* Usually it's a commit hash.
|
|
19
|
+
* @example "2c106d9619c71c3082c9b59b1d72817363c8ecb9"
|
|
20
|
+
* @default "no-cache-busting-id-set"
|
|
21
|
+
*/
|
|
22
|
+
cdnCacheBustingId?: string;
|
|
16
23
|
}
|
|
17
24
|
interface MultistoreConfig {
|
|
18
25
|
/**
|
|
@@ -41,25 +48,55 @@ interface CreateSdkOptions {
|
|
|
41
48
|
* const options: CreateSdkOptions = {
|
|
42
49
|
* middleware: {
|
|
43
50
|
* apiUrl: "http://localhost:4000",
|
|
51
|
+
* ssrApiUrl: "http://localhost:4000",
|
|
52
|
+
* cdnCacheBustingId: "no-cache-busting-id-set",
|
|
53
|
+
* },
|
|
54
|
+
* multistore: {
|
|
55
|
+
* enabled: false,
|
|
44
56
|
* },
|
|
45
57
|
* };
|
|
46
58
|
*
|
|
47
59
|
* export const { getSdk, createSdkContext } = createSdk(
|
|
48
60
|
* options,
|
|
49
|
-
* ({ buildModule, middlewareModule,
|
|
61
|
+
* ({ buildModule, middlewareModule, config, getRequestHeaders }) => ({
|
|
50
62
|
* unified: buildModule(middlewareModule<UnifiedApiEndpoints>, {
|
|
51
|
-
* apiUrl: middlewareUrl + "/commerce",
|
|
63
|
+
* apiUrl: config.middlewareUrl + "/commerce",
|
|
64
|
+
* cdnCacheBustingId: config.cdnCacheBustingId,
|
|
52
65
|
* defaultRequestConfig: {
|
|
53
66
|
* headers: getRequestHeaders(),
|
|
54
67
|
* },
|
|
68
|
+
* methodsRequestConfig: config.defaultMethodsRequestConfig.unifiedCommerce.middlewareModule,
|
|
55
69
|
* }),
|
|
56
70
|
* contentful: buildModule(contentfulModule, {
|
|
57
|
-
* apiUrl: middlewareUrl + "/cntf",
|
|
71
|
+
* apiUrl: config.middlewareUrl + "/cntf",
|
|
58
72
|
* }),
|
|
59
73
|
* }),
|
|
60
74
|
* );
|
|
61
75
|
* ```
|
|
62
76
|
*/
|
|
63
77
|
declare function createSdk<TConfig extends Record<string, any>>(options: CreateSdkOptions, configDefinition: Config<TConfig>): CreateSdkReturn<TConfig>;
|
|
78
|
+
/**
|
|
79
|
+
* Creates a configuration definition for the SDK.
|
|
80
|
+
* @param config The configuration definition for the SDK.
|
|
81
|
+
* @returns An object containing SDK configuration
|
|
82
|
+
* @example
|
|
83
|
+
* ```tsx
|
|
84
|
+
* const config = defineSdkConfig(
|
|
85
|
+
* ({ buildModule, middlewareModule, config, getRequestHeaders }) => ({
|
|
86
|
+
* unified: buildModule(middlewareModule<UnifiedApiEndpoints>, {
|
|
87
|
+
* apiUrl: config.middlewareUrl + "/commerce",
|
|
88
|
+
* cdnCacheBustingId: config.cdnCacheBustingId,
|
|
89
|
+
* defaultRequestConfig: {
|
|
90
|
+
* headers: getRequestHeaders(),
|
|
91
|
+
* },
|
|
92
|
+
* methodsRequestConfig: config.defaultMethodsRequestConfig.unifiedCommerce.middlewareModule,
|
|
93
|
+
* }),
|
|
94
|
+
* contentful: buildModule(contentfulModule, {
|
|
95
|
+
* apiUrl: config.middlewareUrl + "/cntf",
|
|
96
|
+
* }),
|
|
97
|
+
* })
|
|
98
|
+
* );
|
|
99
|
+
*/
|
|
100
|
+
declare function defineSdkConfig<TConfig extends Record<string, any>>(config: Config<TConfig>): Config<TConfig>;
|
|
64
101
|
|
|
65
|
-
export { type CreateSdkOptions, createSdk };
|
|
102
|
+
export { type CreateSdkOptions, createSdk, defineSdkConfig };
|
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-CL1oQuKL.js';
|
|
2
2
|
import '@vue-storefront/sdk';
|
|
3
3
|
import 'react';
|
|
4
4
|
|
|
@@ -13,6 +13,13 @@ interface MiddlewareConfig {
|
|
|
13
13
|
* @example "http://localhost:4000"
|
|
14
14
|
*/
|
|
15
15
|
ssrApiUrl?: string;
|
|
16
|
+
/**
|
|
17
|
+
* This is identifier used to invalidate the cache on CDN when the assets change.
|
|
18
|
+
* Usually it's a commit hash.
|
|
19
|
+
* @example "2c106d9619c71c3082c9b59b1d72817363c8ecb9"
|
|
20
|
+
* @default "no-cache-busting-id-set"
|
|
21
|
+
*/
|
|
22
|
+
cdnCacheBustingId?: string;
|
|
16
23
|
}
|
|
17
24
|
interface MultistoreConfig {
|
|
18
25
|
/**
|
|
@@ -41,25 +48,55 @@ interface CreateSdkOptions {
|
|
|
41
48
|
* const options: CreateSdkOptions = {
|
|
42
49
|
* middleware: {
|
|
43
50
|
* apiUrl: "http://localhost:4000",
|
|
51
|
+
* ssrApiUrl: "http://localhost:4000",
|
|
52
|
+
* cdnCacheBustingId: "no-cache-busting-id-set",
|
|
53
|
+
* },
|
|
54
|
+
* multistore: {
|
|
55
|
+
* enabled: false,
|
|
44
56
|
* },
|
|
45
57
|
* };
|
|
46
58
|
*
|
|
47
59
|
* export const { getSdk, createSdkContext } = createSdk(
|
|
48
60
|
* options,
|
|
49
|
-
* ({ buildModule, middlewareModule,
|
|
61
|
+
* ({ buildModule, middlewareModule, config, getRequestHeaders }) => ({
|
|
50
62
|
* unified: buildModule(middlewareModule<UnifiedApiEndpoints>, {
|
|
51
|
-
* apiUrl: middlewareUrl + "/commerce",
|
|
63
|
+
* apiUrl: config.middlewareUrl + "/commerce",
|
|
64
|
+
* cdnCacheBustingId: config.cdnCacheBustingId,
|
|
52
65
|
* defaultRequestConfig: {
|
|
53
66
|
* headers: getRequestHeaders(),
|
|
54
67
|
* },
|
|
68
|
+
* methodsRequestConfig: config.defaultMethodsRequestConfig.unifiedCommerce.middlewareModule,
|
|
55
69
|
* }),
|
|
56
70
|
* contentful: buildModule(contentfulModule, {
|
|
57
|
-
* apiUrl: middlewareUrl + "/cntf",
|
|
71
|
+
* apiUrl: config.middlewareUrl + "/cntf",
|
|
58
72
|
* }),
|
|
59
73
|
* }),
|
|
60
74
|
* );
|
|
61
75
|
* ```
|
|
62
76
|
*/
|
|
63
77
|
declare function createSdk<TConfig extends Record<string, any>>(options: CreateSdkOptions, configDefinition: Config<TConfig>): CreateSdkReturn<TConfig>;
|
|
78
|
+
/**
|
|
79
|
+
* Creates a configuration definition for the SDK.
|
|
80
|
+
* @param config The configuration definition for the SDK.
|
|
81
|
+
* @returns An object containing SDK configuration
|
|
82
|
+
* @example
|
|
83
|
+
* ```tsx
|
|
84
|
+
* const config = defineSdkConfig(
|
|
85
|
+
* ({ buildModule, middlewareModule, config, getRequestHeaders }) => ({
|
|
86
|
+
* unified: buildModule(middlewareModule<UnifiedApiEndpoints>, {
|
|
87
|
+
* apiUrl: config.middlewareUrl + "/commerce",
|
|
88
|
+
* cdnCacheBustingId: config.cdnCacheBustingId,
|
|
89
|
+
* defaultRequestConfig: {
|
|
90
|
+
* headers: getRequestHeaders(),
|
|
91
|
+
* },
|
|
92
|
+
* methodsRequestConfig: config.defaultMethodsRequestConfig.unifiedCommerce.middlewareModule,
|
|
93
|
+
* }),
|
|
94
|
+
* contentful: buildModule(contentfulModule, {
|
|
95
|
+
* apiUrl: config.middlewareUrl + "/cntf",
|
|
96
|
+
* }),
|
|
97
|
+
* })
|
|
98
|
+
* );
|
|
99
|
+
*/
|
|
100
|
+
declare function defineSdkConfig<TConfig extends Record<string, any>>(config: Config<TConfig>): Config<TConfig>;
|
|
64
101
|
|
|
65
|
-
export { type CreateSdkOptions, createSdk };
|
|
102
|
+
export { type CreateSdkOptions, createSdk, defineSdkConfig };
|
package/dist/index.js
CHANGED
|
@@ -36,7 +36,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
36
36
|
// src/index.ts
|
|
37
37
|
var src_exports = {};
|
|
38
38
|
__export(src_exports, {
|
|
39
|
-
createSdk: () => createSdk
|
|
39
|
+
createSdk: () => createSdk,
|
|
40
|
+
defineSdkConfig: () => defineSdkConfig
|
|
40
41
|
});
|
|
41
42
|
module.exports = __toCommonJS(src_exports);
|
|
42
43
|
|
|
@@ -79,23 +80,19 @@ function composeMiddlewareUrl({
|
|
|
79
80
|
}
|
|
80
81
|
|
|
81
82
|
// ../shared/src/helpers/defaultConfigs.ts
|
|
82
|
-
var
|
|
83
|
+
var defaultMethodsRequestConfig = {
|
|
83
84
|
unifiedCommerce: {
|
|
84
85
|
middlewareModule: {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
searchProducts: { method: "GET" }
|
|
91
|
-
}
|
|
86
|
+
getCategories: { method: "GET" },
|
|
87
|
+
getProductDetails: { method: "GET" },
|
|
88
|
+
getProductReviews: { method: "GET" },
|
|
89
|
+
getProducts: { method: "GET" },
|
|
90
|
+
searchProducts: { method: "GET" }
|
|
92
91
|
}
|
|
93
92
|
},
|
|
94
93
|
unifiedCms: {
|
|
95
94
|
middlewareModule: {
|
|
96
|
-
|
|
97
|
-
getEntries: { method: "GET" }
|
|
98
|
-
}
|
|
95
|
+
getEntries: { method: "GET" }
|
|
99
96
|
}
|
|
100
97
|
}
|
|
101
98
|
};
|
|
@@ -126,17 +123,23 @@ function resolveDynamicContext(context) {
|
|
|
126
123
|
// src/sdk/index.tsx
|
|
127
124
|
function createSdk(options, configDefinition) {
|
|
128
125
|
function getSdk(dynamicContext = {}) {
|
|
126
|
+
var _a;
|
|
129
127
|
const { getRequestHeaders } = resolveDynamicContext(dynamicContext);
|
|
130
128
|
const middlewareUrl = composeMiddlewareUrl({
|
|
131
129
|
options,
|
|
132
130
|
headers: getRequestHeaders()
|
|
133
131
|
});
|
|
134
132
|
const resolvedConfig = configDefinition({
|
|
135
|
-
defaults:
|
|
133
|
+
defaults: defaultMethodsRequestConfig,
|
|
136
134
|
buildModule: import_sdk.buildModule,
|
|
137
135
|
middlewareModule: import_sdk.middlewareModule,
|
|
138
136
|
getRequestHeaders,
|
|
139
|
-
middlewareUrl
|
|
137
|
+
middlewareUrl,
|
|
138
|
+
config: {
|
|
139
|
+
middlewareUrl,
|
|
140
|
+
defaultMethodsRequestConfig,
|
|
141
|
+
cdnCacheBustingId: (_a = options.middleware.cdnCacheBustingId) != null ? _a : "no-cache-busting-id-set"
|
|
142
|
+
}
|
|
140
143
|
});
|
|
141
144
|
return (0, import_sdk.initSDK)(resolvedConfig);
|
|
142
145
|
}
|
|
@@ -144,7 +147,11 @@ function createSdk(options, configDefinition) {
|
|
|
144
147
|
getSdk
|
|
145
148
|
};
|
|
146
149
|
}
|
|
150
|
+
function defineSdkConfig(config) {
|
|
151
|
+
return config;
|
|
152
|
+
}
|
|
147
153
|
// Annotate the CommonJS export names for ESM import in node:
|
|
148
154
|
0 && (module.exports = {
|
|
149
|
-
createSdk
|
|
155
|
+
createSdk,
|
|
156
|
+
defineSdkConfig
|
|
150
157
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -42,23 +42,19 @@ function composeMiddlewareUrl({
|
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
// ../shared/src/helpers/defaultConfigs.ts
|
|
45
|
-
var
|
|
45
|
+
var defaultMethodsRequestConfig = {
|
|
46
46
|
unifiedCommerce: {
|
|
47
47
|
middlewareModule: {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
searchProducts: { method: "GET" }
|
|
54
|
-
}
|
|
48
|
+
getCategories: { method: "GET" },
|
|
49
|
+
getProductDetails: { method: "GET" },
|
|
50
|
+
getProductReviews: { method: "GET" },
|
|
51
|
+
getProducts: { method: "GET" },
|
|
52
|
+
searchProducts: { method: "GET" }
|
|
55
53
|
}
|
|
56
54
|
},
|
|
57
55
|
unifiedCms: {
|
|
58
56
|
middlewareModule: {
|
|
59
|
-
|
|
60
|
-
getEntries: { method: "GET" }
|
|
61
|
-
}
|
|
57
|
+
getEntries: { method: "GET" }
|
|
62
58
|
}
|
|
63
59
|
}
|
|
64
60
|
};
|
|
@@ -89,17 +85,23 @@ function resolveDynamicContext(context) {
|
|
|
89
85
|
// src/sdk/index.tsx
|
|
90
86
|
function createSdk(options, configDefinition) {
|
|
91
87
|
function getSdk(dynamicContext = {}) {
|
|
88
|
+
var _a;
|
|
92
89
|
const { getRequestHeaders } = resolveDynamicContext(dynamicContext);
|
|
93
90
|
const middlewareUrl = composeMiddlewareUrl({
|
|
94
91
|
options,
|
|
95
92
|
headers: getRequestHeaders()
|
|
96
93
|
});
|
|
97
94
|
const resolvedConfig = configDefinition({
|
|
98
|
-
defaults:
|
|
95
|
+
defaults: defaultMethodsRequestConfig,
|
|
99
96
|
buildModule,
|
|
100
97
|
middlewareModule,
|
|
101
98
|
getRequestHeaders,
|
|
102
|
-
middlewareUrl
|
|
99
|
+
middlewareUrl,
|
|
100
|
+
config: {
|
|
101
|
+
middlewareUrl,
|
|
102
|
+
defaultMethodsRequestConfig,
|
|
103
|
+
cdnCacheBustingId: (_a = options.middleware.cdnCacheBustingId) != null ? _a : "no-cache-busting-id-set"
|
|
104
|
+
}
|
|
103
105
|
});
|
|
104
106
|
return initSDK(resolvedConfig);
|
|
105
107
|
}
|
|
@@ -107,6 +109,10 @@ function createSdk(options, configDefinition) {
|
|
|
107
109
|
getSdk
|
|
108
110
|
};
|
|
109
111
|
}
|
|
112
|
+
function defineSdkConfig(config) {
|
|
113
|
+
return config;
|
|
114
|
+
}
|
|
110
115
|
export {
|
|
111
|
-
createSdk
|
|
116
|
+
createSdk,
|
|
117
|
+
defineSdkConfig
|
|
112
118
|
};
|
|
@@ -1,34 +1,30 @@
|
|
|
1
1
|
import { SDKApi, buildModule, middlewareModule } from '@vue-storefront/sdk';
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
3
|
|
|
4
|
-
declare const
|
|
4
|
+
declare const defaultMethodsRequestConfig: {
|
|
5
5
|
readonly unifiedCommerce: {
|
|
6
6
|
readonly middlewareModule: {
|
|
7
|
-
readonly
|
|
8
|
-
readonly
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
readonly
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
readonly
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
readonly
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
readonly
|
|
21
|
-
readonly method: "GET";
|
|
22
|
-
};
|
|
7
|
+
readonly getCategories: {
|
|
8
|
+
readonly method: "GET";
|
|
9
|
+
};
|
|
10
|
+
readonly getProductDetails: {
|
|
11
|
+
readonly method: "GET";
|
|
12
|
+
};
|
|
13
|
+
readonly getProductReviews: {
|
|
14
|
+
readonly method: "GET";
|
|
15
|
+
};
|
|
16
|
+
readonly getProducts: {
|
|
17
|
+
readonly method: "GET";
|
|
18
|
+
};
|
|
19
|
+
readonly searchProducts: {
|
|
20
|
+
readonly method: "GET";
|
|
23
21
|
};
|
|
24
22
|
};
|
|
25
23
|
};
|
|
26
24
|
readonly unifiedCms: {
|
|
27
25
|
readonly middlewareModule: {
|
|
28
|
-
readonly
|
|
29
|
-
readonly
|
|
30
|
-
readonly method: "GET";
|
|
31
|
-
};
|
|
26
|
+
readonly getEntries: {
|
|
27
|
+
readonly method: "GET";
|
|
32
28
|
};
|
|
33
29
|
};
|
|
34
30
|
};
|
|
@@ -46,13 +42,25 @@ type DynamicContext = {
|
|
|
46
42
|
type StaticContext = {
|
|
47
43
|
buildModule: typeof buildModule;
|
|
48
44
|
middlewareModule: typeof middlewareModule;
|
|
45
|
+
/**
|
|
46
|
+
* @deprecated Use `config.middlewareUrl` instead.
|
|
47
|
+
*/
|
|
49
48
|
middlewareUrl: string;
|
|
50
|
-
|
|
49
|
+
/**
|
|
50
|
+
* @deprecated Use `config.defaultMethodsRequestConfig` instead.
|
|
51
|
+
*/
|
|
52
|
+
defaults: typeof defaultMethodsRequestConfig;
|
|
53
|
+
config: {
|
|
54
|
+
middlewareUrl: string;
|
|
55
|
+
defaultMethodsRequestConfig: typeof defaultMethodsRequestConfig;
|
|
56
|
+
cdnCacheBustingId: string;
|
|
57
|
+
};
|
|
51
58
|
};
|
|
52
59
|
type InjectedContext = DynamicContext & StaticContext;
|
|
53
60
|
type Config<TConfig> = (context: InjectedContext) => TConfig;
|
|
54
|
-
type SdkProviderProps = {
|
|
61
|
+
type SdkProviderProps<TSdk> = {
|
|
55
62
|
children: ReactNode;
|
|
63
|
+
sdk: TSdk;
|
|
56
64
|
};
|
|
57
65
|
interface CreateSdkReturn<TConfig extends Record<string, any>> {
|
|
58
66
|
/**
|
|
@@ -101,7 +109,7 @@ interface CreateSdkReturn<TConfig extends Record<string, any>> {
|
|
|
101
109
|
getSdk: (dynamicContext?: GetSdkContext) => SDKApi<TConfig>;
|
|
102
110
|
}
|
|
103
111
|
type CreateSdkContextReturn<TSdk extends SDKApi<any>> = readonly [
|
|
104
|
-
({ children }: SdkProviderProps) => JSX.Element,
|
|
112
|
+
({ children }: SdkProviderProps<TSdk>) => JSX.Element,
|
|
105
113
|
() => TSdk
|
|
106
114
|
];
|
|
107
115
|
|
|
@@ -1,34 +1,30 @@
|
|
|
1
1
|
import { SDKApi, buildModule, middlewareModule } from '@vue-storefront/sdk';
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
3
|
|
|
4
|
-
declare const
|
|
4
|
+
declare const defaultMethodsRequestConfig: {
|
|
5
5
|
readonly unifiedCommerce: {
|
|
6
6
|
readonly middlewareModule: {
|
|
7
|
-
readonly
|
|
8
|
-
readonly
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
readonly
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
readonly
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
readonly
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
readonly
|
|
21
|
-
readonly method: "GET";
|
|
22
|
-
};
|
|
7
|
+
readonly getCategories: {
|
|
8
|
+
readonly method: "GET";
|
|
9
|
+
};
|
|
10
|
+
readonly getProductDetails: {
|
|
11
|
+
readonly method: "GET";
|
|
12
|
+
};
|
|
13
|
+
readonly getProductReviews: {
|
|
14
|
+
readonly method: "GET";
|
|
15
|
+
};
|
|
16
|
+
readonly getProducts: {
|
|
17
|
+
readonly method: "GET";
|
|
18
|
+
};
|
|
19
|
+
readonly searchProducts: {
|
|
20
|
+
readonly method: "GET";
|
|
23
21
|
};
|
|
24
22
|
};
|
|
25
23
|
};
|
|
26
24
|
readonly unifiedCms: {
|
|
27
25
|
readonly middlewareModule: {
|
|
28
|
-
readonly
|
|
29
|
-
readonly
|
|
30
|
-
readonly method: "GET";
|
|
31
|
-
};
|
|
26
|
+
readonly getEntries: {
|
|
27
|
+
readonly method: "GET";
|
|
32
28
|
};
|
|
33
29
|
};
|
|
34
30
|
};
|
|
@@ -46,13 +42,25 @@ type DynamicContext = {
|
|
|
46
42
|
type StaticContext = {
|
|
47
43
|
buildModule: typeof buildModule;
|
|
48
44
|
middlewareModule: typeof middlewareModule;
|
|
45
|
+
/**
|
|
46
|
+
* @deprecated Use `config.middlewareUrl` instead.
|
|
47
|
+
*/
|
|
49
48
|
middlewareUrl: string;
|
|
50
|
-
|
|
49
|
+
/**
|
|
50
|
+
* @deprecated Use `config.defaultMethodsRequestConfig` instead.
|
|
51
|
+
*/
|
|
52
|
+
defaults: typeof defaultMethodsRequestConfig;
|
|
53
|
+
config: {
|
|
54
|
+
middlewareUrl: string;
|
|
55
|
+
defaultMethodsRequestConfig: typeof defaultMethodsRequestConfig;
|
|
56
|
+
cdnCacheBustingId: string;
|
|
57
|
+
};
|
|
51
58
|
};
|
|
52
59
|
type InjectedContext = DynamicContext & StaticContext;
|
|
53
60
|
type Config<TConfig> = (context: InjectedContext) => TConfig;
|
|
54
|
-
type SdkProviderProps = {
|
|
61
|
+
type SdkProviderProps<TSdk> = {
|
|
55
62
|
children: ReactNode;
|
|
63
|
+
sdk: TSdk;
|
|
56
64
|
};
|
|
57
65
|
interface CreateSdkReturn<TConfig extends Record<string, any>> {
|
|
58
66
|
/**
|
|
@@ -101,7 +109,7 @@ interface CreateSdkReturn<TConfig extends Record<string, any>> {
|
|
|
101
109
|
getSdk: (dynamicContext?: GetSdkContext) => SDKApi<TConfig>;
|
|
102
110
|
}
|
|
103
111
|
type CreateSdkContextReturn<TSdk extends SDKApi<any>> = readonly [
|
|
104
|
-
({ children }: SdkProviderProps) => JSX.Element,
|
|
112
|
+
({ children }: SdkProviderProps<TSdk>) => JSX.Element,
|
|
105
113
|
() => TSdk
|
|
106
114
|
];
|
|
107
115
|
|
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": "
|
|
5
|
+
"version": "3.0.0-rc.0",
|
|
6
6
|
"exports": {
|
|
7
7
|
".": {
|
|
8
8
|
"import": "./dist/index.mjs",
|
|
@@ -30,20 +30,20 @@
|
|
|
30
30
|
],
|
|
31
31
|
"scripts": {
|
|
32
32
|
"build": "tsup && yarn build:app-router && yarn build:pages-router",
|
|
33
|
-
"build:app-router": "cd __tests__/apps/app-router && yarn build",
|
|
34
|
-
"build:pages-router": "cd __tests__/apps/pages-router && yarn build",
|
|
33
|
+
"build:app-router": "cd __tests__/apps/app-router && yarn install && yarn build",
|
|
34
|
+
"build:pages-router": "cd __tests__/apps/pages-router && yarn install && yarn build",
|
|
35
35
|
"dev:app-router": "cd __tests__/apps/app-router && yarn dev",
|
|
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
39
|
"test:app-router": "start-server-and-test dev:middleware localhost:4000/test_integration/getSuccess dev:app-router localhost:3000 \"yarn test:e2e\"",
|
|
40
40
|
"test:pages-router": "start-server-and-test dev:middleware localhost:4000/test_integration/getSuccess dev:pages-router localhost:3000 \"yarn test:e2e\"",
|
|
41
|
-
"test": "yarn test:app-router && yarn test:pages-router",
|
|
41
|
+
"test:e2e:run": "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": "^3.
|
|
46
|
+
"@vue-storefront/sdk": "^3.1.0"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
49
|
"@types/react": "^18.2.31",
|