@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/dist/client.d.cts CHANGED
@@ -1,138 +1,17 @@
1
- import { TokenStorage, StorefrontSDK, StorefrontSDKOptions } from '@commercengine/storefront-sdk';
2
- export * from '@commercengine/storefront-sdk';
3
- export { StorefrontSDK, StorefrontSDKOptions } from '@commercengine/storefront-sdk';
4
-
5
- /**
6
- * Configuration options for NextJSTokenStorage
7
- */
8
- interface NextJSTokenStorageOptions {
9
- /**
10
- * Prefix for cookie names (default: "ce_")
11
- */
12
- prefix?: string;
13
- /**
14
- * Maximum age of cookies in seconds (default: 30 days)
15
- */
16
- maxAge?: number;
17
- /**
18
- * Cookie path (default: "/")
19
- */
20
- path?: string;
21
- /**
22
- * Cookie domain (default: current domain)
23
- */
24
- domain?: string;
25
- /**
26
- * Whether cookies should be secure (default: auto-detect based on environment)
27
- */
28
- secure?: boolean;
29
- /**
30
- * SameSite cookie attribute (default: "Lax")
31
- */
32
- sameSite?: "Strict" | "Lax" | "None";
33
- }
34
- /**
35
- * Client-side token storage that uses document.cookie
36
- */
37
- declare class ClientTokenStorage implements TokenStorage {
38
- private accessTokenKey;
39
- private refreshTokenKey;
40
- private options;
41
- constructor(options?: NextJSTokenStorageOptions);
42
- getAccessToken(): Promise<string | null>;
43
- setAccessToken(token: string): Promise<void>;
44
- getRefreshToken(): Promise<string | null>;
45
- setRefreshToken(token: string): Promise<void>;
46
- clearTokens(): Promise<void>;
47
- private getCookie;
48
- private setCookie;
49
- private deleteCookie;
50
- }
51
-
52
- /**
53
- * Configuration for the NextJS SDK wrapper
54
- */
55
- interface NextJSSDKConfig extends Omit<StorefrontSDKOptions, "tokenStorage"> {
56
- /**
57
- * Token storage configuration options
58
- */
59
- tokenStorageOptions?: NextJSTokenStorageOptions;
60
- }
61
- type NextCookieStore$1 = {
62
- get: (name: string) => {
63
- value: string;
64
- } | undefined;
65
- set: (name: string, value: string, options?: any) => void;
66
- delete: (name: string) => void;
67
- };
68
- /**
69
- * Smart SDK getter that automatically detects environment
70
- *
71
- * Usage:
72
- * - Client-side: getStorefrontSDK()
73
- * - Server-side with request context: getStorefrontSDK(await cookies())
74
- * - SSG/ISR (no request context): getStorefrontSDK() (uses memory storage)
75
- */
76
- declare function getStorefrontSDK(): StorefrontSDK;
77
- declare function getStorefrontSDK(cookieStore: NextCookieStore$1): StorefrontSDK;
78
- /**
79
- * Initialize the SDK with configuration (internal use)
80
- * This should be called once in your app via StorefrontSDKInitializer
81
- */
82
- declare function initializeStorefrontSDK(config: NextJSSDKConfig): void;
83
-
84
- /**
85
- * Universal storefront SDK export
86
- *
87
- * This provides a simple unified interface that works in all Next.js contexts:
88
- * - Client components: automatically uses client token storage
89
- * - Server components: requires cookies() to be passed
90
- * - SSG/ISR: automatically uses memory storage with optional build caching
91
- *
92
- * Usage:
93
- * ```typescript
94
- * // Client-side
95
- * import { storefront } from '@commercengine/storefront-sdk-nextjs/storefront'
96
- * const products = await storefront().catalog.listProducts()
97
- *
98
- * // Server-side
99
- * import { storefront } from '@commercengine/storefront-sdk-nextjs/storefront'
100
- * import { cookies } from 'next/headers'
101
- * const products = await storefront(cookies()).catalog.listProducts()
102
- * ```
103
- */
104
-
105
- type NextCookieStore = {
106
- get: (name: string) => {
107
- value: string;
108
- } | undefined;
109
- set: (name: string, value: string, options?: any) => void;
110
- delete: (name: string) => void;
111
- };
112
- /**
113
- * Universal storefront SDK accessor
114
- *
115
- * @param cookieStore - Next.js cookie store (required on server-side)
116
- * @returns StorefrontSDK instance configured for the current environment
117
- */
118
- declare function storefront(): StorefrontSDK;
119
- declare function storefront(cookieStore: NextCookieStore): StorefrontSDK;
1
+ import { ClientTokenStorage, NextJSSDKConfig, NextJSTokenStorageOptions, StorefrontRuntimeConfig, getStorefrontSDK, initializeStorefrontSDK } from "./sdk-manager-D2ktqPrp.cjs";
2
+ import { AuthClient, BrowserTokenStorage, CartClient, CatalogClient, CookieTokenStorage, CustomerClient, Environment, HelpersClient, MemoryTokenStorage, OrderClient, ResponseUtils, ShippingClient, StoreConfigClient, StorefrontAPIClient, StorefrontSDK, StorefrontSDKOptions, TokenStorage } from "@commercengine/storefront-sdk";
120
3
 
4
+ //#region src/init-client.d.ts
121
5
  interface StorefrontSDKInitializerProps {
122
- config: NextJSSDKConfig;
6
+ /**
7
+ * Optional runtime configuration overrides for client-side API calls
8
+ * These settings will apply to all client-side storefront() calls
9
+ */
10
+ runtimeConfig?: StorefrontRuntimeConfig;
123
11
  }
124
- /**
125
- * Client-side initialization component
126
- * Use this in your root layout to initialize the SDK once
127
- *
128
- * The core SDK middleware now automatically handles everything:
129
- * - Creates anonymous tokens automatically on first API request (if no tokens exist)
130
- * - Token state assessment and cleanup on first request per page load
131
- * - Expired token refresh with automatic anonymous fallback
132
- * - Graceful handling of partial token states
133
- *
134
- * No manual token creation needed - just make API calls and everything works!
135
- */
136
- declare function StorefrontSDKInitializer({ config, }: StorefrontSDKInitializerProps): null;
137
-
138
- export { ClientTokenStorage, type NextJSSDKConfig, type NextJSTokenStorageOptions, StorefrontSDKInitializer, getStorefrontSDK, initializeStorefrontSDK, storefront };
12
+ declare function StorefrontSDKInitializer({
13
+ runtimeConfig
14
+ }?: StorefrontSDKInitializerProps): null;
15
+ //#endregion
16
+ export { AuthClient, BrowserTokenStorage, CartClient, CatalogClient, ClientTokenStorage, CookieTokenStorage, CustomerClient, Environment, HelpersClient, MemoryTokenStorage, type NextJSSDKConfig, type NextJSTokenStorageOptions, OrderClient, ResponseUtils, ShippingClient, StoreConfigClient, StorefrontAPIClient, StorefrontSDK, StorefrontSDKInitializer, type StorefrontSDKOptions, type TokenStorage, getStorefrontSDK, initializeStorefrontSDK };
17
+ //# sourceMappingURL=client.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.cts","names":[],"sources":["../src/init-client.ts"],"sourcesContent":[],"mappings":";;;;UAuCU,6BAAA;;;AAhCa;AAwCvB;EAAwC,aAAA,CAAA,EAHtB,uBAGsB;;AAAoB,iBAA5C,wBAAA,CAA4C;EAAA;AAAA,CAAA,CAAA,EAAA,6BAAA,CAAA,EAAA,IAAA"}
package/dist/client.d.ts CHANGED
@@ -1,138 +1,17 @@
1
- import { TokenStorage, StorefrontSDK, StorefrontSDKOptions } from '@commercengine/storefront-sdk';
2
- export * from '@commercengine/storefront-sdk';
3
- export { StorefrontSDK, StorefrontSDKOptions } from '@commercengine/storefront-sdk';
4
-
5
- /**
6
- * Configuration options for NextJSTokenStorage
7
- */
8
- interface NextJSTokenStorageOptions {
9
- /**
10
- * Prefix for cookie names (default: "ce_")
11
- */
12
- prefix?: string;
13
- /**
14
- * Maximum age of cookies in seconds (default: 30 days)
15
- */
16
- maxAge?: number;
17
- /**
18
- * Cookie path (default: "/")
19
- */
20
- path?: string;
21
- /**
22
- * Cookie domain (default: current domain)
23
- */
24
- domain?: string;
25
- /**
26
- * Whether cookies should be secure (default: auto-detect based on environment)
27
- */
28
- secure?: boolean;
29
- /**
30
- * SameSite cookie attribute (default: "Lax")
31
- */
32
- sameSite?: "Strict" | "Lax" | "None";
33
- }
34
- /**
35
- * Client-side token storage that uses document.cookie
36
- */
37
- declare class ClientTokenStorage implements TokenStorage {
38
- private accessTokenKey;
39
- private refreshTokenKey;
40
- private options;
41
- constructor(options?: NextJSTokenStorageOptions);
42
- getAccessToken(): Promise<string | null>;
43
- setAccessToken(token: string): Promise<void>;
44
- getRefreshToken(): Promise<string | null>;
45
- setRefreshToken(token: string): Promise<void>;
46
- clearTokens(): Promise<void>;
47
- private getCookie;
48
- private setCookie;
49
- private deleteCookie;
50
- }
51
-
52
- /**
53
- * Configuration for the NextJS SDK wrapper
54
- */
55
- interface NextJSSDKConfig extends Omit<StorefrontSDKOptions, "tokenStorage"> {
56
- /**
57
- * Token storage configuration options
58
- */
59
- tokenStorageOptions?: NextJSTokenStorageOptions;
60
- }
61
- type NextCookieStore$1 = {
62
- get: (name: string) => {
63
- value: string;
64
- } | undefined;
65
- set: (name: string, value: string, options?: any) => void;
66
- delete: (name: string) => void;
67
- };
68
- /**
69
- * Smart SDK getter that automatically detects environment
70
- *
71
- * Usage:
72
- * - Client-side: getStorefrontSDK()
73
- * - Server-side with request context: getStorefrontSDK(await cookies())
74
- * - SSG/ISR (no request context): getStorefrontSDK() (uses memory storage)
75
- */
76
- declare function getStorefrontSDK(): StorefrontSDK;
77
- declare function getStorefrontSDK(cookieStore: NextCookieStore$1): StorefrontSDK;
78
- /**
79
- * Initialize the SDK with configuration (internal use)
80
- * This should be called once in your app via StorefrontSDKInitializer
81
- */
82
- declare function initializeStorefrontSDK(config: NextJSSDKConfig): void;
83
-
84
- /**
85
- * Universal storefront SDK export
86
- *
87
- * This provides a simple unified interface that works in all Next.js contexts:
88
- * - Client components: automatically uses client token storage
89
- * - Server components: requires cookies() to be passed
90
- * - SSG/ISR: automatically uses memory storage with optional build caching
91
- *
92
- * Usage:
93
- * ```typescript
94
- * // Client-side
95
- * import { storefront } from '@commercengine/storefront-sdk-nextjs/storefront'
96
- * const products = await storefront().catalog.listProducts()
97
- *
98
- * // Server-side
99
- * import { storefront } from '@commercengine/storefront-sdk-nextjs/storefront'
100
- * import { cookies } from 'next/headers'
101
- * const products = await storefront(cookies()).catalog.listProducts()
102
- * ```
103
- */
104
-
105
- type NextCookieStore = {
106
- get: (name: string) => {
107
- value: string;
108
- } | undefined;
109
- set: (name: string, value: string, options?: any) => void;
110
- delete: (name: string) => void;
111
- };
112
- /**
113
- * Universal storefront SDK accessor
114
- *
115
- * @param cookieStore - Next.js cookie store (required on server-side)
116
- * @returns StorefrontSDK instance configured for the current environment
117
- */
118
- declare function storefront(): StorefrontSDK;
119
- declare function storefront(cookieStore: NextCookieStore): StorefrontSDK;
1
+ import { ClientTokenStorage, NextJSSDKConfig, NextJSTokenStorageOptions, StorefrontRuntimeConfig, getStorefrontSDK, initializeStorefrontSDK } from "./sdk-manager-B9xDQQuv.js";
2
+ import { AuthClient, BrowserTokenStorage, CartClient, CatalogClient, CookieTokenStorage, CustomerClient, Environment, HelpersClient, MemoryTokenStorage, OrderClient, ResponseUtils, ShippingClient, StoreConfigClient, StorefrontAPIClient, StorefrontSDK, StorefrontSDKOptions, TokenStorage } from "@commercengine/storefront-sdk";
120
3
 
4
+ //#region src/init-client.d.ts
121
5
  interface StorefrontSDKInitializerProps {
122
- config: NextJSSDKConfig;
6
+ /**
7
+ * Optional runtime configuration overrides for client-side API calls
8
+ * These settings will apply to all client-side storefront() calls
9
+ */
10
+ runtimeConfig?: StorefrontRuntimeConfig;
123
11
  }
124
- /**
125
- * Client-side initialization component
126
- * Use this in your root layout to initialize the SDK once
127
- *
128
- * The core SDK middleware now automatically handles everything:
129
- * - Creates anonymous tokens automatically on first API request (if no tokens exist)
130
- * - Token state assessment and cleanup on first request per page load
131
- * - Expired token refresh with automatic anonymous fallback
132
- * - Graceful handling of partial token states
133
- *
134
- * No manual token creation needed - just make API calls and everything works!
135
- */
136
- declare function StorefrontSDKInitializer({ config, }: StorefrontSDKInitializerProps): null;
137
-
138
- export { ClientTokenStorage, type NextJSSDKConfig, type NextJSTokenStorageOptions, StorefrontSDKInitializer, getStorefrontSDK, initializeStorefrontSDK, storefront };
12
+ declare function StorefrontSDKInitializer({
13
+ runtimeConfig
14
+ }?: StorefrontSDKInitializerProps): null;
15
+ //#endregion
16
+ export { AuthClient, BrowserTokenStorage, CartClient, CatalogClient, ClientTokenStorage, CookieTokenStorage, CustomerClient, Environment, HelpersClient, MemoryTokenStorage, type NextJSSDKConfig, type NextJSTokenStorageOptions, OrderClient, ResponseUtils, ShippingClient, StoreConfigClient, StorefrontAPIClient, StorefrontSDK, StorefrontSDKInitializer, type StorefrontSDKOptions, type TokenStorage, getStorefrontSDK, initializeStorefrontSDK };
17
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","names":[],"sources":["../src/init-client.ts"],"sourcesContent":[],"mappings":";;;;UAuCU,6BAAA;;;AAhCa;AAwCvB;EAAwC,aAAA,CAAA,EAHtB,uBAGsB;;AAAoB,iBAA5C,wBAAA,CAA4C;EAAA;AAAA,CAAA,CAAA,EAAA,6BAAA,CAAA,EAAA,IAAA"}