@vue-storefront/next 4.2.0 → 4.3.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/README.md +2 -0
- package/dist/client.d.mts +2 -2
- package/dist/client.d.ts +2 -2
- package/dist/client.js +1 -0
- package/dist/client.mjs +1 -1
- package/dist/index.d.mts +11 -34
- package/dist/index.d.ts +11 -34
- package/dist/index.js +74 -44
- package/dist/index.mjs +73 -45
- package/dist/{types-UzPeXhBu.d.mts → types-FxigqFRO.d.mts} +58 -11
- package/dist/{types-UzPeXhBu.d.ts → types-FxigqFRO.d.ts} +58 -11
- package/package.json +18 -32
- /package/dist/{chunk-FUJQIYOF.mjs → chunk-FWCSY2DS.mjs} +0 -0
package/README.md
CHANGED
|
@@ -18,6 +18,7 @@ npm install --save-dev @vue-storefront/next
|
|
|
18
18
|
2. Create SDK config file - `sdk.config.ts` in root directory of your project:
|
|
19
19
|
|
|
20
20
|
The `createSdk` function expects
|
|
21
|
+
|
|
21
22
|
- base SDK options including the middleware and (optionally) the multistore configuration as a first argument,
|
|
22
23
|
- and a factory function for the SDK configuration as a second argument. Those factory function receives a context, useful for creating the SDK configuration.
|
|
23
24
|
|
|
@@ -55,6 +56,7 @@ export const { getSdk, createSdkContext } = createSdk(
|
|
|
55
56
|
```
|
|
56
57
|
|
|
57
58
|
The `createSdk` function returns
|
|
59
|
+
|
|
58
60
|
- the `getSdk` function, which is used to create the new SDK instance,
|
|
59
61
|
- and the `createSdkContext` function, which is used to create the SDK context, to share the same SDK instance on the Client side.
|
|
60
62
|
|
package/dist/client.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { SDKApi } from '@vue-storefront/sdk';
|
|
2
|
-
import { S as SfContract,
|
|
3
|
-
export { M as Maybe,
|
|
2
|
+
import { S as SfContract, c as CreateSdkContextReturn } from './types-FxigqFRO.mjs';
|
|
3
|
+
export { M as Maybe, e as SfState, d as SfStateProps, f as createSfStateProvider } from './types-FxigqFRO.mjs';
|
|
4
4
|
import 'react';
|
|
5
5
|
|
|
6
6
|
/**
|
package/dist/client.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { SDKApi } from '@vue-storefront/sdk';
|
|
2
|
-
import { S as SfContract,
|
|
3
|
-
export { M as Maybe,
|
|
2
|
+
import { S as SfContract, c as CreateSdkContextReturn } from './types-FxigqFRO.js';
|
|
3
|
+
export { M as Maybe, e as SfState, d as SfStateProps, f as createSfStateProvider } from './types-FxigqFRO.js';
|
|
4
4
|
import 'react';
|
|
5
5
|
|
|
6
6
|
/**
|
package/dist/client.js
CHANGED
package/dist/client.mjs
CHANGED
package/dist/index.d.mts
CHANGED
|
@@ -1,39 +1,8 @@
|
|
|
1
|
-
import { C as
|
|
1
|
+
import { C as CreateSdkOptions, a as Config, b as CreateSdkReturn } from './types-FxigqFRO.mjs';
|
|
2
|
+
import * as _vue_storefront_logger from '@vue-storefront/logger';
|
|
2
3
|
import '@vue-storefront/sdk';
|
|
3
4
|
import 'react';
|
|
4
5
|
|
|
5
|
-
interface MiddlewareConfig {
|
|
6
|
-
/**
|
|
7
|
-
* The URL of the middleware.
|
|
8
|
-
* @example "http://localhost:4000"
|
|
9
|
-
*/
|
|
10
|
-
apiUrl: string;
|
|
11
|
-
/**
|
|
12
|
-
* The URL of the middleware for server-side rendering.
|
|
13
|
-
* @example "http://localhost:4000"
|
|
14
|
-
*/
|
|
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;
|
|
23
|
-
}
|
|
24
|
-
interface MultistoreConfig {
|
|
25
|
-
/**
|
|
26
|
-
* Whether the multistore is enabled or not.
|
|
27
|
-
* @example false
|
|
28
|
-
* @default false
|
|
29
|
-
*/
|
|
30
|
-
enabled: boolean;
|
|
31
|
-
}
|
|
32
|
-
interface CreateSdkOptions {
|
|
33
|
-
multistore?: MultistoreConfig;
|
|
34
|
-
middleware: MiddlewareConfig;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
6
|
/**
|
|
38
7
|
* Creates an SDK for the given configuration definition.
|
|
39
8
|
* @param options - The options for creating the SDK.
|
|
@@ -109,4 +78,12 @@ type ResolveSdkOptionsConfig = {
|
|
|
109
78
|
*/
|
|
110
79
|
declare function resolveSdkOptions(input: CreateSdkOptions, options?: Partial<ResolveSdkOptionsConfig>): CreateSdkOptions;
|
|
111
80
|
|
|
112
|
-
|
|
81
|
+
type LogVerbosity = "emergency" | "alert" | "critical" | "error" | "warning" | "notice" | "info" | "debug";
|
|
82
|
+
type LoggerOptions = Partial<{
|
|
83
|
+
verbosity: LogVerbosity;
|
|
84
|
+
includeStackTrace: boolean;
|
|
85
|
+
}>;
|
|
86
|
+
|
|
87
|
+
declare const createLogger: (options?: LoggerOptions) => _vue_storefront_logger.LoggerInterface;
|
|
88
|
+
|
|
89
|
+
export { CreateSdkOptions, createLogger, createSdk, defineSdkConfig, resolveSdkOptions };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,39 +1,8 @@
|
|
|
1
|
-
import { C as
|
|
1
|
+
import { C as CreateSdkOptions, a as Config, b as CreateSdkReturn } from './types-FxigqFRO.js';
|
|
2
|
+
import * as _vue_storefront_logger from '@vue-storefront/logger';
|
|
2
3
|
import '@vue-storefront/sdk';
|
|
3
4
|
import 'react';
|
|
4
5
|
|
|
5
|
-
interface MiddlewareConfig {
|
|
6
|
-
/**
|
|
7
|
-
* The URL of the middleware.
|
|
8
|
-
* @example "http://localhost:4000"
|
|
9
|
-
*/
|
|
10
|
-
apiUrl: string;
|
|
11
|
-
/**
|
|
12
|
-
* The URL of the middleware for server-side rendering.
|
|
13
|
-
* @example "http://localhost:4000"
|
|
14
|
-
*/
|
|
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;
|
|
23
|
-
}
|
|
24
|
-
interface MultistoreConfig {
|
|
25
|
-
/**
|
|
26
|
-
* Whether the multistore is enabled or not.
|
|
27
|
-
* @example false
|
|
28
|
-
* @default false
|
|
29
|
-
*/
|
|
30
|
-
enabled: boolean;
|
|
31
|
-
}
|
|
32
|
-
interface CreateSdkOptions {
|
|
33
|
-
multistore?: MultistoreConfig;
|
|
34
|
-
middleware: MiddlewareConfig;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
6
|
/**
|
|
38
7
|
* Creates an SDK for the given configuration definition.
|
|
39
8
|
* @param options - The options for creating the SDK.
|
|
@@ -109,4 +78,12 @@ type ResolveSdkOptionsConfig = {
|
|
|
109
78
|
*/
|
|
110
79
|
declare function resolveSdkOptions(input: CreateSdkOptions, options?: Partial<ResolveSdkOptionsConfig>): CreateSdkOptions;
|
|
111
80
|
|
|
112
|
-
|
|
81
|
+
type LogVerbosity = "emergency" | "alert" | "critical" | "error" | "warning" | "notice" | "info" | "debug";
|
|
82
|
+
type LoggerOptions = Partial<{
|
|
83
|
+
verbosity: LogVerbosity;
|
|
84
|
+
includeStackTrace: boolean;
|
|
85
|
+
}>;
|
|
86
|
+
|
|
87
|
+
declare const createLogger: (options?: LoggerOptions) => _vue_storefront_logger.LoggerInterface;
|
|
88
|
+
|
|
89
|
+
export { CreateSdkOptions, createLogger, createSdk, defineSdkConfig, resolveSdkOptions };
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
var __defProp = Object.defineProperty;
|
|
2
3
|
var __defProps = Object.defineProperties;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -36,13 +37,55 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
36
37
|
// src/index.ts
|
|
37
38
|
var src_exports = {};
|
|
38
39
|
__export(src_exports, {
|
|
40
|
+
createLogger: () => createLogger,
|
|
39
41
|
createSdk: () => createSdk,
|
|
40
42
|
defineSdkConfig: () => defineSdkConfig,
|
|
41
43
|
resolveSdkOptions: () => resolveSdkOptions
|
|
42
44
|
});
|
|
43
45
|
module.exports = __toCommonJS(src_exports);
|
|
44
46
|
|
|
45
|
-
//
|
|
47
|
+
// src/sdk/helpers/resolveDynamicContext.ts
|
|
48
|
+
var BLACKLISTED_HEADERS = /* @__PURE__ */ new Set(["host"]);
|
|
49
|
+
function isAppRouterHeaders(headers) {
|
|
50
|
+
return headers && "entries" in headers;
|
|
51
|
+
}
|
|
52
|
+
function resolveDynamicContext(context) {
|
|
53
|
+
return __spreadProps(__spreadValues({}, context), {
|
|
54
|
+
getRequestHeaders() {
|
|
55
|
+
var _a;
|
|
56
|
+
const headers = ((_a = context.getRequestHeaders) == null ? void 0 : _a.call(context)) || {};
|
|
57
|
+
const resolvedHeaders = isAppRouterHeaders(headers) ? Object.fromEntries(headers.entries()) : headers;
|
|
58
|
+
return Object.fromEntries(
|
|
59
|
+
Object.entries(resolvedHeaders).filter(
|
|
60
|
+
([key]) => !BLACKLISTED_HEADERS.has(key)
|
|
61
|
+
)
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// src/sdk/helpers/defaultConfigs.ts
|
|
68
|
+
var defaultMethodsRequestConfig = {
|
|
69
|
+
unifiedCommerce: {
|
|
70
|
+
middlewareModule: {
|
|
71
|
+
getCategory: { method: "GET" },
|
|
72
|
+
getCategories: { method: "GET" },
|
|
73
|
+
getProductDetails: { method: "GET" },
|
|
74
|
+
getProductReviews: { method: "GET" },
|
|
75
|
+
getProducts: { method: "GET" },
|
|
76
|
+
getCurrencies: { method: "GET" },
|
|
77
|
+
searchProducts: { method: "GET" }
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
unifiedCms: {
|
|
81
|
+
middlewareModule: {
|
|
82
|
+
getPage: { method: "GET" },
|
|
83
|
+
getEntries: { method: "GET" }
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
// src/sdk/helpers/composeMiddlewareUrl.ts
|
|
46
89
|
function calculateMiddlewareUrl({
|
|
47
90
|
options,
|
|
48
91
|
headers
|
|
@@ -80,51 +123,8 @@ function composeMiddlewareUrl({
|
|
|
80
123
|
return removeTrailingSlash(url);
|
|
81
124
|
}
|
|
82
125
|
|
|
83
|
-
// ../shared/src/helpers/defaultConfigs.ts
|
|
84
|
-
var defaultMethodsRequestConfig = {
|
|
85
|
-
unifiedCommerce: {
|
|
86
|
-
middlewareModule: {
|
|
87
|
-
getCategory: { method: "GET" },
|
|
88
|
-
getCategories: { method: "GET" },
|
|
89
|
-
getProductDetails: { method: "GET" },
|
|
90
|
-
getProductReviews: { method: "GET" },
|
|
91
|
-
getProducts: { method: "GET" },
|
|
92
|
-
getCurrencies: { method: "GET" },
|
|
93
|
-
searchProducts: { method: "GET" }
|
|
94
|
-
}
|
|
95
|
-
},
|
|
96
|
-
unifiedCms: {
|
|
97
|
-
middlewareModule: {
|
|
98
|
-
getPage: { method: "GET" },
|
|
99
|
-
getEntries: { method: "GET" }
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
};
|
|
103
|
-
|
|
104
126
|
// src/sdk/index.tsx
|
|
105
127
|
var import_sdk = require("@vue-storefront/sdk");
|
|
106
|
-
|
|
107
|
-
// src/sdk/helpers/resolveDynamicContext.ts
|
|
108
|
-
var BLACKLISTED_HEADERS = /* @__PURE__ */ new Set(["host"]);
|
|
109
|
-
function isAppRouterHeaders(headers) {
|
|
110
|
-
return headers && "entries" in headers;
|
|
111
|
-
}
|
|
112
|
-
function resolveDynamicContext(context) {
|
|
113
|
-
return __spreadProps(__spreadValues({}, context), {
|
|
114
|
-
getRequestHeaders() {
|
|
115
|
-
var _a;
|
|
116
|
-
const headers = ((_a = context.getRequestHeaders) == null ? void 0 : _a.call(context)) || {};
|
|
117
|
-
const resolvedHeaders = isAppRouterHeaders(headers) ? Object.fromEntries(headers.entries()) : headers;
|
|
118
|
-
return Object.fromEntries(
|
|
119
|
-
Object.entries(resolvedHeaders).filter(
|
|
120
|
-
([key]) => !BLACKLISTED_HEADERS.has(key)
|
|
121
|
-
)
|
|
122
|
-
);
|
|
123
|
-
}
|
|
124
|
-
});
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
// src/sdk/index.tsx
|
|
128
128
|
function createSdk(options, configDefinition) {
|
|
129
129
|
function getSdk(dynamicContext = {}) {
|
|
130
130
|
var _a;
|
|
@@ -172,8 +172,38 @@ function resolveSdkOptions(input, options = {}) {
|
|
|
172
172
|
}
|
|
173
173
|
return input;
|
|
174
174
|
}
|
|
175
|
+
|
|
176
|
+
// src/logger/index.ts
|
|
177
|
+
var import_logger = require("@vue-storefront/logger");
|
|
178
|
+
|
|
179
|
+
// src/logger/injectMetadata.ts
|
|
180
|
+
function injectMetadata(logger, externalData) {
|
|
181
|
+
return new Proxy(logger, {
|
|
182
|
+
get(target, prop) {
|
|
183
|
+
const targetProp = target[prop];
|
|
184
|
+
if (typeof targetProp === "function") {
|
|
185
|
+
return (...args) => {
|
|
186
|
+
const [logData, metadata] = args;
|
|
187
|
+
targetProp(logData, __spreadValues(__spreadValues({}, metadata), externalData));
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
return targetProp;
|
|
191
|
+
}
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
// src/logger/index.ts
|
|
196
|
+
var createLogger = (options) => {
|
|
197
|
+
const logger = import_logger.LoggerFactory.create(import_logger.LoggerType.ConsolaGcp, options);
|
|
198
|
+
return injectMetadata(logger, {
|
|
199
|
+
alokai: {
|
|
200
|
+
context: "storefront"
|
|
201
|
+
}
|
|
202
|
+
});
|
|
203
|
+
};
|
|
175
204
|
// Annotate the CommonJS export names for ESM import in node:
|
|
176
205
|
0 && (module.exports = {
|
|
206
|
+
createLogger,
|
|
177
207
|
createSdk,
|
|
178
208
|
defineSdkConfig,
|
|
179
209
|
resolveSdkOptions
|
package/dist/index.mjs
CHANGED
|
@@ -1,9 +1,50 @@
|
|
|
1
1
|
import {
|
|
2
2
|
__spreadProps,
|
|
3
3
|
__spreadValues
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-FWCSY2DS.mjs";
|
|
5
5
|
|
|
6
|
-
//
|
|
6
|
+
// src/sdk/helpers/resolveDynamicContext.ts
|
|
7
|
+
var BLACKLISTED_HEADERS = /* @__PURE__ */ new Set(["host"]);
|
|
8
|
+
function isAppRouterHeaders(headers) {
|
|
9
|
+
return headers && "entries" in headers;
|
|
10
|
+
}
|
|
11
|
+
function resolveDynamicContext(context) {
|
|
12
|
+
return __spreadProps(__spreadValues({}, context), {
|
|
13
|
+
getRequestHeaders() {
|
|
14
|
+
var _a;
|
|
15
|
+
const headers = ((_a = context.getRequestHeaders) == null ? void 0 : _a.call(context)) || {};
|
|
16
|
+
const resolvedHeaders = isAppRouterHeaders(headers) ? Object.fromEntries(headers.entries()) : headers;
|
|
17
|
+
return Object.fromEntries(
|
|
18
|
+
Object.entries(resolvedHeaders).filter(
|
|
19
|
+
([key]) => !BLACKLISTED_HEADERS.has(key)
|
|
20
|
+
)
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// src/sdk/helpers/defaultConfigs.ts
|
|
27
|
+
var defaultMethodsRequestConfig = {
|
|
28
|
+
unifiedCommerce: {
|
|
29
|
+
middlewareModule: {
|
|
30
|
+
getCategory: { method: "GET" },
|
|
31
|
+
getCategories: { method: "GET" },
|
|
32
|
+
getProductDetails: { method: "GET" },
|
|
33
|
+
getProductReviews: { method: "GET" },
|
|
34
|
+
getProducts: { method: "GET" },
|
|
35
|
+
getCurrencies: { method: "GET" },
|
|
36
|
+
searchProducts: { method: "GET" }
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
unifiedCms: {
|
|
40
|
+
middlewareModule: {
|
|
41
|
+
getPage: { method: "GET" },
|
|
42
|
+
getEntries: { method: "GET" }
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
// src/sdk/helpers/composeMiddlewareUrl.ts
|
|
7
48
|
function calculateMiddlewareUrl({
|
|
8
49
|
options,
|
|
9
50
|
headers
|
|
@@ -41,51 +82,8 @@ function composeMiddlewareUrl({
|
|
|
41
82
|
return removeTrailingSlash(url);
|
|
42
83
|
}
|
|
43
84
|
|
|
44
|
-
// ../shared/src/helpers/defaultConfigs.ts
|
|
45
|
-
var defaultMethodsRequestConfig = {
|
|
46
|
-
unifiedCommerce: {
|
|
47
|
-
middlewareModule: {
|
|
48
|
-
getCategory: { method: "GET" },
|
|
49
|
-
getCategories: { method: "GET" },
|
|
50
|
-
getProductDetails: { method: "GET" },
|
|
51
|
-
getProductReviews: { method: "GET" },
|
|
52
|
-
getProducts: { method: "GET" },
|
|
53
|
-
getCurrencies: { method: "GET" },
|
|
54
|
-
searchProducts: { method: "GET" }
|
|
55
|
-
}
|
|
56
|
-
},
|
|
57
|
-
unifiedCms: {
|
|
58
|
-
middlewareModule: {
|
|
59
|
-
getPage: { method: "GET" },
|
|
60
|
-
getEntries: { method: "GET" }
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
};
|
|
64
|
-
|
|
65
85
|
// src/sdk/index.tsx
|
|
66
86
|
import { buildModule, initSDK, middlewareModule } from "@vue-storefront/sdk";
|
|
67
|
-
|
|
68
|
-
// src/sdk/helpers/resolveDynamicContext.ts
|
|
69
|
-
var BLACKLISTED_HEADERS = /* @__PURE__ */ new Set(["host"]);
|
|
70
|
-
function isAppRouterHeaders(headers) {
|
|
71
|
-
return headers && "entries" in headers;
|
|
72
|
-
}
|
|
73
|
-
function resolveDynamicContext(context) {
|
|
74
|
-
return __spreadProps(__spreadValues({}, context), {
|
|
75
|
-
getRequestHeaders() {
|
|
76
|
-
var _a;
|
|
77
|
-
const headers = ((_a = context.getRequestHeaders) == null ? void 0 : _a.call(context)) || {};
|
|
78
|
-
const resolvedHeaders = isAppRouterHeaders(headers) ? Object.fromEntries(headers.entries()) : headers;
|
|
79
|
-
return Object.fromEntries(
|
|
80
|
-
Object.entries(resolvedHeaders).filter(
|
|
81
|
-
([key]) => !BLACKLISTED_HEADERS.has(key)
|
|
82
|
-
)
|
|
83
|
-
);
|
|
84
|
-
}
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
// src/sdk/index.tsx
|
|
89
87
|
function createSdk(options, configDefinition) {
|
|
90
88
|
function getSdk(dynamicContext = {}) {
|
|
91
89
|
var _a;
|
|
@@ -133,7 +131,37 @@ function resolveSdkOptions(input, options = {}) {
|
|
|
133
131
|
}
|
|
134
132
|
return input;
|
|
135
133
|
}
|
|
134
|
+
|
|
135
|
+
// src/logger/index.ts
|
|
136
|
+
import { LoggerFactory, LoggerType } from "@vue-storefront/logger";
|
|
137
|
+
|
|
138
|
+
// src/logger/injectMetadata.ts
|
|
139
|
+
function injectMetadata(logger, externalData) {
|
|
140
|
+
return new Proxy(logger, {
|
|
141
|
+
get(target, prop) {
|
|
142
|
+
const targetProp = target[prop];
|
|
143
|
+
if (typeof targetProp === "function") {
|
|
144
|
+
return (...args) => {
|
|
145
|
+
const [logData, metadata] = args;
|
|
146
|
+
targetProp(logData, __spreadValues(__spreadValues({}, metadata), externalData));
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
return targetProp;
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
// src/logger/index.ts
|
|
155
|
+
var createLogger = (options) => {
|
|
156
|
+
const logger = LoggerFactory.create(LoggerType.ConsolaGcp, options);
|
|
157
|
+
return injectMetadata(logger, {
|
|
158
|
+
alokai: {
|
|
159
|
+
context: "storefront"
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
};
|
|
136
163
|
export {
|
|
164
|
+
createLogger,
|
|
137
165
|
createSdk,
|
|
138
166
|
defineSdkConfig,
|
|
139
167
|
resolveSdkOptions
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SDKApi, buildModule, middlewareModule } from '@vue-storefront/sdk';
|
|
2
|
-
import React, { ReactNode } from 'react';
|
|
2
|
+
import React, { PropsWithChildren, ReactNode } from 'react';
|
|
3
3
|
|
|
4
4
|
declare const defaultMethodsRequestConfig: {
|
|
5
5
|
readonly unifiedCommerce: {
|
|
@@ -66,17 +66,64 @@ interface SfState<TSfContract extends SfContract> extends SfStateProps<TSfContra
|
|
|
66
66
|
declare function createSfStateProvider<TSfContract extends SfContract>(): {
|
|
67
67
|
SfStateProvider: ({ children, initialData, }: {
|
|
68
68
|
initialData: SfStateProps<TSfContract>;
|
|
69
|
-
} &
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
69
|
+
} & PropsWithChildren) => React.JSX.Element;
|
|
70
|
+
useSfCurrencyState: () => [
|
|
71
|
+
TSfContract["SfCurrency"],
|
|
72
|
+
(currency: TSfContract["SfCurrency"]) => void
|
|
73
|
+
];
|
|
74
|
+
useSfCurrenciesState: () => [
|
|
75
|
+
TSfContract["SfCurrency"][],
|
|
76
|
+
(currencies: TSfContract["SfCurrency"][]) => void
|
|
77
|
+
];
|
|
78
|
+
useSfLocaleState: () => [
|
|
79
|
+
TSfContract["SfLocale"],
|
|
80
|
+
(locale: TSfContract["SfLocale"]) => void
|
|
81
|
+
];
|
|
82
|
+
useSfLocalesState: () => [
|
|
83
|
+
TSfContract["SfLocale"][],
|
|
84
|
+
(locales: TSfContract["SfLocale"][]) => void
|
|
85
|
+
];
|
|
86
|
+
useSfCartState: () => [
|
|
87
|
+
TSfContract["SfCart"] | null | undefined,
|
|
88
|
+
(cart?: TSfContract["SfCart"] | null) => void
|
|
89
|
+
];
|
|
90
|
+
useSfCustomerState: () => [
|
|
91
|
+
TSfContract["SfCustomer"] | null | undefined,
|
|
92
|
+
(customer?: TSfContract["SfCustomer"] | null) => void
|
|
93
|
+
];
|
|
78
94
|
};
|
|
79
95
|
|
|
96
|
+
interface MiddlewareConfig {
|
|
97
|
+
/**
|
|
98
|
+
* The URL of the middleware.
|
|
99
|
+
* @example "http://localhost:4000"
|
|
100
|
+
*/
|
|
101
|
+
apiUrl: string;
|
|
102
|
+
/**
|
|
103
|
+
* The URL of the middleware for server-side rendering.
|
|
104
|
+
* @example "http://localhost:4000"
|
|
105
|
+
*/
|
|
106
|
+
ssrApiUrl?: string;
|
|
107
|
+
/**
|
|
108
|
+
* This is identifier used to invalidate the cache on CDN when the assets change.
|
|
109
|
+
* Usually it's a commit hash.
|
|
110
|
+
* @example "2c106d9619c71c3082c9b59b1d72817363c8ecb9"
|
|
111
|
+
* @default "no-cache-busting-id-set"
|
|
112
|
+
*/
|
|
113
|
+
cdnCacheBustingId?: string;
|
|
114
|
+
}
|
|
115
|
+
interface MultistoreConfig {
|
|
116
|
+
/**
|
|
117
|
+
* Whether the multistore is enabled or not.
|
|
118
|
+
* @example false
|
|
119
|
+
* @default false
|
|
120
|
+
*/
|
|
121
|
+
enabled: boolean;
|
|
122
|
+
}
|
|
123
|
+
interface CreateSdkOptions {
|
|
124
|
+
multistore?: MultistoreConfig;
|
|
125
|
+
middleware: MiddlewareConfig;
|
|
126
|
+
}
|
|
80
127
|
type GetSdkContext = {
|
|
81
128
|
/**
|
|
82
129
|
* A function that returns the request headers.
|
|
@@ -167,4 +214,4 @@ type CreateSdkContextReturn<TSdk extends SDKApi<any>, TSfContract extends SfCont
|
|
|
167
214
|
useSfCustomerState: ReturnType<typeof createSfStateProvider<TSfContract>>["useSfCustomerState"];
|
|
168
215
|
}>;
|
|
169
216
|
|
|
170
|
-
export { type
|
|
217
|
+
export { type CreateSdkOptions as C, type Maybe as M, type SfContract as S, type Config as a, type CreateSdkReturn as b, type CreateSdkContextReturn as c, type SfStateProps as d, type SfState as e, createSfStateProvider as f };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SDKApi, buildModule, middlewareModule } from '@vue-storefront/sdk';
|
|
2
|
-
import React, { ReactNode } from 'react';
|
|
2
|
+
import React, { PropsWithChildren, ReactNode } from 'react';
|
|
3
3
|
|
|
4
4
|
declare const defaultMethodsRequestConfig: {
|
|
5
5
|
readonly unifiedCommerce: {
|
|
@@ -66,17 +66,64 @@ interface SfState<TSfContract extends SfContract> extends SfStateProps<TSfContra
|
|
|
66
66
|
declare function createSfStateProvider<TSfContract extends SfContract>(): {
|
|
67
67
|
SfStateProvider: ({ children, initialData, }: {
|
|
68
68
|
initialData: SfStateProps<TSfContract>;
|
|
69
|
-
} &
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
69
|
+
} & PropsWithChildren) => React.JSX.Element;
|
|
70
|
+
useSfCurrencyState: () => [
|
|
71
|
+
TSfContract["SfCurrency"],
|
|
72
|
+
(currency: TSfContract["SfCurrency"]) => void
|
|
73
|
+
];
|
|
74
|
+
useSfCurrenciesState: () => [
|
|
75
|
+
TSfContract["SfCurrency"][],
|
|
76
|
+
(currencies: TSfContract["SfCurrency"][]) => void
|
|
77
|
+
];
|
|
78
|
+
useSfLocaleState: () => [
|
|
79
|
+
TSfContract["SfLocale"],
|
|
80
|
+
(locale: TSfContract["SfLocale"]) => void
|
|
81
|
+
];
|
|
82
|
+
useSfLocalesState: () => [
|
|
83
|
+
TSfContract["SfLocale"][],
|
|
84
|
+
(locales: TSfContract["SfLocale"][]) => void
|
|
85
|
+
];
|
|
86
|
+
useSfCartState: () => [
|
|
87
|
+
TSfContract["SfCart"] | null | undefined,
|
|
88
|
+
(cart?: TSfContract["SfCart"] | null) => void
|
|
89
|
+
];
|
|
90
|
+
useSfCustomerState: () => [
|
|
91
|
+
TSfContract["SfCustomer"] | null | undefined,
|
|
92
|
+
(customer?: TSfContract["SfCustomer"] | null) => void
|
|
93
|
+
];
|
|
78
94
|
};
|
|
79
95
|
|
|
96
|
+
interface MiddlewareConfig {
|
|
97
|
+
/**
|
|
98
|
+
* The URL of the middleware.
|
|
99
|
+
* @example "http://localhost:4000"
|
|
100
|
+
*/
|
|
101
|
+
apiUrl: string;
|
|
102
|
+
/**
|
|
103
|
+
* The URL of the middleware for server-side rendering.
|
|
104
|
+
* @example "http://localhost:4000"
|
|
105
|
+
*/
|
|
106
|
+
ssrApiUrl?: string;
|
|
107
|
+
/**
|
|
108
|
+
* This is identifier used to invalidate the cache on CDN when the assets change.
|
|
109
|
+
* Usually it's a commit hash.
|
|
110
|
+
* @example "2c106d9619c71c3082c9b59b1d72817363c8ecb9"
|
|
111
|
+
* @default "no-cache-busting-id-set"
|
|
112
|
+
*/
|
|
113
|
+
cdnCacheBustingId?: string;
|
|
114
|
+
}
|
|
115
|
+
interface MultistoreConfig {
|
|
116
|
+
/**
|
|
117
|
+
* Whether the multistore is enabled or not.
|
|
118
|
+
* @example false
|
|
119
|
+
* @default false
|
|
120
|
+
*/
|
|
121
|
+
enabled: boolean;
|
|
122
|
+
}
|
|
123
|
+
interface CreateSdkOptions {
|
|
124
|
+
multistore?: MultistoreConfig;
|
|
125
|
+
middleware: MiddlewareConfig;
|
|
126
|
+
}
|
|
80
127
|
type GetSdkContext = {
|
|
81
128
|
/**
|
|
82
129
|
* A function that returns the request headers.
|
|
@@ -167,4 +214,4 @@ type CreateSdkContextReturn<TSdk extends SDKApi<any>, TSfContract extends SfCont
|
|
|
167
214
|
useSfCustomerState: ReturnType<typeof createSfStateProvider<TSfContract>>["useSfCustomerState"];
|
|
168
215
|
}>;
|
|
169
216
|
|
|
170
|
-
export { type
|
|
217
|
+
export { type CreateSdkOptions as C, type Maybe as M, type SfContract as S, type Config as a, type CreateSdkReturn as b, type CreateSdkContextReturn as c, type SfStateProps as d, type SfState as e, createSfStateProvider as f };
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vue-storefront/next",
|
|
3
|
-
"description": "
|
|
3
|
+
"description": "Alokai dedicated features for Next.js",
|
|
4
4
|
"license": "MIT",
|
|
5
|
-
"version": "4.
|
|
5
|
+
"version": "4.3.0",
|
|
6
6
|
"exports": {
|
|
7
7
|
".": {
|
|
8
8
|
"import": "./dist/index.mjs",
|
|
@@ -15,54 +15,40 @@
|
|
|
15
15
|
"types": "./dist/client.d.ts"
|
|
16
16
|
}
|
|
17
17
|
},
|
|
18
|
-
"typesVersions": {
|
|
19
|
-
"*": {
|
|
20
|
-
"*": [
|
|
21
|
-
"dist/index.d.ts"
|
|
22
|
-
],
|
|
23
|
-
"client": [
|
|
24
|
-
"dist/client.d.ts"
|
|
25
|
-
]
|
|
26
|
-
}
|
|
27
|
-
},
|
|
28
18
|
"files": [
|
|
29
19
|
"dist"
|
|
30
20
|
],
|
|
31
21
|
"scripts": {
|
|
32
22
|
"build": "tsup",
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"dev:app-router": "cd __tests__/apps/app-router && yarn dev",
|
|
36
|
-
"dev:pages-router": "cd __tests__/apps/pages-router && yarn dev",
|
|
37
|
-
"dev:middleware": "cd ../shared/src/__tests__/middleware && yarn dev",
|
|
38
|
-
"lint": "eslint . --ext .ts",
|
|
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
|
-
"test:e2e:run": "yarn test:app-router && yarn test:pages-router",
|
|
42
|
-
"test:e2e": "cd ../shared/ && yarn test:e2e",
|
|
23
|
+
"lint": "biome ci .",
|
|
24
|
+
"format": "prettier --write .",
|
|
43
25
|
"test:unit": "vitest run"
|
|
44
26
|
},
|
|
45
27
|
"dependencies": {
|
|
46
|
-
"zustand": "^4.5.4"
|
|
28
|
+
"zustand": "^4.5.4",
|
|
29
|
+
"@vue-storefront/logger": "1.0.0"
|
|
47
30
|
},
|
|
48
31
|
"devDependencies": {
|
|
49
|
-
"@types/react": "
|
|
50
|
-
"@types/react-dom": "
|
|
51
|
-
"@vue-storefront/sdk": "
|
|
52
|
-
"react-dom": "
|
|
32
|
+
"@types/react": "18.3.2",
|
|
33
|
+
"@types/react-dom": "18.3.0",
|
|
34
|
+
"@vue-storefront/sdk": "3.3.0",
|
|
35
|
+
"react-dom": "18.3.0",
|
|
53
36
|
"start-server-and-test": "^2.0.3",
|
|
54
|
-
"tsup": "8.0
|
|
55
|
-
"vitest": "
|
|
56
|
-
"react": "
|
|
57
|
-
"next": "
|
|
37
|
+
"tsup": "8.3.0",
|
|
38
|
+
"vitest": "2.0.3",
|
|
39
|
+
"react": "18.3.1",
|
|
40
|
+
"next": "14.2.5"
|
|
58
41
|
},
|
|
59
42
|
"peerDependencies": {
|
|
60
|
-
"@vue-storefront/sdk": "
|
|
43
|
+
"@vue-storefront/sdk": "3.3.0",
|
|
61
44
|
"react": "^18.2.0",
|
|
62
45
|
"next": "^13.4.7 || ^14.0.0"
|
|
63
46
|
},
|
|
64
47
|
"engines": {
|
|
65
48
|
"npm": ">=8.0.0",
|
|
66
49
|
"node": ">=18.0.0"
|
|
50
|
+
},
|
|
51
|
+
"publishConfig": {
|
|
52
|
+
"access": "public"
|
|
67
53
|
}
|
|
68
54
|
}
|
|
File without changes
|