@vue-storefront/next 4.3.1 → 5.0.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
@@ -51,7 +51,7 @@ export const { getSdk, createSdkContext } = createSdk(
51
51
  contentful: buildModule<ContentfulModuleType>(contentfulModule, {
52
52
  apiUrl: middlewareUrl + "/cntf",
53
53
  }),
54
- }),
54
+ })
55
55
  );
56
56
  ```
57
57
 
package/dist/client.d.mts CHANGED
@@ -1,7 +1,8 @@
1
1
  import { SDKApi } from '@vue-storefront/sdk';
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';
2
+ import { S as SfContract, c as CreateSdkContextReturn } from './types-DGN1ZAgC.mjs';
3
+ export { M as Maybe, e as SfState, d as SfStateProps, f as createSfStateProvider } from './types-DGN1ZAgC.mjs';
4
4
  import 'react';
5
+ import 'next/headers';
5
6
 
6
7
  /**
7
8
  * Creates a new Alokai context which is a combination of SDK and state contexts.
package/dist/client.d.ts CHANGED
@@ -1,7 +1,8 @@
1
1
  import { SDKApi } from '@vue-storefront/sdk';
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';
2
+ import { S as SfContract, c as CreateSdkContextReturn } from './types-DGN1ZAgC.js';
3
+ export { M as Maybe, e as SfState, d as SfStateProps, f as createSfStateProvider } from './types-DGN1ZAgC.js';
4
4
  import 'react';
5
+ import 'next/headers';
5
6
 
6
7
  /**
7
8
  * Creates a new Alokai context which is a combination of SDK and state contexts.
package/dist/client.js CHANGED
@@ -177,7 +177,7 @@ function createAlokaiContext() {
177
177
  return /* @__PURE__ */ import_react2.default.createElement(SdkContext.Provider, { value: sdk }, /* @__PURE__ */ import_react2.default.createElement(import_script.default, { strategy: "beforeInteractive", id: "vsfMetaTag" }, `
178
178
  const vsfMetaTag = document.createElement("meta");
179
179
  vsfMetaTag.setAttribute("name", "generator");
180
- vsfMetaTag.setAttribute("content", "Vue Storefront 2");
180
+ vsfMetaTag.setAttribute("content", "Alokai Storefront");
181
181
  document.head.appendChild(vsfMetaTag);
182
182
  `), /* @__PURE__ */ import_react2.default.createElement(SfStateProvider, { initialData }, children));
183
183
  }
package/dist/client.mjs CHANGED
@@ -121,7 +121,7 @@ function createAlokaiContext() {
121
121
  return /* @__PURE__ */ React2.createElement(SdkContext.Provider, { value: sdk }, /* @__PURE__ */ React2.createElement(Script, { strategy: "beforeInteractive", id: "vsfMetaTag" }, `
122
122
  const vsfMetaTag = document.createElement("meta");
123
123
  vsfMetaTag.setAttribute("name", "generator");
124
- vsfMetaTag.setAttribute("content", "Vue Storefront 2");
124
+ vsfMetaTag.setAttribute("content", "Alokai Storefront");
125
125
  document.head.appendChild(vsfMetaTag);
126
126
  `), /* @__PURE__ */ React2.createElement(SfStateProvider, { initialData }, children));
127
127
  }
package/dist/index.d.mts CHANGED
@@ -1,7 +1,8 @@
1
- import { C as CreateSdkOptions, a as Config, b as CreateSdkReturn } from './types-FxigqFRO.mjs';
1
+ import { C as CreateSdkOptions, a as Config, b as CreateSdkReturn } from './types-DGN1ZAgC.mjs';
2
2
  import * as _vue_storefront_logger from '@vue-storefront/logger';
3
3
  import '@vue-storefront/sdk';
4
4
  import 'react';
5
+ import 'next/headers';
5
6
 
6
7
  /**
7
8
  * Creates an SDK for the given configuration definition.
@@ -29,7 +30,8 @@ import 'react';
29
30
  * options,
30
31
  * ({ buildModule, middlewareModule, config, getRequestHeaders }) => ({
31
32
  * unified: buildModule(middlewareModule<UnifiedApiEndpoints>, {
32
- * apiUrl: config.middlewareUrl + "/commerce",
33
+ * apiUrl: config.apiUrl + "/commerce",
34
+ * ssrApiUrl: config.ssrApiUrl + "/commerce",
33
35
  * cdnCacheBustingId: config.cdnCacheBustingId,
34
36
  * defaultRequestConfig: {
35
37
  * headers: getRequestHeaders(),
@@ -37,7 +39,8 @@ import 'react';
37
39
  * methodsRequestConfig: config.defaultMethodsRequestConfig.unifiedCommerce.middlewareModule,
38
40
  * }),
39
41
  * contentful: buildModule(contentfulModule, {
40
- * apiUrl: config.middlewareUrl + "/cntf",
42
+ * apiUrl: config.apiUrl + "/cntf",
43
+ * ssrApiUrl: config.ssrApiUrl + "/cntf",
41
44
  * }),
42
45
  * }),
43
46
  * );
@@ -53,7 +56,8 @@ declare function createSdk<TConfig extends Record<string, any>>(options: CreateS
53
56
  * const config = defineSdkConfig(
54
57
  * ({ buildModule, middlewareModule, config, getRequestHeaders }) => ({
55
58
  * unified: buildModule(middlewareModule<UnifiedApiEndpoints>, {
56
- * apiUrl: config.middlewareUrl + "/commerce",
59
+ * apiUrl: config.apiUrl + "/commerce",
60
+ * ssrApiUrl: config.ssrApiUrl + "/commerce",
57
61
  * cdnCacheBustingId: config.cdnCacheBustingId,
58
62
  * defaultRequestConfig: {
59
63
  * headers: getRequestHeaders(),
@@ -61,7 +65,8 @@ declare function createSdk<TConfig extends Record<string, any>>(options: CreateS
61
65
  * methodsRequestConfig: config.defaultMethodsRequestConfig.unifiedCommerce.middlewareModule,
62
66
  * }),
63
67
  * contentful: buildModule(contentfulModule, {
64
- * apiUrl: config.middlewareUrl + "/cntf",
68
+ * apiUrl: config.apiUrl + "/cntf",
69
+ * ssrApiUrl: config.ssrApiUrl + "/cntf",
65
70
  * }),
66
71
  * })
67
72
  * );
@@ -72,11 +77,17 @@ type ResolveSdkOptionsConfig = {
72
77
  };
73
78
  /**
74
79
  * Helper function to resolve the SDK options based on the configuration.
80
+ *
81
+ * @privateRemarks
82
+ * For now this file only verifies the type of the input and simply returns it.
83
+ * However, in the future we might need it to perform true input resolution.
84
+ *
75
85
  * @param input - The options for creating the SDK.
76
86
  * @param options - The configuration object, that allows to customize the API Url creation on enabled multistore.
87
+ *
77
88
  * @returns The resolved SDK options.
78
89
  */
79
- declare function resolveSdkOptions(input: CreateSdkOptions, options?: Partial<ResolveSdkOptionsConfig>): CreateSdkOptions;
90
+ declare function resolveSdkOptions(input: CreateSdkOptions, _options?: Partial<ResolveSdkOptionsConfig>): CreateSdkOptions;
80
91
 
81
92
  type LogVerbosity = "emergency" | "alert" | "critical" | "error" | "warning" | "notice" | "info" | "debug";
82
93
  type LoggerOptions = Partial<{
package/dist/index.d.ts CHANGED
@@ -1,7 +1,8 @@
1
- import { C as CreateSdkOptions, a as Config, b as CreateSdkReturn } from './types-FxigqFRO.js';
1
+ import { C as CreateSdkOptions, a as Config, b as CreateSdkReturn } from './types-DGN1ZAgC.js';
2
2
  import * as _vue_storefront_logger from '@vue-storefront/logger';
3
3
  import '@vue-storefront/sdk';
4
4
  import 'react';
5
+ import 'next/headers';
5
6
 
6
7
  /**
7
8
  * Creates an SDK for the given configuration definition.
@@ -29,7 +30,8 @@ import 'react';
29
30
  * options,
30
31
  * ({ buildModule, middlewareModule, config, getRequestHeaders }) => ({
31
32
  * unified: buildModule(middlewareModule<UnifiedApiEndpoints>, {
32
- * apiUrl: config.middlewareUrl + "/commerce",
33
+ * apiUrl: config.apiUrl + "/commerce",
34
+ * ssrApiUrl: config.ssrApiUrl + "/commerce",
33
35
  * cdnCacheBustingId: config.cdnCacheBustingId,
34
36
  * defaultRequestConfig: {
35
37
  * headers: getRequestHeaders(),
@@ -37,7 +39,8 @@ import 'react';
37
39
  * methodsRequestConfig: config.defaultMethodsRequestConfig.unifiedCommerce.middlewareModule,
38
40
  * }),
39
41
  * contentful: buildModule(contentfulModule, {
40
- * apiUrl: config.middlewareUrl + "/cntf",
42
+ * apiUrl: config.apiUrl + "/cntf",
43
+ * ssrApiUrl: config.ssrApiUrl + "/cntf",
41
44
  * }),
42
45
  * }),
43
46
  * );
@@ -53,7 +56,8 @@ declare function createSdk<TConfig extends Record<string, any>>(options: CreateS
53
56
  * const config = defineSdkConfig(
54
57
  * ({ buildModule, middlewareModule, config, getRequestHeaders }) => ({
55
58
  * unified: buildModule(middlewareModule<UnifiedApiEndpoints>, {
56
- * apiUrl: config.middlewareUrl + "/commerce",
59
+ * apiUrl: config.apiUrl + "/commerce",
60
+ * ssrApiUrl: config.ssrApiUrl + "/commerce",
57
61
  * cdnCacheBustingId: config.cdnCacheBustingId,
58
62
  * defaultRequestConfig: {
59
63
  * headers: getRequestHeaders(),
@@ -61,7 +65,8 @@ declare function createSdk<TConfig extends Record<string, any>>(options: CreateS
61
65
  * methodsRequestConfig: config.defaultMethodsRequestConfig.unifiedCommerce.middlewareModule,
62
66
  * }),
63
67
  * contentful: buildModule(contentfulModule, {
64
- * apiUrl: config.middlewareUrl + "/cntf",
68
+ * apiUrl: config.apiUrl + "/cntf",
69
+ * ssrApiUrl: config.ssrApiUrl + "/cntf",
65
70
  * }),
66
71
  * })
67
72
  * );
@@ -72,11 +77,17 @@ type ResolveSdkOptionsConfig = {
72
77
  };
73
78
  /**
74
79
  * Helper function to resolve the SDK options based on the configuration.
80
+ *
81
+ * @privateRemarks
82
+ * For now this file only verifies the type of the input and simply returns it.
83
+ * However, in the future we might need it to perform true input resolution.
84
+ *
75
85
  * @param input - The options for creating the SDK.
76
86
  * @param options - The configuration object, that allows to customize the API Url creation on enabled multistore.
87
+ *
77
88
  * @returns The resolved SDK options.
78
89
  */
79
- declare function resolveSdkOptions(input: CreateSdkOptions, options?: Partial<ResolveSdkOptionsConfig>): CreateSdkOptions;
90
+ declare function resolveSdkOptions(input: CreateSdkOptions, _options?: Partial<ResolveSdkOptionsConfig>): CreateSdkOptions;
80
91
 
81
92
  type LogVerbosity = "emergency" | "alert" | "critical" | "error" | "warning" | "notice" | "info" | "debug";
82
93
  type LoggerOptions = Partial<{
package/dist/index.js CHANGED
@@ -47,16 +47,31 @@ module.exports = __toCommonJS(src_exports);
47
47
  // src/sdk/helpers/resolveDynamicContext.ts
48
48
  var BLACKLISTED_HEADERS = /* @__PURE__ */ new Set(["host"]);
49
49
  function isAppRouterHeaders(headers) {
50
- return headers && "entries" in headers;
50
+ return !!headers && "entries" in headers;
51
+ }
52
+ function isFlatNextHeaders(headers) {
53
+ return !!headers && !("headers" in headers);
54
+ }
55
+ function normalizeRequestHeaders(requestHeaders) {
56
+ const { headers = {}, cookies } = isFlatNextHeaders(requestHeaders) ? { headers: requestHeaders, cookies: void 0 } : {
57
+ headers: requestHeaders == null ? void 0 : requestHeaders.headers,
58
+ cookies: requestHeaders == null ? void 0 : requestHeaders.cookies
59
+ };
60
+ const normalizedHeaders = isAppRouterHeaders(headers) ? Object.fromEntries(headers.entries()) : headers;
61
+ if (cookies) {
62
+ normalizedHeaders.cookie = cookies.toString();
63
+ }
64
+ return normalizedHeaders;
51
65
  }
52
66
  function resolveDynamicContext(context) {
53
67
  return __spreadProps(__spreadValues({}, context), {
54
68
  getRequestHeaders() {
55
69
  var _a;
56
- const headers = ((_a = context.getRequestHeaders) == null ? void 0 : _a.call(context)) || {};
57
- const resolvedHeaders = isAppRouterHeaders(headers) ? Object.fromEntries(headers.entries()) : headers;
70
+ const normalizedHeaders = normalizeRequestHeaders(
71
+ (_a = context.getRequestHeaders) == null ? void 0 : _a.call(context)
72
+ );
58
73
  return Object.fromEntries(
59
- Object.entries(resolvedHeaders).filter(
74
+ Object.entries(normalizedHeaders).filter(
60
75
  ([key]) => !BLACKLISTED_HEADERS.has(key)
61
76
  )
62
77
  );
@@ -85,62 +100,20 @@ var defaultMethodsRequestConfig = {
85
100
  }
86
101
  };
87
102
 
88
- // src/sdk/helpers/composeMiddlewareUrl.ts
89
- function calculateMiddlewareUrl({
90
- options,
91
- headers
92
- }) {
93
- var _a, _b, _c;
94
- const { apiUrl, ssrApiUrl } = options.middleware;
95
- if (typeof window !== "undefined") {
96
- if ((_a = options.multistore) == null ? void 0 : _a.enabled) {
97
- const url2 = new URL(apiUrl);
98
- url2.host = window.location.host;
99
- return url2.href;
100
- }
101
- return apiUrl;
102
- }
103
- if (ssrApiUrl) {
104
- return ssrApiUrl;
105
- }
106
- if (!((_b = options.multistore) == null ? void 0 : _b.enabled)) {
107
- return apiUrl;
108
- }
109
- const forwardedHost = (_c = headers["x-forwarded-host"]) != null ? _c : headers.host;
110
- const resolvedForwardedHost = forwardedHost && Array.isArray(forwardedHost) ? forwardedHost[0] : forwardedHost;
111
- const url = new URL(apiUrl);
112
- url.host = resolvedForwardedHost || new URL(apiUrl).host;
113
- return url.href;
114
- }
115
- function removeTrailingSlash(url) {
116
- return url.replace(/\/$/, "");
117
- }
118
- function composeMiddlewareUrl({
119
- options,
120
- headers
121
- }) {
122
- const url = calculateMiddlewareUrl({ options, headers });
123
- return removeTrailingSlash(url);
124
- }
125
-
126
103
  // src/sdk/index.tsx
127
104
  var import_sdk = require("@vue-storefront/sdk");
128
105
  function createSdk(options, configDefinition) {
129
106
  function getSdk(dynamicContext = {}) {
130
107
  var _a;
131
108
  const { getRequestHeaders } = resolveDynamicContext(dynamicContext);
132
- const middlewareUrl = composeMiddlewareUrl({
133
- options,
134
- headers: getRequestHeaders()
135
- });
136
109
  const resolvedConfig = configDefinition({
137
110
  defaults: defaultMethodsRequestConfig,
138
111
  buildModule: import_sdk.buildModule,
139
112
  middlewareModule: import_sdk.middlewareModule,
140
113
  getRequestHeaders,
141
- middlewareUrl,
142
114
  config: {
143
- middlewareUrl,
115
+ apiUrl: options.middleware.apiUrl,
116
+ ssrApiUrl: options.middleware.ssrApiUrl,
144
117
  defaultMethodsRequestConfig,
145
118
  cdnCacheBustingId: (_a = options.middleware.cdnCacheBustingId) != null ? _a : "no-cache-busting-id-set"
146
119
  }
@@ -154,22 +127,7 @@ function createSdk(options, configDefinition) {
154
127
  function defineSdkConfig(config) {
155
128
  return config;
156
129
  }
157
- function resolveSdkOptions(input, options = {}) {
158
- var _a, _b, _c, _d, _e;
159
- if ((_a = input == null ? void 0 : input.multistore) == null ? void 0 : _a.enabled) {
160
- return {
161
- middleware: {
162
- // This is a dummy URL, the localhost domain will be replaced by the actual domain in the browser
163
- // in composeMiddlewareUrl function. The server-side rendering will use ssrApiUrl.
164
- apiUrl: `https://localhost/${(_b = options == null ? void 0 : options.customSuffix) != null ? _b : "api"}`,
165
- cdnCacheBustingId: (_c = input.middleware) == null ? void 0 : _c.cdnCacheBustingId,
166
- ssrApiUrl: (_e = (_d = input.middleware) == null ? void 0 : _d.ssrApiUrl) != null ? _e : input.middleware.apiUrl
167
- },
168
- multistore: {
169
- enabled: true
170
- }
171
- };
172
- }
130
+ function resolveSdkOptions(input, _options = {}) {
173
131
  return input;
174
132
  }
175
133
 
package/dist/index.mjs CHANGED
@@ -6,16 +6,31 @@ import {
6
6
  // src/sdk/helpers/resolveDynamicContext.ts
7
7
  var BLACKLISTED_HEADERS = /* @__PURE__ */ new Set(["host"]);
8
8
  function isAppRouterHeaders(headers) {
9
- return headers && "entries" in headers;
9
+ return !!headers && "entries" in headers;
10
+ }
11
+ function isFlatNextHeaders(headers) {
12
+ return !!headers && !("headers" in headers);
13
+ }
14
+ function normalizeRequestHeaders(requestHeaders) {
15
+ const { headers = {}, cookies } = isFlatNextHeaders(requestHeaders) ? { headers: requestHeaders, cookies: void 0 } : {
16
+ headers: requestHeaders == null ? void 0 : requestHeaders.headers,
17
+ cookies: requestHeaders == null ? void 0 : requestHeaders.cookies
18
+ };
19
+ const normalizedHeaders = isAppRouterHeaders(headers) ? Object.fromEntries(headers.entries()) : headers;
20
+ if (cookies) {
21
+ normalizedHeaders.cookie = cookies.toString();
22
+ }
23
+ return normalizedHeaders;
10
24
  }
11
25
  function resolveDynamicContext(context) {
12
26
  return __spreadProps(__spreadValues({}, context), {
13
27
  getRequestHeaders() {
14
28
  var _a;
15
- const headers = ((_a = context.getRequestHeaders) == null ? void 0 : _a.call(context)) || {};
16
- const resolvedHeaders = isAppRouterHeaders(headers) ? Object.fromEntries(headers.entries()) : headers;
29
+ const normalizedHeaders = normalizeRequestHeaders(
30
+ (_a = context.getRequestHeaders) == null ? void 0 : _a.call(context)
31
+ );
17
32
  return Object.fromEntries(
18
- Object.entries(resolvedHeaders).filter(
33
+ Object.entries(normalizedHeaders).filter(
19
34
  ([key]) => !BLACKLISTED_HEADERS.has(key)
20
35
  )
21
36
  );
@@ -44,62 +59,20 @@ var defaultMethodsRequestConfig = {
44
59
  }
45
60
  };
46
61
 
47
- // src/sdk/helpers/composeMiddlewareUrl.ts
48
- function calculateMiddlewareUrl({
49
- options,
50
- headers
51
- }) {
52
- var _a, _b, _c;
53
- const { apiUrl, ssrApiUrl } = options.middleware;
54
- if (typeof window !== "undefined") {
55
- if ((_a = options.multistore) == null ? void 0 : _a.enabled) {
56
- const url2 = new URL(apiUrl);
57
- url2.host = window.location.host;
58
- return url2.href;
59
- }
60
- return apiUrl;
61
- }
62
- if (ssrApiUrl) {
63
- return ssrApiUrl;
64
- }
65
- if (!((_b = options.multistore) == null ? void 0 : _b.enabled)) {
66
- return apiUrl;
67
- }
68
- const forwardedHost = (_c = headers["x-forwarded-host"]) != null ? _c : headers.host;
69
- const resolvedForwardedHost = forwardedHost && Array.isArray(forwardedHost) ? forwardedHost[0] : forwardedHost;
70
- const url = new URL(apiUrl);
71
- url.host = resolvedForwardedHost || new URL(apiUrl).host;
72
- return url.href;
73
- }
74
- function removeTrailingSlash(url) {
75
- return url.replace(/\/$/, "");
76
- }
77
- function composeMiddlewareUrl({
78
- options,
79
- headers
80
- }) {
81
- const url = calculateMiddlewareUrl({ options, headers });
82
- return removeTrailingSlash(url);
83
- }
84
-
85
62
  // src/sdk/index.tsx
86
63
  import { buildModule, initSDK, middlewareModule } from "@vue-storefront/sdk";
87
64
  function createSdk(options, configDefinition) {
88
65
  function getSdk(dynamicContext = {}) {
89
66
  var _a;
90
67
  const { getRequestHeaders } = resolveDynamicContext(dynamicContext);
91
- const middlewareUrl = composeMiddlewareUrl({
92
- options,
93
- headers: getRequestHeaders()
94
- });
95
68
  const resolvedConfig = configDefinition({
96
69
  defaults: defaultMethodsRequestConfig,
97
70
  buildModule,
98
71
  middlewareModule,
99
72
  getRequestHeaders,
100
- middlewareUrl,
101
73
  config: {
102
- middlewareUrl,
74
+ apiUrl: options.middleware.apiUrl,
75
+ ssrApiUrl: options.middleware.ssrApiUrl,
103
76
  defaultMethodsRequestConfig,
104
77
  cdnCacheBustingId: (_a = options.middleware.cdnCacheBustingId) != null ? _a : "no-cache-busting-id-set"
105
78
  }
@@ -113,22 +86,7 @@ function createSdk(options, configDefinition) {
113
86
  function defineSdkConfig(config) {
114
87
  return config;
115
88
  }
116
- function resolveSdkOptions(input, options = {}) {
117
- var _a, _b, _c, _d, _e;
118
- if ((_a = input == null ? void 0 : input.multistore) == null ? void 0 : _a.enabled) {
119
- return {
120
- middleware: {
121
- // This is a dummy URL, the localhost domain will be replaced by the actual domain in the browser
122
- // in composeMiddlewareUrl function. The server-side rendering will use ssrApiUrl.
123
- apiUrl: `https://localhost/${(_b = options == null ? void 0 : options.customSuffix) != null ? _b : "api"}`,
124
- cdnCacheBustingId: (_c = input.middleware) == null ? void 0 : _c.cdnCacheBustingId,
125
- ssrApiUrl: (_e = (_d = input.middleware) == null ? void 0 : _d.ssrApiUrl) != null ? _e : input.middleware.apiUrl
126
- },
127
- multistore: {
128
- enabled: true
129
- }
130
- };
131
- }
89
+ function resolveSdkOptions(input, _options = {}) {
132
90
  return input;
133
91
  }
134
92
 
@@ -1,5 +1,6 @@
1
1
  import { SDKApi, buildModule, middlewareModule } from '@vue-storefront/sdk';
2
2
  import React, { PropsWithChildren, ReactNode } from 'react';
3
+ import { cookies } from 'next/headers';
3
4
 
4
5
  declare const defaultMethodsRequestConfig: {
5
6
  readonly unifiedCommerce: {
@@ -103,7 +104,7 @@ interface MiddlewareConfig {
103
104
  * The URL of the middleware for server-side rendering.
104
105
  * @example "http://localhost:4000"
105
106
  */
106
- ssrApiUrl?: string;
107
+ ssrApiUrl: string;
107
108
  /**
108
109
  * This is identifier used to invalidate the cache on CDN when the assets change.
109
110
  * Usually it's a commit hash.
@@ -124,11 +125,16 @@ interface CreateSdkOptions {
124
125
  multistore?: MultistoreConfig;
125
126
  middleware: MiddlewareConfig;
126
127
  }
128
+ type Cookies = ReturnType<typeof cookies>;
129
+ type NextHeaders = Record<string, string | string[] | undefined> | Headers;
127
130
  type GetSdkContext = {
128
131
  /**
129
132
  * A function that returns the request headers.
130
133
  */
131
- getRequestHeaders?: () => Record<string, string | string[] | undefined> | Headers;
134
+ getRequestHeaders?: () => NextHeaders | {
135
+ headers: NextHeaders;
136
+ cookies: Cookies;
137
+ };
132
138
  };
133
139
  type DynamicContext = {
134
140
  getRequestHeaders: () => Record<string, string | string[]>;
@@ -136,16 +142,13 @@ type DynamicContext = {
136
142
  type StaticContext = {
137
143
  buildModule: typeof buildModule;
138
144
  middlewareModule: typeof middlewareModule;
139
- /**
140
- * @deprecated Use `config.middlewareUrl` instead.
141
- */
142
- middlewareUrl: string;
143
145
  /**
144
146
  * @deprecated Use `config.defaultMethodsRequestConfig` instead.
145
147
  */
146
148
  defaults: typeof defaultMethodsRequestConfig;
147
149
  config: {
148
- middlewareUrl: string;
150
+ apiUrl: string;
151
+ ssrApiUrl: string;
149
152
  defaultMethodsRequestConfig: typeof defaultMethodsRequestConfig;
150
153
  cdnCacheBustingId: string;
151
154
  };
@@ -1,5 +1,6 @@
1
1
  import { SDKApi, buildModule, middlewareModule } from '@vue-storefront/sdk';
2
2
  import React, { PropsWithChildren, ReactNode } from 'react';
3
+ import { cookies } from 'next/headers';
3
4
 
4
5
  declare const defaultMethodsRequestConfig: {
5
6
  readonly unifiedCommerce: {
@@ -103,7 +104,7 @@ interface MiddlewareConfig {
103
104
  * The URL of the middleware for server-side rendering.
104
105
  * @example "http://localhost:4000"
105
106
  */
106
- ssrApiUrl?: string;
107
+ ssrApiUrl: string;
107
108
  /**
108
109
  * This is identifier used to invalidate the cache on CDN when the assets change.
109
110
  * Usually it's a commit hash.
@@ -124,11 +125,16 @@ interface CreateSdkOptions {
124
125
  multistore?: MultistoreConfig;
125
126
  middleware: MiddlewareConfig;
126
127
  }
128
+ type Cookies = ReturnType<typeof cookies>;
129
+ type NextHeaders = Record<string, string | string[] | undefined> | Headers;
127
130
  type GetSdkContext = {
128
131
  /**
129
132
  * A function that returns the request headers.
130
133
  */
131
- getRequestHeaders?: () => Record<string, string | string[] | undefined> | Headers;
134
+ getRequestHeaders?: () => NextHeaders | {
135
+ headers: NextHeaders;
136
+ cookies: Cookies;
137
+ };
132
138
  };
133
139
  type DynamicContext = {
134
140
  getRequestHeaders: () => Record<string, string | string[]>;
@@ -136,16 +142,13 @@ type DynamicContext = {
136
142
  type StaticContext = {
137
143
  buildModule: typeof buildModule;
138
144
  middlewareModule: typeof middlewareModule;
139
- /**
140
- * @deprecated Use `config.middlewareUrl` instead.
141
- */
142
- middlewareUrl: string;
143
145
  /**
144
146
  * @deprecated Use `config.defaultMethodsRequestConfig` instead.
145
147
  */
146
148
  defaults: typeof defaultMethodsRequestConfig;
147
149
  config: {
148
- middlewareUrl: string;
150
+ apiUrl: string;
151
+ ssrApiUrl: string;
149
152
  defaultMethodsRequestConfig: typeof defaultMethodsRequestConfig;
150
153
  cdnCacheBustingId: string;
151
154
  };
package/package.json CHANGED
@@ -2,17 +2,17 @@
2
2
  "name": "@vue-storefront/next",
3
3
  "description": "Alokai dedicated features for Next.js",
4
4
  "license": "MIT",
5
- "version": "4.3.1",
5
+ "version": "5.0.0",
6
6
  "exports": {
7
7
  ".": {
8
+ "types": "./dist/index.d.ts",
8
9
  "import": "./dist/index.mjs",
9
- "require": "./dist/index.js",
10
- "types": "./dist/index.d.ts"
10
+ "require": "./dist/index.js"
11
11
  },
12
12
  "./client": {
13
+ "types": "./dist/client.d.ts",
13
14
  "import": "./dist/client.js",
14
- "require": "./dist/client.js",
15
- "types": "./dist/client.d.ts"
15
+ "require": "./dist/client.js"
16
16
  }
17
17
  },
18
18
  "files": [
@@ -32,16 +32,16 @@
32
32
  "devDependencies": {
33
33
  "@types/react": "18.3.2",
34
34
  "@types/react-dom": "18.3.0",
35
- "@vue-storefront/sdk": "3.3.0",
36
- "react-dom": "18.3.0",
35
+ "@vue-storefront/sdk": "3.4.1",
36
+ "react-dom": "18.3.1",
37
37
  "start-server-and-test": "^2.0.3",
38
38
  "tsup": "8.3.0",
39
39
  "vitest": "2.1.5",
40
40
  "react": "18.3.1",
41
- "next": "14.2.5"
41
+ "next": "14.2.23"
42
42
  },
43
43
  "peerDependencies": {
44
- "@vue-storefront/sdk": "3.3.0",
44
+ "@vue-storefront/sdk": "3.4.1",
45
45
  "react": "^18.2.0",
46
46
  "next": "^13.4.7 || ^14.0.0"
47
47
  },