brainerce 1.7.0 → 1.9.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.
@@ -572,21 +572,22 @@ Stores can configure product relations. Use these to boost sales with smart prod
572
572
  ```typescript
573
573
  import type { ProductRecommendationsResponse, CartRecommendationsResponse } from 'brainerce';
574
574
 
575
- // Product page — get upsells + related products
576
- const recs: ProductRecommendationsResponse = await client.getProductRecommendations(product.id);
577
- // recs.upsells premium alternatives (show on product page)
578
- // recs.relatedsimilar products (show at bottom of product page)
579
- // recs.crossSellscomplementary products (typically used on cart page)
575
+ // Product page — recommendations come EMBEDDED in the product response (no extra API call needed)
576
+ const product = await client.getProductBySlug('some-slug');
577
+ const recs = (product as any).recommendations as ProductRecommendationsResponse | undefined;
578
+ // recs?.upsellspremium alternatives (show on product page)
579
+ // recs?.relatedsimilar products (show at bottom of product page)
580
+ // recs?.crossSells — complementary products (typically used on cart page)
580
581
 
581
- // Each recommendation has: id, name, slug, basePrice, salePrice, images, type, inventory
582
+ // Each recommendation has: id, name, slug, basePrice, salePrice, images[], type, inventory
582
583
 
583
- // Cart page — cross-sell suggestions for cart items
584
+ // Cart page — cross-sell suggestions for cart items (separate call, since cart has no embedded recs)
584
585
  const cart = await client.smartGetCart();
585
586
  const cartRecs: CartRecommendationsResponse = await client.getCartRecommendations(cart.id, 4);
586
587
  // cartRecs.recommendations — deduplicated cross-sells (excludes items already in cart)
587
588
 
588
- // Render recommendation cards
589
- {recs.upsells.length > 0 && (
589
+ // Render recommendation cards on product page
590
+ {recs?.upsells && recs.upsells.length > 0 && (
590
591
  <section>
591
592
  <h2>Upgrade Your Choice</h2>
592
593
  <div className="grid grid-cols-2 sm:grid-cols-4 gap-4">
@@ -602,7 +603,7 @@ const cartRecs: CartRecommendationsResponse = await client.getCartRecommendation
602
603
  )}
603
604
  ```
604
605
 
605
- > **Note:** These methods return empty arrays when no relations are configured — the UI just renders nothing. Always build the sections.
606
+ > **Note:** Recommendations return empty arrays when no relations are configured — the UI just renders nothing. Always build the sections. The `getProductRecommendations()` SDK method still works as a fallback for older storefronts.
606
607
 
607
608
  ---
608
609
 
@@ -774,7 +775,7 @@ if (params.get('oauth_success') === 'true') {
774
775
 
775
776
  - [ ] **Home** (`/`) - Featured products grid
776
777
  - [ ] **Products** (`/products`) - Product list with infinite scroll
777
- - [ ] **Product Detail** (`/products/[slug]`) - Use `getProductBySlug(slug)`. Show **upsells** + **related products** via `getProductRecommendations()`
778
+ - [ ] **Product Detail** (`/products/[slug]`) - Use `getProductBySlug(slug)`. Show **upsells** + **related products** from `product.recommendations` (embedded in response)
778
779
  - [ ] **Cart** (`/cart`) - Show items, quantities, totals, **coupon code input**, discount display, **cross-sell recommendations** via `getCartRecommendations()`
779
780
  - [ ] **Checkout** (`/checkout`) - Address → Shipping → Payment. **Show discount in order summary!**
780
781
  - [ ] **Success** (`/checkout/success`) - **Must call `completeGuestCheckout()`!**
@@ -798,7 +799,7 @@ Some features may not be configured yet, but the store owner can enable them at
798
799
  - **Product Discount Badges** → `getProductDiscountBadge(id)` returns `null` — renders nothing.
799
800
  - **Cart Nudges** → `cart.nudges` is `[]` — renders nothing.
800
801
  - **Coupon Input** → Always show in cart. Works even with no coupons configured.
801
- - **Product Recommendations** → Upsells + related on product page, cross-sells on cart page. `getProductRecommendations()` / `getCartRecommendations()` return empty arrays when none configured.
802
+ - **Product Recommendations** → Upsells + related on product page (from `product.recommendations`), cross-sells on cart page (`getCartRecommendations()`). Returns empty arrays when none configured.
802
803
 
803
804
  ---
804
805
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "brainerce",
3
- "version": "1.7.0",
3
+ "version": "1.9.0",
4
4
  "description": "Official SDK for building e-commerce storefronts with Brainerce Platform. Perfect for vibe-coded sites, AI-built stores (Cursor, Lovable, v0), and custom storefronts.",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",