@vue-storefront/next 4.3.2 → 5.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/client.d.mts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { SDKApi } from '@vue-storefront/sdk';
2
- import { S as SfContract, c as CreateSdkContextReturn } from './types-BdDsK6en.mjs';
3
- export { M as Maybe, e as SfState, d as SfStateProps, f as createSfStateProvider } from './types-BdDsK6en.mjs';
2
+ import { S as SfContract, c as CreateSdkContextReturn } from './types-Dw2Ev7Da.mjs';
3
+ export { M as Maybe, e as SfState, d as SfStateProps, f as createSfStateProvider } from './types-Dw2Ev7Da.mjs';
4
4
  import 'react';
5
5
  import 'next/headers';
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, c as CreateSdkContextReturn } from './types-BdDsK6en.js';
3
- export { M as Maybe, e as SfState, d as SfStateProps, f as createSfStateProvider } from './types-BdDsK6en.js';
2
+ import { S as SfContract, c as CreateSdkContextReturn } from './types-Dw2Ev7Da.js';
3
+ export { M as Maybe, e as SfState, d as SfStateProps, f as createSfStateProvider } from './types-Dw2Ev7Da.js';
4
4
  import 'react';
5
5
  import 'next/headers';
6
6
 
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,4 +1,4 @@
1
- import { C as CreateSdkOptions, a as Config, b as CreateSdkReturn } from './types-BdDsK6en.mjs';
1
+ import { C as CreateSdkOptions, a as Config, b as CreateSdkReturn } from './types-Dw2Ev7Da.mjs';
2
2
  import * as _vue_storefront_logger from '@vue-storefront/logger';
3
3
  import '@vue-storefront/sdk';
4
4
  import 'react';
@@ -30,7 +30,8 @@ import 'next/headers';
30
30
  * options,
31
31
  * ({ buildModule, middlewareModule, config, getRequestHeaders }) => ({
32
32
  * unified: buildModule(middlewareModule<UnifiedApiEndpoints>, {
33
- * apiUrl: config.middlewareUrl + "/commerce",
33
+ * apiUrl: config.apiUrl + "/commerce",
34
+ * ssrApiUrl: config.ssrApiUrl + "/commerce",
34
35
  * cdnCacheBustingId: config.cdnCacheBustingId,
35
36
  * defaultRequestConfig: {
36
37
  * headers: getRequestHeaders(),
@@ -38,7 +39,8 @@ import 'next/headers';
38
39
  * methodsRequestConfig: config.defaultMethodsRequestConfig.unifiedCommerce.middlewareModule,
39
40
  * }),
40
41
  * contentful: buildModule(contentfulModule, {
41
- * apiUrl: config.middlewareUrl + "/cntf",
42
+ * apiUrl: config.apiUrl + "/cntf",
43
+ * ssrApiUrl: config.ssrApiUrl + "/cntf",
42
44
  * }),
43
45
  * }),
44
46
  * );
@@ -54,7 +56,8 @@ declare function createSdk<TConfig extends Record<string, any>>(options: CreateS
54
56
  * const config = defineSdkConfig(
55
57
  * ({ buildModule, middlewareModule, config, getRequestHeaders }) => ({
56
58
  * unified: buildModule(middlewareModule<UnifiedApiEndpoints>, {
57
- * apiUrl: config.middlewareUrl + "/commerce",
59
+ * apiUrl: config.apiUrl + "/commerce",
60
+ * ssrApiUrl: config.ssrApiUrl + "/commerce",
58
61
  * cdnCacheBustingId: config.cdnCacheBustingId,
59
62
  * defaultRequestConfig: {
60
63
  * headers: getRequestHeaders(),
@@ -62,7 +65,8 @@ declare function createSdk<TConfig extends Record<string, any>>(options: CreateS
62
65
  * methodsRequestConfig: config.defaultMethodsRequestConfig.unifiedCommerce.middlewareModule,
63
66
  * }),
64
67
  * contentful: buildModule(contentfulModule, {
65
- * apiUrl: config.middlewareUrl + "/cntf",
68
+ * apiUrl: config.apiUrl + "/cntf",
69
+ * ssrApiUrl: config.ssrApiUrl + "/cntf",
66
70
  * }),
67
71
  * })
68
72
  * );
@@ -73,11 +77,17 @@ type ResolveSdkOptionsConfig = {
73
77
  };
74
78
  /**
75
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
+ *
76
85
  * @param input - The options for creating the SDK.
77
86
  * @param options - The configuration object, that allows to customize the API Url creation on enabled multistore.
87
+ *
78
88
  * @returns The resolved SDK options.
79
89
  */
80
- declare function resolveSdkOptions(input: CreateSdkOptions, options?: Partial<ResolveSdkOptionsConfig>): CreateSdkOptions;
90
+ declare function resolveSdkOptions(input: CreateSdkOptions, _options?: Partial<ResolveSdkOptionsConfig>): CreateSdkOptions;
81
91
 
82
92
  type LogVerbosity = "emergency" | "alert" | "critical" | "error" | "warning" | "notice" | "info" | "debug";
83
93
  type LoggerOptions = Partial<{
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { C as CreateSdkOptions, a as Config, b as CreateSdkReturn } from './types-BdDsK6en.js';
1
+ import { C as CreateSdkOptions, a as Config, b as CreateSdkReturn } from './types-Dw2Ev7Da.js';
2
2
  import * as _vue_storefront_logger from '@vue-storefront/logger';
3
3
  import '@vue-storefront/sdk';
4
4
  import 'react';
@@ -30,7 +30,8 @@ import 'next/headers';
30
30
  * options,
31
31
  * ({ buildModule, middlewareModule, config, getRequestHeaders }) => ({
32
32
  * unified: buildModule(middlewareModule<UnifiedApiEndpoints>, {
33
- * apiUrl: config.middlewareUrl + "/commerce",
33
+ * apiUrl: config.apiUrl + "/commerce",
34
+ * ssrApiUrl: config.ssrApiUrl + "/commerce",
34
35
  * cdnCacheBustingId: config.cdnCacheBustingId,
35
36
  * defaultRequestConfig: {
36
37
  * headers: getRequestHeaders(),
@@ -38,7 +39,8 @@ import 'next/headers';
38
39
  * methodsRequestConfig: config.defaultMethodsRequestConfig.unifiedCommerce.middlewareModule,
39
40
  * }),
40
41
  * contentful: buildModule(contentfulModule, {
41
- * apiUrl: config.middlewareUrl + "/cntf",
42
+ * apiUrl: config.apiUrl + "/cntf",
43
+ * ssrApiUrl: config.ssrApiUrl + "/cntf",
42
44
  * }),
43
45
  * }),
44
46
  * );
@@ -54,7 +56,8 @@ declare function createSdk<TConfig extends Record<string, any>>(options: CreateS
54
56
  * const config = defineSdkConfig(
55
57
  * ({ buildModule, middlewareModule, config, getRequestHeaders }) => ({
56
58
  * unified: buildModule(middlewareModule<UnifiedApiEndpoints>, {
57
- * apiUrl: config.middlewareUrl + "/commerce",
59
+ * apiUrl: config.apiUrl + "/commerce",
60
+ * ssrApiUrl: config.ssrApiUrl + "/commerce",
58
61
  * cdnCacheBustingId: config.cdnCacheBustingId,
59
62
  * defaultRequestConfig: {
60
63
  * headers: getRequestHeaders(),
@@ -62,7 +65,8 @@ declare function createSdk<TConfig extends Record<string, any>>(options: CreateS
62
65
  * methodsRequestConfig: config.defaultMethodsRequestConfig.unifiedCommerce.middlewareModule,
63
66
  * }),
64
67
  * contentful: buildModule(contentfulModule, {
65
- * apiUrl: config.middlewareUrl + "/cntf",
68
+ * apiUrl: config.apiUrl + "/cntf",
69
+ * ssrApiUrl: config.ssrApiUrl + "/cntf",
66
70
  * }),
67
71
  * })
68
72
  * );
@@ -73,11 +77,17 @@ type ResolveSdkOptionsConfig = {
73
77
  };
74
78
  /**
75
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
+ *
76
85
  * @param input - The options for creating the SDK.
77
86
  * @param options - The configuration object, that allows to customize the API Url creation on enabled multistore.
87
+ *
78
88
  * @returns The resolved SDK options.
79
89
  */
80
- declare function resolveSdkOptions(input: CreateSdkOptions, options?: Partial<ResolveSdkOptionsConfig>): CreateSdkOptions;
90
+ declare function resolveSdkOptions(input: CreateSdkOptions, _options?: Partial<ResolveSdkOptionsConfig>): CreateSdkOptions;
81
91
 
82
92
  type LogVerbosity = "emergency" | "alert" | "critical" | "error" | "warning" | "notice" | "info" | "debug";
83
93
  type LoggerOptions = Partial<{
package/dist/index.js CHANGED
@@ -100,62 +100,20 @@ var defaultMethodsRequestConfig = {
100
100
  }
101
101
  };
102
102
 
103
- // src/sdk/helpers/composeMiddlewareUrl.ts
104
- function calculateMiddlewareUrl({
105
- options,
106
- headers
107
- }) {
108
- var _a, _b, _c;
109
- const { apiUrl, ssrApiUrl } = options.middleware;
110
- if (typeof window !== "undefined") {
111
- if ((_a = options.multistore) == null ? void 0 : _a.enabled) {
112
- const url2 = new URL(apiUrl);
113
- url2.host = window.location.host;
114
- return url2.href;
115
- }
116
- return apiUrl;
117
- }
118
- if (ssrApiUrl) {
119
- return ssrApiUrl;
120
- }
121
- if (!((_b = options.multistore) == null ? void 0 : _b.enabled)) {
122
- return apiUrl;
123
- }
124
- const forwardedHost = (_c = headers["x-forwarded-host"]) != null ? _c : headers.host;
125
- const resolvedForwardedHost = forwardedHost && Array.isArray(forwardedHost) ? forwardedHost[0] : forwardedHost;
126
- const url = new URL(apiUrl);
127
- url.host = resolvedForwardedHost || new URL(apiUrl).host;
128
- return url.href;
129
- }
130
- function removeTrailingSlash(url) {
131
- return url.replace(/\/$/, "");
132
- }
133
- function composeMiddlewareUrl({
134
- options,
135
- headers
136
- }) {
137
- const url = calculateMiddlewareUrl({ options, headers });
138
- return removeTrailingSlash(url);
139
- }
140
-
141
103
  // src/sdk/index.tsx
142
104
  var import_sdk = require("@vue-storefront/sdk");
143
105
  function createSdk(options, configDefinition) {
144
106
  function getSdk(dynamicContext = {}) {
145
107
  var _a;
146
108
  const { getRequestHeaders } = resolveDynamicContext(dynamicContext);
147
- const middlewareUrl = composeMiddlewareUrl({
148
- options,
149
- headers: getRequestHeaders()
150
- });
151
109
  const resolvedConfig = configDefinition({
152
110
  defaults: defaultMethodsRequestConfig,
153
111
  buildModule: import_sdk.buildModule,
154
112
  middlewareModule: import_sdk.middlewareModule,
155
113
  getRequestHeaders,
156
- middlewareUrl,
157
114
  config: {
158
- middlewareUrl,
115
+ apiUrl: options.middleware.apiUrl,
116
+ ssrApiUrl: options.middleware.ssrApiUrl,
159
117
  defaultMethodsRequestConfig,
160
118
  cdnCacheBustingId: (_a = options.middleware.cdnCacheBustingId) != null ? _a : "no-cache-busting-id-set"
161
119
  }
@@ -169,22 +127,7 @@ function createSdk(options, configDefinition) {
169
127
  function defineSdkConfig(config) {
170
128
  return config;
171
129
  }
172
- function resolveSdkOptions(input, options = {}) {
173
- var _a, _b, _c, _d, _e;
174
- if ((_a = input == null ? void 0 : input.multistore) == null ? void 0 : _a.enabled) {
175
- return {
176
- middleware: {
177
- // This is a dummy URL, the localhost domain will be replaced by the actual domain in the browser
178
- // in composeMiddlewareUrl function. The server-side rendering will use ssrApiUrl.
179
- apiUrl: `https://localhost/${(_b = options == null ? void 0 : options.customSuffix) != null ? _b : "api"}`,
180
- cdnCacheBustingId: (_c = input.middleware) == null ? void 0 : _c.cdnCacheBustingId,
181
- ssrApiUrl: (_e = (_d = input.middleware) == null ? void 0 : _d.ssrApiUrl) != null ? _e : input.middleware.apiUrl
182
- },
183
- multistore: {
184
- enabled: true
185
- }
186
- };
187
- }
130
+ function resolveSdkOptions(input, _options = {}) {
188
131
  return input;
189
132
  }
190
133
 
package/dist/index.mjs CHANGED
@@ -59,62 +59,20 @@ var defaultMethodsRequestConfig = {
59
59
  }
60
60
  };
61
61
 
62
- // src/sdk/helpers/composeMiddlewareUrl.ts
63
- function calculateMiddlewareUrl({
64
- options,
65
- headers
66
- }) {
67
- var _a, _b, _c;
68
- const { apiUrl, ssrApiUrl } = options.middleware;
69
- if (typeof window !== "undefined") {
70
- if ((_a = options.multistore) == null ? void 0 : _a.enabled) {
71
- const url2 = new URL(apiUrl);
72
- url2.host = window.location.host;
73
- return url2.href;
74
- }
75
- return apiUrl;
76
- }
77
- if (ssrApiUrl) {
78
- return ssrApiUrl;
79
- }
80
- if (!((_b = options.multistore) == null ? void 0 : _b.enabled)) {
81
- return apiUrl;
82
- }
83
- const forwardedHost = (_c = headers["x-forwarded-host"]) != null ? _c : headers.host;
84
- const resolvedForwardedHost = forwardedHost && Array.isArray(forwardedHost) ? forwardedHost[0] : forwardedHost;
85
- const url = new URL(apiUrl);
86
- url.host = resolvedForwardedHost || new URL(apiUrl).host;
87
- return url.href;
88
- }
89
- function removeTrailingSlash(url) {
90
- return url.replace(/\/$/, "");
91
- }
92
- function composeMiddlewareUrl({
93
- options,
94
- headers
95
- }) {
96
- const url = calculateMiddlewareUrl({ options, headers });
97
- return removeTrailingSlash(url);
98
- }
99
-
100
62
  // src/sdk/index.tsx
101
63
  import { buildModule, initSDK, middlewareModule } from "@vue-storefront/sdk";
102
64
  function createSdk(options, configDefinition) {
103
65
  function getSdk(dynamicContext = {}) {
104
66
  var _a;
105
67
  const { getRequestHeaders } = resolveDynamicContext(dynamicContext);
106
- const middlewareUrl = composeMiddlewareUrl({
107
- options,
108
- headers: getRequestHeaders()
109
- });
110
68
  const resolvedConfig = configDefinition({
111
69
  defaults: defaultMethodsRequestConfig,
112
70
  buildModule,
113
71
  middlewareModule,
114
72
  getRequestHeaders,
115
- middlewareUrl,
116
73
  config: {
117
- middlewareUrl,
74
+ apiUrl: options.middleware.apiUrl,
75
+ ssrApiUrl: options.middleware.ssrApiUrl,
118
76
  defaultMethodsRequestConfig,
119
77
  cdnCacheBustingId: (_a = options.middleware.cdnCacheBustingId) != null ? _a : "no-cache-busting-id-set"
120
78
  }
@@ -128,22 +86,7 @@ function createSdk(options, configDefinition) {
128
86
  function defineSdkConfig(config) {
129
87
  return config;
130
88
  }
131
- function resolveSdkOptions(input, options = {}) {
132
- var _a, _b, _c, _d, _e;
133
- if ((_a = input == null ? void 0 : input.multistore) == null ? void 0 : _a.enabled) {
134
- return {
135
- middleware: {
136
- // This is a dummy URL, the localhost domain will be replaced by the actual domain in the browser
137
- // in composeMiddlewareUrl function. The server-side rendering will use ssrApiUrl.
138
- apiUrl: `https://localhost/${(_b = options == null ? void 0 : options.customSuffix) != null ? _b : "api"}`,
139
- cdnCacheBustingId: (_c = input.middleware) == null ? void 0 : _c.cdnCacheBustingId,
140
- ssrApiUrl: (_e = (_d = input.middleware) == null ? void 0 : _d.ssrApiUrl) != null ? _e : input.middleware.apiUrl
141
- },
142
- multistore: {
143
- enabled: true
144
- }
145
- };
146
- }
89
+ function resolveSdkOptions(input, _options = {}) {
147
90
  return input;
148
91
  }
149
92
 
@@ -1,4 +1,4 @@
1
- import { SDKApi, buildModule, middlewareModule } from '@vue-storefront/sdk';
1
+ import { buildModule, middlewareModule, SDKApi } from '@vue-storefront/sdk';
2
2
  import React, { PropsWithChildren, ReactNode } from 'react';
3
3
  import { cookies } from 'next/headers';
4
4
 
@@ -104,7 +104,7 @@ interface MiddlewareConfig {
104
104
  * The URL of the middleware for server-side rendering.
105
105
  * @example "http://localhost:4000"
106
106
  */
107
- ssrApiUrl?: string;
107
+ ssrApiUrl: string;
108
108
  /**
109
109
  * This is identifier used to invalidate the cache on CDN when the assets change.
110
110
  * Usually it's a commit hash.
@@ -142,16 +142,13 @@ type DynamicContext = {
142
142
  type StaticContext = {
143
143
  buildModule: typeof buildModule;
144
144
  middlewareModule: typeof middlewareModule;
145
- /**
146
- * @deprecated Use `config.middlewareUrl` instead.
147
- */
148
- middlewareUrl: string;
149
145
  /**
150
146
  * @deprecated Use `config.defaultMethodsRequestConfig` instead.
151
147
  */
152
148
  defaults: typeof defaultMethodsRequestConfig;
153
149
  config: {
154
- middlewareUrl: string;
150
+ apiUrl: string;
151
+ ssrApiUrl: string;
155
152
  defaultMethodsRequestConfig: typeof defaultMethodsRequestConfig;
156
153
  cdnCacheBustingId: string;
157
154
  };
@@ -1,4 +1,4 @@
1
- import { SDKApi, buildModule, middlewareModule } from '@vue-storefront/sdk';
1
+ import { buildModule, middlewareModule, SDKApi } from '@vue-storefront/sdk';
2
2
  import React, { PropsWithChildren, ReactNode } from 'react';
3
3
  import { cookies } from 'next/headers';
4
4
 
@@ -104,7 +104,7 @@ interface MiddlewareConfig {
104
104
  * The URL of the middleware for server-side rendering.
105
105
  * @example "http://localhost:4000"
106
106
  */
107
- ssrApiUrl?: string;
107
+ ssrApiUrl: string;
108
108
  /**
109
109
  * This is identifier used to invalidate the cache on CDN when the assets change.
110
110
  * Usually it's a commit hash.
@@ -142,16 +142,13 @@ type DynamicContext = {
142
142
  type StaticContext = {
143
143
  buildModule: typeof buildModule;
144
144
  middlewareModule: typeof middlewareModule;
145
- /**
146
- * @deprecated Use `config.middlewareUrl` instead.
147
- */
148
- middlewareUrl: string;
149
145
  /**
150
146
  * @deprecated Use `config.defaultMethodsRequestConfig` instead.
151
147
  */
152
148
  defaults: typeof defaultMethodsRequestConfig;
153
149
  config: {
154
- middlewareUrl: string;
150
+ apiUrl: string;
151
+ ssrApiUrl: string;
155
152
  defaultMethodsRequestConfig: typeof defaultMethodsRequestConfig;
156
153
  cdnCacheBustingId: string;
157
154
  };
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@vue-storefront/next",
3
3
  "description": "Alokai dedicated features for Next.js",
4
4
  "license": "MIT",
5
- "version": "4.3.2",
5
+ "version": "5.1.0",
6
6
  "exports": {
7
7
  ".": {
8
8
  "types": "./dist/index.d.ts",
@@ -23,7 +23,7 @@
23
23
  "lint": "biome ci .",
24
24
  "format": "prettier --write .",
25
25
  "test:unit": "vitest run",
26
- "version": "cp CHANGELOG.md ../../docs/content/storefront/6.change-log/next.md"
26
+ "version": "cp CHANGELOG.md ../../docs/enterprise/content/storefront/6.change-log/next.md"
27
27
  },
28
28
  "dependencies": {
29
29
  "zustand": "^4.5.4",