@commercengine/storefront-sdk 0.14.1 → 0.14.3

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/MIGRATION.md CHANGED
@@ -40,6 +40,9 @@ const publicSdk = storefront.public();
40
40
  const sessionSdk = storefront.session();
41
41
  ```
42
42
 
43
+ The factory owns one cached public SDK and one cached default session SDK, so
44
+ most applications only need a single shared `storefront` export.
45
+
43
46
  ## Before / After
44
47
 
45
48
  ### Managed session SDK
package/README.md CHANGED
@@ -5,6 +5,11 @@ A powerful, type-safe TypeScript SDK for the CommerceEngine Storefront API. Buil
5
5
  Breaking changes from the previous SDK surface are documented in
6
6
  [MIGRATION.md](./MIGRATION.md).
7
7
 
8
+ If you are building an application on an official framework wrapper such as
9
+ Next.js, prefer [`@commercengine/storefront`](../storefront/README.md). This
10
+ package is the standalone isomorphic core SDK for SPA usage, advanced custom
11
+ integrations, and framework bindings.
12
+
8
13
  **✨ Key Features:**
9
14
  - **100% Type Safe**: Every API endpoint is fully typed with TypeScript
10
15
  - **Automatic Token Management**: Built-in refresh token logic for seamless authentication
@@ -51,6 +56,11 @@ const { data: products } = await storefront.public().catalog.listProducts();
51
56
  const { data: wishlist } = await storefront.session().cart.getWishlist();
52
57
  ```
53
58
 
59
+ `createStorefront()` returns one cached public SDK and one cached default
60
+ session SDK for that factory instance. Use `storefront.session(overrides)` only
61
+ for one-off, token-seeded/stateless cases that should not reuse the default
62
+ session client.
63
+
54
64
  ## Configuration Options
55
65
 
56
66
  The SDK supports extensive configuration to fit your needs:
@@ -121,6 +131,18 @@ const sdk = new SessionStorefrontSDK({
121
131
  });
122
132
  ```
123
133
 
134
+ If you need the raw public transport classes directly, the advanced exports are
135
+ also available:
136
+
137
+ ```typescript
138
+ import {
139
+ PublicStorefrontAPIClient,
140
+ PublicStorefrontSDK,
141
+ SessionStorefrontAPIClient,
142
+ SessionStorefrontSDK,
143
+ } from "@commercengine/storefront-sdk";
144
+ ```
145
+
124
146
  ## Token Management
125
147
 
126
148
  The SDK supports three primary access patterns:
@@ -210,7 +232,7 @@ import { BrowserTokenStorage } from "@commercengine/storefront-sdk";
210
232
  const tokenStorage = new BrowserTokenStorage("myapp_"); // Optional prefix
211
233
  ```
212
234
 
213
- #### Cookies (for SSR or cross-tab sync)
235
+ #### Browser cookies (for browser persistence or cross-tab sync)
214
236
  ```typescript
215
237
  import { CookieTokenStorage } from "@commercengine/storefront-sdk";
216
238
 
@@ -222,6 +244,12 @@ const tokenStorage = new CookieTokenStorage({
222
244
  });
223
245
  ```
224
246
 
247
+ `CookieTokenStorage` uses `document.cookie` and is browser-only. It is useful
248
+ for browser cookie persistence and cross-tab visibility, but it is **not**
249
+ request-aware SSR storage. For framework server/client continuity, use an
250
+ official wrapper from `@commercengine/storefront` or a request-aware storage
251
+ adapter from `@commercengine/ssr-utils`.
252
+
225
253
  #### Memory (for server-side or temporary storage)
226
254
  ```typescript
227
255
  import { MemoryTokenStorage } from "@commercengine/storefront-sdk";
@@ -246,7 +274,14 @@ class CustomTokenStorage implements TokenStorage {
246
274
 
247
275
  ## Authentication
248
276
 
249
- If you use managed sessions (`tokenStorage`), you usually do not need to call anonymous auth manually. The SDK can bootstrap anonymous sessions automatically on token-required requests.
277
+ If you use managed sessions (`tokenStorage`), you usually do not need to call
278
+ anonymous auth manually. The SDK can bootstrap anonymous sessions
279
+ automatically on token-required requests.
280
+
281
+ That lazy bootstrap is a core SDK capability, not necessarily the primary app
282
+ pattern for every framework. For official framework wrappers, the recommended
283
+ pattern is still to bootstrap explicitly in app code when later server-side
284
+ session reads depend on established cookie continuity.
250
285
 
251
286
  ### Anonymous Authentication
252
287
  ```typescript
@@ -467,10 +502,10 @@ The SDK works seamlessly across all JavaScript environments:
467
502
  - **Background jobs**: Reliable token management for long-running processes
468
503
 
469
504
  ### Hybrid Rendering (SSR/SSG)
470
- - **Next.js, Nuxt, SvelteKit, Remix**: Use request-aware cookie-backed storage
471
- - **CookieTokenStorage**: Useful for browser cookie persistence
472
- - **Cookie-based storage**: Maintains sessions across server/client boundaries
473
- - **Hydration-safe**: No client/server state mismatches
505
+ - **Official framework wrappers**: Prefer `@commercengine/storefront`
506
+ - **Custom SSR integrations**: Use request-aware storage from `@commercengine/ssr-utils`
507
+ - **CookieTokenStorage**: Browser-only cookie persistence, not server request storage
508
+ - **Hydration-safe setups**: depend on framework-aware request storage, not `document.cookie`
474
509
 
475
510
  ## Best Practices Built-In
476
511
 
package/dist/index.d.mts CHANGED
@@ -6528,6 +6528,7 @@ interface components {
6528
6528
  is_default: $Read<boolean>; /** @description This object contains multiple dynamic keys. Each key is a string derived from the attribute key, and the value is an object of the type `AssociatedOption`. */
6529
6529
  associated_options: components["schemas"]["AssociatedOption"];
6530
6530
  images: components["schemas"]["ProductImage"][];
6531
+ videos: components["schemas"]["ProductVideo"][];
6531
6532
  pricing: components["schemas"]["ProductPricing"];
6532
6533
  subscription: components["schemas"]["ProductSubscription"][];
6533
6534
  promotion: components["schemas"]["ProductPromotion"];
@@ -6548,7 +6549,6 @@ interface components {
6548
6549
  variant_options: components["schemas"]["VariantOption"][];
6549
6550
  product_attributes: components["schemas"]["ProductAttribute"][];
6550
6551
  variant_attributes: components["schemas"]["ProductAttribute"][];
6551
- videos: components["schemas"]["ProductVideo"][];
6552
6552
  shipping: components["schemas"]["ProductShipping"];
6553
6553
  seo: components["schemas"]["Seo"];
6554
6554
  metadata: {
@@ -12595,7 +12595,11 @@ type SessionStorefrontClientConfig = StorefrontClientBaseConfig & SessionStorefr
12595
12595
  };
12596
12596
  /**
12597
12597
  * Storefront API client that extends the generic BaseAPIClient
12598
- * Adds Commerce Engine specific authentication and token management
12598
+ * Adds Commerce Engine specific authentication and token management.
12599
+ *
12600
+ * Session-only domain clients can extend this directly. Shared public/session
12601
+ * read clients may instead extend a shared base class and call
12602
+ * `attachSessionAuth()` explicitly in their concrete session wrapper.
12599
12603
  */
12600
12604
  declare class SessionStorefrontAPIClient extends StorefrontAPIClientBase {
12601
12605
  protected config: SessionStorefrontClientConfig;
@@ -13976,8 +13980,9 @@ declare class BaseCatalogClient extends StorefrontAPIClientBase {
13976
13980
  /**
13977
13981
  * Storefront API client that always authenticates with `X-Api-Key`.
13978
13982
  *
13979
- * This client is used by the public storefront surface where no session or
13980
- * token lifecycle should be involved.
13983
+ * This class is kept as the advanced public transport client. Concrete public
13984
+ * domain clients can either extend this directly or extend a shared base class
13985
+ * and attach the same auth behavior via `attachPublicAuth()`.
13981
13986
  */
13982
13987
  declare class PublicStorefrontAPIClient extends StorefrontAPIClientBase {
13983
13988
  constructor(config: StorefrontClientBaseConfig);
@@ -886,7 +886,11 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
886
886
  }
887
887
  /**
888
888
  * Storefront API client that extends the generic BaseAPIClient
889
- * Adds Commerce Engine specific authentication and token management
889
+ * Adds Commerce Engine specific authentication and token management.
890
+ *
891
+ * Session-only domain clients can extend this directly. Shared public/session
892
+ * read clients may instead extend a shared base class and call
893
+ * `attachSessionAuth()` explicitly in their concrete session wrapper.
890
894
  */
891
895
  var SessionStorefrontAPIClient = class extends StorefrontAPIClientBase {
892
896
  config;
@@ -1587,8 +1591,9 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
1587
1591
  /**
1588
1592
  * Storefront API client that always authenticates with `X-Api-Key`.
1589
1593
  *
1590
- * This client is used by the public storefront surface where no session or
1591
- * token lifecycle should be involved.
1594
+ * This class is kept as the advanced public transport client. Concrete public
1595
+ * domain clients can either extend this directly or extend a shared base class
1596
+ * and attach the same auth behavior via `attachPublicAuth()`.
1592
1597
  */
1593
1598
  var PublicStorefrontAPIClient = class extends StorefrontAPIClientBase {
1594
1599
  constructor(config) {