@commercengine/storefront-sdk-nextjs 0.1.0-alpha.1 → 0.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/README.md +333 -440
- package/dist/client.cjs +113 -407
- package/dist/client.d.cts +14 -135
- package/dist/client.d.cts.map +1 -0
- package/dist/client.d.ts +14 -135
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +40 -394
- package/dist/client.js.map +1 -0
- package/dist/index.cjs +126 -391
- package/dist/index.d.cts +36 -100
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.ts +36 -100
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +57 -380
- package/dist/index.js.map +1 -0
- package/dist/sdk-manager-B9xDQQuv.d.ts +141 -0
- package/dist/sdk-manager-B9xDQQuv.d.ts.map +1 -0
- package/dist/sdk-manager-CdgrfSVp.js +343 -0
- package/dist/sdk-manager-CdgrfSVp.js.map +1 -0
- package/dist/sdk-manager-D2ktqPrp.d.cts +141 -0
- package/dist/sdk-manager-D2ktqPrp.d.cts.map +1 -0
- package/dist/sdk-manager-NWADjRFW.cjs +400 -0
- package/dist/server.cjs +84 -398
- package/dist/server.d.cts +4 -4
- package/dist/server.d.ts +4 -4
- package/dist/server.js +4 -383
- package/package.json +4 -4
- package/dist/middleware.cjs +0 -66
- package/dist/middleware.d.cts +0 -38
- package/dist/middleware.d.ts +0 -38
- package/dist/middleware.js +0 -39
- package/dist/server-D-pFrx8J.d.cts +0 -105
- package/dist/server-DaDfTjsO.d.cts +0 -103
- package/dist/server-DaDfTjsO.d.ts +0 -103
- package/dist/server-DjlQVC11.d.ts +0 -105
- package/dist/storefront.cjs +0 -402
- package/dist/storefront.d.cts +0 -40
- package/dist/storefront.d.ts +0 -40
- package/dist/storefront.js +0 -376
package/dist/server.cjs
CHANGED
|
@@ -1,416 +1,102 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
21
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
-
mod
|
|
28
|
-
));
|
|
29
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
|
-
|
|
31
|
-
// src/server.ts
|
|
32
|
-
var server_exports = {};
|
|
33
|
-
__export(server_exports, {
|
|
34
|
-
ServerTokenStorage: () => ServerTokenStorage,
|
|
35
|
-
getStorefrontSDK: () => getStorefrontSDK,
|
|
36
|
-
initializeStorefrontSDK: () => initializeStorefrontSDK,
|
|
37
|
-
storefront: () => storefront
|
|
38
|
-
});
|
|
39
|
-
module.exports = __toCommonJS(server_exports);
|
|
40
|
-
|
|
41
|
-
// src/sdk-manager.ts
|
|
42
|
-
var import_react = require("react");
|
|
43
|
-
var import_storefront_sdk = require("@commercengine/storefront-sdk");
|
|
44
|
-
|
|
45
|
-
// src/token-storage.ts
|
|
46
|
-
var ClientTokenStorage = class {
|
|
47
|
-
constructor(options = {}) {
|
|
48
|
-
const prefix = options.prefix || "ce_";
|
|
49
|
-
this.accessTokenKey = `${prefix}access_token`;
|
|
50
|
-
this.refreshTokenKey = `${prefix}refresh_token`;
|
|
51
|
-
this.options = {
|
|
52
|
-
maxAge: options.maxAge || 30 * 24 * 60 * 60,
|
|
53
|
-
// 30 days default
|
|
54
|
-
path: options.path || "/",
|
|
55
|
-
domain: options.domain,
|
|
56
|
-
secure: options.secure ?? (typeof window !== "undefined" && window.location?.protocol === "https:"),
|
|
57
|
-
sameSite: options.sameSite || "Lax"
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
async getAccessToken() {
|
|
61
|
-
return this.getCookie(this.accessTokenKey);
|
|
62
|
-
}
|
|
63
|
-
async setAccessToken(token) {
|
|
64
|
-
this.setCookie(this.accessTokenKey, token);
|
|
65
|
-
}
|
|
66
|
-
async getRefreshToken() {
|
|
67
|
-
return this.getCookie(this.refreshTokenKey);
|
|
68
|
-
}
|
|
69
|
-
async setRefreshToken(token) {
|
|
70
|
-
this.setCookie(this.refreshTokenKey, token);
|
|
71
|
-
}
|
|
72
|
-
async clearTokens() {
|
|
73
|
-
this.deleteCookie(this.accessTokenKey);
|
|
74
|
-
this.deleteCookie(this.refreshTokenKey);
|
|
75
|
-
}
|
|
76
|
-
getCookie(name) {
|
|
77
|
-
if (typeof document === "undefined") return null;
|
|
78
|
-
const value = `; ${document.cookie}`;
|
|
79
|
-
const parts = value.split(`; ${name}=`);
|
|
80
|
-
if (parts.length === 2) {
|
|
81
|
-
const cookieValue = parts.pop()?.split(";").shift();
|
|
82
|
-
return cookieValue ? decodeURIComponent(cookieValue) : null;
|
|
83
|
-
}
|
|
84
|
-
return null;
|
|
85
|
-
}
|
|
86
|
-
setCookie(name, value) {
|
|
87
|
-
if (typeof document === "undefined") return;
|
|
88
|
-
const encodedValue = encodeURIComponent(value);
|
|
89
|
-
let cookieString = `${name}=${encodedValue}`;
|
|
90
|
-
if (this.options.maxAge) {
|
|
91
|
-
cookieString += `; Max-Age=${this.options.maxAge}`;
|
|
92
|
-
}
|
|
93
|
-
if (this.options.path) {
|
|
94
|
-
cookieString += `; Path=${this.options.path}`;
|
|
95
|
-
}
|
|
96
|
-
if (this.options.domain) {
|
|
97
|
-
cookieString += `; Domain=${this.options.domain}`;
|
|
98
|
-
}
|
|
99
|
-
if (this.options.secure) {
|
|
100
|
-
cookieString += `; Secure`;
|
|
101
|
-
}
|
|
102
|
-
if (this.options.sameSite) {
|
|
103
|
-
cookieString += `; SameSite=${this.options.sameSite}`;
|
|
104
|
-
}
|
|
105
|
-
document.cookie = cookieString;
|
|
106
|
-
}
|
|
107
|
-
deleteCookie(name) {
|
|
108
|
-
if (typeof document === "undefined") return;
|
|
109
|
-
let cookieString = `${name}=; Max-Age=0`;
|
|
110
|
-
if (this.options.path) {
|
|
111
|
-
cookieString += `; Path=${this.options.path}`;
|
|
112
|
-
}
|
|
113
|
-
if (this.options.domain) {
|
|
114
|
-
cookieString += `; Domain=${this.options.domain}`;
|
|
115
|
-
}
|
|
116
|
-
document.cookie = cookieString;
|
|
117
|
-
}
|
|
118
|
-
};
|
|
119
|
-
var ServerTokenStorage = class {
|
|
120
|
-
constructor(cookieStore, options = {}) {
|
|
121
|
-
const prefix = options.prefix || "ce_";
|
|
122
|
-
this.accessTokenKey = `${prefix}access_token`;
|
|
123
|
-
this.refreshTokenKey = `${prefix}refresh_token`;
|
|
124
|
-
this.cookieStore = cookieStore;
|
|
125
|
-
this.options = {
|
|
126
|
-
maxAge: options.maxAge || 30 * 24 * 60 * 60,
|
|
127
|
-
// 30 days default
|
|
128
|
-
path: options.path || "/",
|
|
129
|
-
domain: options.domain,
|
|
130
|
-
secure: options.secure ?? process.env.NODE_ENV === "production",
|
|
131
|
-
sameSite: options.sameSite || "Lax"
|
|
132
|
-
};
|
|
133
|
-
}
|
|
134
|
-
async getAccessToken() {
|
|
135
|
-
try {
|
|
136
|
-
return this.cookieStore.get(this.accessTokenKey)?.value || null;
|
|
137
|
-
} catch (error) {
|
|
138
|
-
console.warn(`Could not get access token from server cookies:`, error);
|
|
139
|
-
return null;
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
async setAccessToken(token) {
|
|
143
|
-
try {
|
|
144
|
-
this.cookieStore.set(this.accessTokenKey, token, {
|
|
145
|
-
maxAge: this.options.maxAge,
|
|
146
|
-
path: this.options.path,
|
|
147
|
-
domain: this.options.domain,
|
|
148
|
-
secure: this.options.secure,
|
|
149
|
-
sameSite: this.options.sameSite?.toLowerCase(),
|
|
150
|
-
httpOnly: false
|
|
151
|
-
// Allow client-side access for SDK flexibility
|
|
152
|
-
});
|
|
153
|
-
} catch (error) {
|
|
154
|
-
console.warn(`Could not set access token on server:`, error);
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
async getRefreshToken() {
|
|
158
|
-
try {
|
|
159
|
-
return this.cookieStore.get(this.refreshTokenKey)?.value || null;
|
|
160
|
-
} catch (error) {
|
|
161
|
-
console.warn(`Could not get refresh token from server cookies:`, error);
|
|
162
|
-
return null;
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
async setRefreshToken(token) {
|
|
166
|
-
try {
|
|
167
|
-
this.cookieStore.set(this.refreshTokenKey, token, {
|
|
168
|
-
maxAge: this.options.maxAge,
|
|
169
|
-
path: this.options.path,
|
|
170
|
-
domain: this.options.domain,
|
|
171
|
-
secure: this.options.secure,
|
|
172
|
-
sameSite: this.options.sameSite?.toLowerCase(),
|
|
173
|
-
httpOnly: false
|
|
174
|
-
// Allow client-side access for SDK flexibility
|
|
175
|
-
});
|
|
176
|
-
} catch (error) {
|
|
177
|
-
console.warn(`Could not set refresh token on server:`, error);
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
async clearTokens() {
|
|
181
|
-
try {
|
|
182
|
-
this.cookieStore.delete(this.accessTokenKey);
|
|
183
|
-
this.cookieStore.delete(this.refreshTokenKey);
|
|
184
|
-
} catch (error) {
|
|
185
|
-
console.warn(`Could not clear tokens on server:`, error);
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
};
|
|
189
|
-
|
|
190
|
-
// src/build-token-cache.ts
|
|
191
|
-
var store = /* @__PURE__ */ new Map();
|
|
192
|
-
function isExpired(token) {
|
|
193
|
-
if (!token) return true;
|
|
194
|
-
if (!token.expiresAt) return false;
|
|
195
|
-
return Date.now() > token.expiresAt - 3e4;
|
|
196
|
-
}
|
|
197
|
-
function getCachedToken(key) {
|
|
198
|
-
const token = store.get(key);
|
|
199
|
-
return isExpired(token) ? null : token;
|
|
200
|
-
}
|
|
201
|
-
function setCachedToken(key, token) {
|
|
202
|
-
const expiresAt = token.ttlSeconds != null ? Date.now() + token.ttlSeconds * 1e3 : void 0;
|
|
203
|
-
store.set(key, {
|
|
204
|
-
accessToken: token.accessToken,
|
|
205
|
-
refreshToken: token.refreshToken ?? null,
|
|
206
|
-
expiresAt
|
|
207
|
-
});
|
|
208
|
-
}
|
|
209
|
-
function clearCachedToken(key) {
|
|
210
|
-
store.delete(key);
|
|
211
|
-
}
|
|
1
|
+
const require_sdk_manager = require('./sdk-manager-NWADjRFW.cjs');
|
|
2
|
+
const __commercengine_storefront_sdk = require_sdk_manager.__toESM(require("@commercengine/storefront-sdk"));
|
|
212
3
|
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
this.cacheKey = cacheKey;
|
|
218
|
-
this.ttlSeconds = ttlSeconds;
|
|
219
|
-
this.access = null;
|
|
220
|
-
this.refresh = null;
|
|
4
|
+
Object.defineProperty(exports, 'AuthClient', {
|
|
5
|
+
enumerable: true,
|
|
6
|
+
get: function () {
|
|
7
|
+
return __commercengine_storefront_sdk.AuthClient;
|
|
221
8
|
}
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
const cached = getCachedToken(this.cacheKey);
|
|
228
|
-
if (cached?.accessToken) {
|
|
229
|
-
console.log(`\u{1F7E2} [BuildCache] Using cached token for key: ${this.cacheKey}`);
|
|
230
|
-
this.access = cached.accessToken;
|
|
231
|
-
this.refresh = cached.refreshToken ?? null;
|
|
232
|
-
return this.access;
|
|
233
|
-
}
|
|
234
|
-
console.log(`\u{1F7E1} [BuildCache] No cached token found for key: ${this.cacheKey}`);
|
|
235
|
-
return null;
|
|
9
|
+
});
|
|
10
|
+
Object.defineProperty(exports, 'BrowserTokenStorage', {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () {
|
|
13
|
+
return __commercengine_storefront_sdk.BrowserTokenStorage;
|
|
236
14
|
}
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
refreshToken: this.refresh,
|
|
243
|
-
ttlSeconds: this.ttlSeconds
|
|
244
|
-
});
|
|
15
|
+
});
|
|
16
|
+
Object.defineProperty(exports, 'CartClient', {
|
|
17
|
+
enumerable: true,
|
|
18
|
+
get: function () {
|
|
19
|
+
return __commercengine_storefront_sdk.CartClient;
|
|
245
20
|
}
|
|
246
|
-
|
|
247
|
-
|
|
21
|
+
});
|
|
22
|
+
Object.defineProperty(exports, 'CatalogClient', {
|
|
23
|
+
enumerable: true,
|
|
24
|
+
get: function () {
|
|
25
|
+
return __commercengine_storefront_sdk.CatalogClient;
|
|
248
26
|
}
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
ttlSeconds: this.ttlSeconds
|
|
255
|
-
});
|
|
27
|
+
});
|
|
28
|
+
Object.defineProperty(exports, 'CookieTokenStorage', {
|
|
29
|
+
enumerable: true,
|
|
30
|
+
get: function () {
|
|
31
|
+
return __commercengine_storefront_sdk.CookieTokenStorage;
|
|
256
32
|
}
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
33
|
+
});
|
|
34
|
+
Object.defineProperty(exports, 'CustomerClient', {
|
|
35
|
+
enumerable: true,
|
|
36
|
+
get: function () {
|
|
37
|
+
return __commercengine_storefront_sdk.CustomerClient;
|
|
261
38
|
}
|
|
262
|
-
};
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
return {
|
|
268
|
-
storeId: process.env.NEXT_PUBLIC_STORE_ID || "",
|
|
269
|
-
environment: process.env.NEXT_PUBLIC_ENVIRONMENT === "production" ? import_storefront_sdk.Environment.Production : import_storefront_sdk.Environment.Staging,
|
|
270
|
-
apiKey: process.env.NEXT_PUBLIC_API_KEY
|
|
271
|
-
};
|
|
272
|
-
}
|
|
273
|
-
function getConfig() {
|
|
274
|
-
if (globalConfig) {
|
|
275
|
-
return globalConfig;
|
|
39
|
+
});
|
|
40
|
+
Object.defineProperty(exports, 'Environment', {
|
|
41
|
+
enumerable: true,
|
|
42
|
+
get: function () {
|
|
43
|
+
return __commercengine_storefront_sdk.Environment;
|
|
276
44
|
}
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
function
|
|
281
|
-
|
|
282
|
-
const { cookies } = require("next/headers");
|
|
283
|
-
cookies();
|
|
284
|
-
return true;
|
|
285
|
-
} catch {
|
|
286
|
-
return false;
|
|
45
|
+
});
|
|
46
|
+
Object.defineProperty(exports, 'HelpersClient', {
|
|
47
|
+
enumerable: true,
|
|
48
|
+
get: function () {
|
|
49
|
+
return __commercengine_storefront_sdk.HelpersClient;
|
|
287
50
|
}
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
51
|
+
});
|
|
52
|
+
Object.defineProperty(exports, 'MemoryTokenStorage', {
|
|
53
|
+
enumerable: true,
|
|
54
|
+
get: function () {
|
|
55
|
+
return __commercengine_storefront_sdk.MemoryTokenStorage;
|
|
292
56
|
}
|
|
293
|
-
|
|
294
|
-
|
|
57
|
+
});
|
|
58
|
+
Object.defineProperty(exports, 'OrderClient', {
|
|
59
|
+
enumerable: true,
|
|
60
|
+
get: function () {
|
|
61
|
+
return __commercengine_storefront_sdk.OrderClient;
|
|
295
62
|
}
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
return
|
|
63
|
+
});
|
|
64
|
+
Object.defineProperty(exports, 'ResponseUtils', {
|
|
65
|
+
enumerable: true,
|
|
66
|
+
get: function () {
|
|
67
|
+
return __commercengine_storefront_sdk.ResponseUtils;
|
|
301
68
|
}
|
|
302
|
-
console.log(`\u{1F504} [Build] Using standard MemoryTokenStorage (caching disabled)`);
|
|
303
|
-
return new import_storefront_sdk.MemoryTokenStorage();
|
|
304
|
-
}
|
|
305
|
-
var getServerSDKCached = (0, import_react.cache)((cookieStore) => {
|
|
306
|
-
const config = getEnvConfig();
|
|
307
|
-
return new import_storefront_sdk.StorefrontSDK({
|
|
308
|
-
...config,
|
|
309
|
-
tokenStorage: createTokenStorage(
|
|
310
|
-
cookieStore,
|
|
311
|
-
config.tokenStorageOptions,
|
|
312
|
-
config
|
|
313
|
-
)
|
|
314
|
-
});
|
|
315
69
|
});
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
...config,
|
|
322
|
-
tokenStorage: createTokenStorage(
|
|
323
|
-
void 0,
|
|
324
|
-
config.tokenStorageOptions,
|
|
325
|
-
config
|
|
326
|
-
)
|
|
327
|
-
});
|
|
70
|
+
exports.ServerTokenStorage = require_sdk_manager.ServerTokenStorage;
|
|
71
|
+
Object.defineProperty(exports, 'ShippingClient', {
|
|
72
|
+
enumerable: true,
|
|
73
|
+
get: function () {
|
|
74
|
+
return __commercengine_storefront_sdk.ShippingClient;
|
|
328
75
|
}
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
console.warn(
|
|
335
|
-
"Cookie store passed in client environment - this will be ignored"
|
|
336
|
-
);
|
|
337
|
-
}
|
|
338
|
-
const config = getConfig();
|
|
339
|
-
if (!clientSDK) {
|
|
340
|
-
clientSDK = new import_storefront_sdk.StorefrontSDK({
|
|
341
|
-
...config,
|
|
342
|
-
tokenStorage: createTokenStorage(
|
|
343
|
-
void 0,
|
|
344
|
-
config.tokenStorageOptions,
|
|
345
|
-
config
|
|
346
|
-
)
|
|
347
|
-
});
|
|
348
|
-
}
|
|
349
|
-
return clientSDK;
|
|
76
|
+
});
|
|
77
|
+
Object.defineProperty(exports, 'StoreConfigClient', {
|
|
78
|
+
enumerable: true,
|
|
79
|
+
get: function () {
|
|
80
|
+
return __commercengine_storefront_sdk.StoreConfigClient;
|
|
350
81
|
}
|
|
351
|
-
|
|
352
|
-
|
|
82
|
+
});
|
|
83
|
+
Object.defineProperty(exports, 'StorefrontAPIClient', {
|
|
84
|
+
enumerable: true,
|
|
85
|
+
get: function () {
|
|
86
|
+
return __commercengine_storefront_sdk.StorefrontAPIClient;
|
|
353
87
|
}
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
\u{1F50D} Auto-detection attempted but failed. You may be in:
|
|
361
|
-
- Server Action (use: const sdk = getStorefrontSDK(await cookies()))
|
|
362
|
-
- API Route (use: const sdk = getStorefrontSDK(cookies()))
|
|
363
|
-
- Server Component in App Router (use: const sdk = getStorefrontSDK(cookies()))
|
|
364
|
-
`;
|
|
365
|
-
} catch {
|
|
366
|
-
autoDetectMessage = `
|
|
367
|
-
|
|
368
|
-
\u{1F4A1} Make sure you have Next.js installed and are in a server context.
|
|
369
|
-
`;
|
|
370
|
-
}
|
|
371
|
-
throw new Error(
|
|
372
|
-
`
|
|
373
|
-
\u{1F6A8} Server Environment Detected!
|
|
374
|
-
|
|
375
|
-
You're calling getStorefrontSDK() on the server without cookies.
|
|
376
|
-
Please pass the Next.js cookie store:
|
|
377
|
-
|
|
378
|
-
\u2705 Correct usage:
|
|
379
|
-
import { cookies } from 'next/headers';
|
|
380
|
-
|
|
381
|
-
// Server Actions & Route Handlers
|
|
382
|
-
const sdk = getStorefrontSDK(await cookies());
|
|
383
|
-
|
|
384
|
-
// API Routes & Server Components (App Router)
|
|
385
|
-
const sdk = getStorefrontSDK(cookies());
|
|
386
|
-
|
|
387
|
-
\u274C Your current usage:
|
|
388
|
-
const sdk = getStorefrontSDK(); // Missing cookies!
|
|
389
|
-
${autoDetectMessage}
|
|
390
|
-
This is required for server-side token access.
|
|
391
|
-
`.trim()
|
|
392
|
-
);
|
|
88
|
+
});
|
|
89
|
+
Object.defineProperty(exports, 'StorefrontSDK', {
|
|
90
|
+
enumerable: true,
|
|
91
|
+
get: function () {
|
|
92
|
+
return __commercengine_storefront_sdk.StorefrontSDK;
|
|
393
93
|
}
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
}
|
|
401
|
-
|
|
402
|
-
// src/storefront.ts
|
|
403
|
-
function storefront(cookieStore) {
|
|
404
|
-
return getStorefrontSDK(cookieStore);
|
|
405
|
-
}
|
|
406
|
-
|
|
407
|
-
// src/server.ts
|
|
408
|
-
__reExport(server_exports, require("@commercengine/storefront-sdk"), module.exports);
|
|
409
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
410
|
-
0 && (module.exports = {
|
|
411
|
-
ServerTokenStorage,
|
|
412
|
-
getStorefrontSDK,
|
|
413
|
-
initializeStorefrontSDK,
|
|
414
|
-
storefront,
|
|
415
|
-
...require("@commercengine/storefront-sdk")
|
|
94
|
+
});
|
|
95
|
+
exports.getStorefrontSDK = require_sdk_manager.getStorefrontSDK;
|
|
96
|
+
exports.initializeStorefrontSDK = require_sdk_manager.initializeStorefrontSDK;
|
|
97
|
+
Object.keys(__commercengine_storefront_sdk).forEach(function (k) {
|
|
98
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
99
|
+
enumerable: true,
|
|
100
|
+
get: function () { return __commercengine_storefront_sdk[k]; }
|
|
101
|
+
});
|
|
416
102
|
});
|
package/dist/server.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export * from
|
|
4
|
-
export { StorefrontSDK,
|
|
1
|
+
import { NextJSSDKConfig, NextJSTokenStorageOptions, ServerTokenStorage, getStorefrontSDK, initializeStorefrontSDK } from "./sdk-manager-D2ktqPrp.cjs";
|
|
2
|
+
import { AuthClient, BrowserTokenStorage, CartClient, CatalogClient, CookieTokenStorage, CustomerClient, Environment, HelpersClient, MemoryTokenStorage, OrderClient, ResponseUtils, ShippingClient, StoreConfigClient, StorefrontAPIClient, StorefrontSDK } from "@commercengine/storefront-sdk";
|
|
3
|
+
export * from "@commercengine/storefront-sdk";
|
|
4
|
+
export { AuthClient, BrowserTokenStorage, CartClient, CatalogClient, CookieTokenStorage, CustomerClient, Environment, HelpersClient, MemoryTokenStorage, type NextJSSDKConfig, type NextJSTokenStorageOptions, OrderClient, ResponseUtils, ServerTokenStorage, ShippingClient, StoreConfigClient, StorefrontAPIClient, StorefrontSDK, getStorefrontSDK, initializeStorefrontSDK };
|
package/dist/server.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export * from
|
|
4
|
-
export { StorefrontSDK,
|
|
1
|
+
import { NextJSSDKConfig, NextJSTokenStorageOptions, ServerTokenStorage, getStorefrontSDK, initializeStorefrontSDK } from "./sdk-manager-B9xDQQuv.js";
|
|
2
|
+
import { AuthClient, BrowserTokenStorage, CartClient, CatalogClient, CookieTokenStorage, CustomerClient, Environment, HelpersClient, MemoryTokenStorage, OrderClient, ResponseUtils, ShippingClient, StoreConfigClient, StorefrontAPIClient, StorefrontSDK } from "@commercengine/storefront-sdk";
|
|
3
|
+
export * from "@commercengine/storefront-sdk";
|
|
4
|
+
export { AuthClient, BrowserTokenStorage, CartClient, CatalogClient, CookieTokenStorage, CustomerClient, Environment, HelpersClient, MemoryTokenStorage, type NextJSSDKConfig, type NextJSTokenStorageOptions, OrderClient, ResponseUtils, ServerTokenStorage, ShippingClient, StoreConfigClient, StorefrontAPIClient, StorefrontSDK, getStorefrontSDK, initializeStorefrontSDK };
|