@vue-storefront/next 4.1.1 → 4.3.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/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, b as CreateSdkContextReturn } from './types-TuCCvExK.mjs';
3
- export { M as Maybe, d as SfState, c as SfStateProps, e as createSfStateProvider } from './types-TuCCvExK.mjs';
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, b as CreateSdkContextReturn } from './types-TuCCvExK.js';
3
- export { M as Maybe, d as SfState, c as SfStateProps, e as createSfStateProvider } from './types-TuCCvExK.js';
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
@@ -1,3 +1,4 @@
1
+ "use strict";
1
2
  "use client";
2
3
  var __create = Object.create;
3
4
  var __defProp = Object.defineProperty;
package/dist/client.mjs CHANGED
@@ -3,7 +3,7 @@ import {
3
3
  __objRest,
4
4
  __spreadProps,
5
5
  __spreadValues
6
- } from "./chunk-FUJQIYOF.mjs";
6
+ } from "./chunk-FWCSY2DS.mjs";
7
7
 
8
8
  // src/alokai-provider.tsx
9
9
  import Script from "next/script";
package/dist/index.d.mts CHANGED
@@ -1,39 +1,8 @@
1
- import { C as Config, a as CreateSdkReturn } from './types-TuCCvExK.mjs';
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
- export { type CreateSdkOptions, createSdk, defineSdkConfig, resolveSdkOptions };
81
+ type LogLevel = "emergency" | "alert" | "critical" | "error" | "warning" | "notice" | "info" | "debug";
82
+ type LoggerOptions = Partial<{
83
+ level: LogLevel;
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 Config, a as CreateSdkReturn } from './types-TuCCvExK.js';
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
- export { type CreateSdkOptions, createSdk, defineSdkConfig, resolveSdkOptions };
81
+ type LogLevel = "emergency" | "alert" | "critical" | "error" | "warning" | "notice" | "info" | "debug";
82
+ type LoggerOptions = Partial<{
83
+ level: LogLevel;
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
- // ../shared/src/helpers/composeMiddlewareUrl.ts
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,49 +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
- getCategories: { method: "GET" },
88
- getProductDetails: { method: "GET" },
89
- getProductReviews: { method: "GET" },
90
- getProducts: { method: "GET" },
91
- getCurrencies: { method: "GET" },
92
- searchProducts: { method: "GET" }
93
- }
94
- },
95
- unifiedCms: {
96
- middlewareModule: {
97
- getEntries: { method: "GET" }
98
- }
99
- }
100
- };
101
-
102
126
  // src/sdk/index.tsx
103
127
  var import_sdk = require("@vue-storefront/sdk");
104
-
105
- // src/sdk/helpers/resolveDynamicContext.ts
106
- var BLACKLISTED_HEADERS = /* @__PURE__ */ new Set(["host"]);
107
- function isAppRouterHeaders(headers) {
108
- return headers && "entries" in headers;
109
- }
110
- function resolveDynamicContext(context) {
111
- return __spreadProps(__spreadValues({}, context), {
112
- getRequestHeaders() {
113
- var _a;
114
- const headers = ((_a = context.getRequestHeaders) == null ? void 0 : _a.call(context)) || {};
115
- const resolvedHeaders = isAppRouterHeaders(headers) ? Object.fromEntries(headers.entries()) : headers;
116
- return Object.fromEntries(
117
- Object.entries(resolvedHeaders).filter(
118
- ([key]) => !BLACKLISTED_HEADERS.has(key)
119
- )
120
- );
121
- }
122
- });
123
- }
124
-
125
- // src/sdk/index.tsx
126
128
  function createSdk(options, configDefinition) {
127
129
  function getSdk(dynamicContext = {}) {
128
130
  var _a;
@@ -170,8 +172,38 @@ function resolveSdkOptions(input, options = {}) {
170
172
  }
171
173
  return input;
172
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
+ };
173
204
  // Annotate the CommonJS export names for ESM import in node:
174
205
  0 && (module.exports = {
206
+ createLogger,
175
207
  createSdk,
176
208
  defineSdkConfig,
177
209
  resolveSdkOptions
package/dist/index.mjs CHANGED
@@ -1,9 +1,50 @@
1
1
  import {
2
2
  __spreadProps,
3
3
  __spreadValues
4
- } from "./chunk-FUJQIYOF.mjs";
4
+ } from "./chunk-FWCSY2DS.mjs";
5
5
 
6
- // ../shared/src/helpers/composeMiddlewareUrl.ts
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,49 +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
- getCategories: { method: "GET" },
49
- getProductDetails: { method: "GET" },
50
- getProductReviews: { method: "GET" },
51
- getProducts: { method: "GET" },
52
- getCurrencies: { method: "GET" },
53
- searchProducts: { method: "GET" }
54
- }
55
- },
56
- unifiedCms: {
57
- middlewareModule: {
58
- getEntries: { method: "GET" }
59
- }
60
- }
61
- };
62
-
63
85
  // src/sdk/index.tsx
64
86
  import { buildModule, initSDK, middlewareModule } from "@vue-storefront/sdk";
65
-
66
- // src/sdk/helpers/resolveDynamicContext.ts
67
- var BLACKLISTED_HEADERS = /* @__PURE__ */ new Set(["host"]);
68
- function isAppRouterHeaders(headers) {
69
- return headers && "entries" in headers;
70
- }
71
- function resolveDynamicContext(context) {
72
- return __spreadProps(__spreadValues({}, context), {
73
- getRequestHeaders() {
74
- var _a;
75
- const headers = ((_a = context.getRequestHeaders) == null ? void 0 : _a.call(context)) || {};
76
- const resolvedHeaders = isAppRouterHeaders(headers) ? Object.fromEntries(headers.entries()) : headers;
77
- return Object.fromEntries(
78
- Object.entries(resolvedHeaders).filter(
79
- ([key]) => !BLACKLISTED_HEADERS.has(key)
80
- )
81
- );
82
- }
83
- });
84
- }
85
-
86
- // src/sdk/index.tsx
87
87
  function createSdk(options, configDefinition) {
88
88
  function getSdk(dynamicContext = {}) {
89
89
  var _a;
@@ -131,7 +131,37 @@ function resolveSdkOptions(input, options = {}) {
131
131
  }
132
132
  return input;
133
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
+ };
134
163
  export {
164
+ createLogger,
135
165
  createSdk,
136
166
  defineSdkConfig,
137
167
  resolveSdkOptions
@@ -1,9 +1,12 @@
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: {
6
6
  readonly middlewareModule: {
7
+ readonly getCategory: {
8
+ readonly method: "GET";
9
+ };
7
10
  readonly getCategories: {
8
11
  readonly method: "GET";
9
12
  };
@@ -26,6 +29,9 @@ declare const defaultMethodsRequestConfig: {
26
29
  };
27
30
  readonly unifiedCms: {
28
31
  readonly middlewareModule: {
32
+ readonly getPage: {
33
+ readonly method: "GET";
34
+ };
29
35
  readonly getEntries: {
30
36
  readonly method: "GET";
31
37
  };
@@ -60,17 +66,64 @@ interface SfState<TSfContract extends SfContract> extends SfStateProps<TSfContra
60
66
  declare function createSfStateProvider<TSfContract extends SfContract>(): {
61
67
  SfStateProvider: ({ children, initialData, }: {
62
68
  initialData: SfStateProps<TSfContract>;
63
- } & {
64
- children?: React.ReactNode;
65
- }) => React.JSX.Element;
66
- useSfCurrencyState: () => [TSfContract["SfCurrency"], (currency: TSfContract["SfCurrency"]) => void];
67
- useSfCurrenciesState: () => [TSfContract["SfCurrency"][], (currencies: TSfContract["SfCurrency"][]) => void];
68
- useSfLocaleState: () => [TSfContract["SfLocale"], (locale: TSfContract["SfLocale"]) => void];
69
- useSfLocalesState: () => [TSfContract["SfLocale"][], (locales: TSfContract["SfLocale"][]) => void];
70
- useSfCartState: () => [TSfContract["SfCart"], (cart?: TSfContract["SfCart"] | null) => void];
71
- useSfCustomerState: () => [TSfContract["SfCustomer"], (customer?: TSfContract["SfCustomer"] | null) => void];
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
+ ];
72
94
  };
73
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
+ }
74
127
  type GetSdkContext = {
75
128
  /**
76
129
  * A function that returns the request headers.
@@ -161,4 +214,4 @@ type CreateSdkContextReturn<TSdk extends SDKApi<any>, TSfContract extends SfCont
161
214
  useSfCustomerState: ReturnType<typeof createSfStateProvider<TSfContract>>["useSfCustomerState"];
162
215
  }>;
163
216
 
164
- export { type Config as C, type Maybe as M, type SfContract as S, type CreateSdkReturn as a, type CreateSdkContextReturn as b, type SfStateProps as c, type SfState as d, createSfStateProvider as e };
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,9 +1,12 @@
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: {
6
6
  readonly middlewareModule: {
7
+ readonly getCategory: {
8
+ readonly method: "GET";
9
+ };
7
10
  readonly getCategories: {
8
11
  readonly method: "GET";
9
12
  };
@@ -26,6 +29,9 @@ declare const defaultMethodsRequestConfig: {
26
29
  };
27
30
  readonly unifiedCms: {
28
31
  readonly middlewareModule: {
32
+ readonly getPage: {
33
+ readonly method: "GET";
34
+ };
29
35
  readonly getEntries: {
30
36
  readonly method: "GET";
31
37
  };
@@ -60,17 +66,64 @@ interface SfState<TSfContract extends SfContract> extends SfStateProps<TSfContra
60
66
  declare function createSfStateProvider<TSfContract extends SfContract>(): {
61
67
  SfStateProvider: ({ children, initialData, }: {
62
68
  initialData: SfStateProps<TSfContract>;
63
- } & {
64
- children?: React.ReactNode;
65
- }) => React.JSX.Element;
66
- useSfCurrencyState: () => [TSfContract["SfCurrency"], (currency: TSfContract["SfCurrency"]) => void];
67
- useSfCurrenciesState: () => [TSfContract["SfCurrency"][], (currencies: TSfContract["SfCurrency"][]) => void];
68
- useSfLocaleState: () => [TSfContract["SfLocale"], (locale: TSfContract["SfLocale"]) => void];
69
- useSfLocalesState: () => [TSfContract["SfLocale"][], (locales: TSfContract["SfLocale"][]) => void];
70
- useSfCartState: () => [TSfContract["SfCart"], (cart?: TSfContract["SfCart"] | null) => void];
71
- useSfCustomerState: () => [TSfContract["SfCustomer"], (customer?: TSfContract["SfCustomer"] | null) => void];
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
+ ];
72
94
  };
73
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
+ }
74
127
  type GetSdkContext = {
75
128
  /**
76
129
  * A function that returns the request headers.
@@ -161,4 +214,4 @@ type CreateSdkContextReturn<TSdk extends SDKApi<any>, TSfContract extends SfCont
161
214
  useSfCustomerState: ReturnType<typeof createSfStateProvider<TSfContract>>["useSfCustomerState"];
162
215
  }>;
163
216
 
164
- export { type Config as C, type Maybe as M, type SfContract as S, type CreateSdkReturn as a, type CreateSdkContextReturn as b, type SfStateProps as c, type SfState as d, createSfStateProvider as e };
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": "Vue Storefront dedicated features for Next.js",
3
+ "description": "Alokai dedicated features for Next.js",
4
4
  "license": "MIT",
5
- "version": "4.1.1",
5
+ "version": "4.3.0-rc.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
- "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
- "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-rc.4"
47
30
  },
48
31
  "devDependencies": {
49
- "@types/react": "^18.2.31",
50
- "@types/react-dom": "^18.2.14",
51
- "@vue-storefront/sdk": "^3.1.0",
52
- "react-dom": "^18.2.0",
32
+ "@types/react": "18.3.2",
33
+ "@types/react-dom": "18.3.0",
34
+ "@vue-storefront/sdk": "3.3.0-rc.3",
35
+ "react-dom": "18.3.0",
53
36
  "start-server-and-test": "^2.0.3",
54
- "tsup": "8.0.1",
55
- "vitest": "^0.34.6",
56
- "react": "^18.2.0",
57
- "next": "^13.4.7 || ^14.0.0"
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": "^3.1.0",
43
+ "@vue-storefront/sdk": "3.3.0-rc.3",
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