brainerce 1.12.0 → 1.14.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/index.d.mts CHANGED
@@ -1371,10 +1371,19 @@ interface CartItem {
1371
1371
  */
1372
1372
  unitPrice: string;
1373
1373
  /**
1374
- * Discount amount applied to this item as a string.
1374
+ * Discount amount applied to this item as a string (from discount rules).
1375
1375
  * Use parseFloat() for calculations.
1376
1376
  */
1377
1377
  discountAmount: string;
1378
+ /**
1379
+ * Promo discount amount from bundle offers or order bumps as a string.
1380
+ * Use parseFloat() for calculations.
1381
+ */
1382
+ promoDiscountAmount: string;
1383
+ /** Promo source: "BUNDLE" or "ORDER_BUMP", null if no promo */
1384
+ promoSource?: string | null;
1385
+ /** ID of the BundleOffer or OrderBumpConfig that gave this discount */
1386
+ promoSourceId?: string | null;
1378
1387
  /** Optional notes for this line item */
1379
1388
  notes?: string | null;
1380
1389
  /** Optional metadata for this line item */
@@ -1459,6 +1468,8 @@ interface Cart {
1459
1468
  couponCode?: string | null;
1460
1469
  /** Discount amount from automatic rules only (before coupon) */
1461
1470
  ruleDiscountAmount?: string;
1471
+ /** Total promo discount from bundle offers and order bumps */
1472
+ promoDiscountTotal?: string;
1462
1473
  /** Automatic discounts applied by discount rules */
1463
1474
  appliedDiscounts?: CartAppliedDiscount[];
1464
1475
  /** Nudges for nearly-qualifying discount rules */
@@ -2443,8 +2454,8 @@ interface CustomApiTestResult {
2443
2454
  * The frontend dynamically loads the SDK script and calls init/render methods.
2444
2455
  */
2445
2456
  interface PaymentClientSdk {
2446
- /** How the payment UI is rendered: 'sdk-widget' (JS SDK), 'iframe', or 'redirect' */
2447
- renderType: 'sdk-widget' | 'iframe' | 'redirect';
2457
+ /** How the payment UI is rendered: 'sdk-widget' (JS SDK), 'iframe', 'redirect', or 'sandbox' (test orders) */
2458
+ renderType: 'sdk-widget' | 'iframe' | 'redirect' | 'sandbox';
2448
2459
  /** URL of the main SDK script to load */
2449
2460
  scriptUrl?: string;
2450
2461
  /** Name of the global variable set by the SDK script (e.g., 'growPayment') */
@@ -4917,6 +4928,28 @@ declare class BrainerceClient {
4917
4928
  * @returns Updated cart
4918
4929
  */
4919
4930
  removeOrderBump(cartId: string, bumpConfigId: string): Promise<Cart>;
4931
+ /**
4932
+ * Add a bundle offer product to the cart with its discount applied.
4933
+ *
4934
+ * @param cartId - Cart ID
4935
+ * @param bundleOfferId - Bundle offer ID
4936
+ * @returns Updated cart
4937
+ *
4938
+ * @example
4939
+ * ```typescript
4940
+ * const { bundles } = await client.getCartBundles('cart_123');
4941
+ * const cart = await client.addBundleToCart('cart_123', bundles[0].id);
4942
+ * ```
4943
+ */
4944
+ addBundleToCart(cartId: string, bundleOfferId: string): Promise<Cart>;
4945
+ /**
4946
+ * Remove a bundle offer product from the cart.
4947
+ *
4948
+ * @param cartId - Cart ID
4949
+ * @param bundleOfferId - Bundle offer ID
4950
+ * @returns Updated cart
4951
+ */
4952
+ removeBundleFromCart(cartId: string, bundleOfferId: string): Promise<Cart>;
4920
4953
  /**
4921
4954
  * Check if customer is currently authenticated
4922
4955
  * Used internally by smart cart methods to determine storage strategy
package/dist/index.d.ts CHANGED
@@ -1371,10 +1371,19 @@ interface CartItem {
1371
1371
  */
1372
1372
  unitPrice: string;
1373
1373
  /**
1374
- * Discount amount applied to this item as a string.
1374
+ * Discount amount applied to this item as a string (from discount rules).
1375
1375
  * Use parseFloat() for calculations.
1376
1376
  */
1377
1377
  discountAmount: string;
1378
+ /**
1379
+ * Promo discount amount from bundle offers or order bumps as a string.
1380
+ * Use parseFloat() for calculations.
1381
+ */
1382
+ promoDiscountAmount: string;
1383
+ /** Promo source: "BUNDLE" or "ORDER_BUMP", null if no promo */
1384
+ promoSource?: string | null;
1385
+ /** ID of the BundleOffer or OrderBumpConfig that gave this discount */
1386
+ promoSourceId?: string | null;
1378
1387
  /** Optional notes for this line item */
1379
1388
  notes?: string | null;
1380
1389
  /** Optional metadata for this line item */
@@ -1459,6 +1468,8 @@ interface Cart {
1459
1468
  couponCode?: string | null;
1460
1469
  /** Discount amount from automatic rules only (before coupon) */
1461
1470
  ruleDiscountAmount?: string;
1471
+ /** Total promo discount from bundle offers and order bumps */
1472
+ promoDiscountTotal?: string;
1462
1473
  /** Automatic discounts applied by discount rules */
1463
1474
  appliedDiscounts?: CartAppliedDiscount[];
1464
1475
  /** Nudges for nearly-qualifying discount rules */
@@ -2443,8 +2454,8 @@ interface CustomApiTestResult {
2443
2454
  * The frontend dynamically loads the SDK script and calls init/render methods.
2444
2455
  */
2445
2456
  interface PaymentClientSdk {
2446
- /** How the payment UI is rendered: 'sdk-widget' (JS SDK), 'iframe', or 'redirect' */
2447
- renderType: 'sdk-widget' | 'iframe' | 'redirect';
2457
+ /** How the payment UI is rendered: 'sdk-widget' (JS SDK), 'iframe', 'redirect', or 'sandbox' (test orders) */
2458
+ renderType: 'sdk-widget' | 'iframe' | 'redirect' | 'sandbox';
2448
2459
  /** URL of the main SDK script to load */
2449
2460
  scriptUrl?: string;
2450
2461
  /** Name of the global variable set by the SDK script (e.g., 'growPayment') */
@@ -4917,6 +4928,28 @@ declare class BrainerceClient {
4917
4928
  * @returns Updated cart
4918
4929
  */
4919
4930
  removeOrderBump(cartId: string, bumpConfigId: string): Promise<Cart>;
4931
+ /**
4932
+ * Add a bundle offer product to the cart with its discount applied.
4933
+ *
4934
+ * @param cartId - Cart ID
4935
+ * @param bundleOfferId - Bundle offer ID
4936
+ * @returns Updated cart
4937
+ *
4938
+ * @example
4939
+ * ```typescript
4940
+ * const { bundles } = await client.getCartBundles('cart_123');
4941
+ * const cart = await client.addBundleToCart('cart_123', bundles[0].id);
4942
+ * ```
4943
+ */
4944
+ addBundleToCart(cartId: string, bundleOfferId: string): Promise<Cart>;
4945
+ /**
4946
+ * Remove a bundle offer product from the cart.
4947
+ *
4948
+ * @param cartId - Cart ID
4949
+ * @param bundleOfferId - Bundle offer ID
4950
+ * @returns Updated cart
4951
+ */
4952
+ removeBundleFromCart(cartId: string, bundleOfferId: string): Promise<Cart>;
4920
4953
  /**
4921
4954
  * Check if customer is currently authenticated
4922
4955
  * Used internally by smart cart methods to determine storage strategy
package/dist/index.js CHANGED
@@ -2519,6 +2519,44 @@ var BrainerceClient = class {
2519
2519
  }
2520
2520
  throw new BrainerceError("removeOrderBump() requires vibe-coded or storefront mode", 400);
2521
2521
  }
2522
+ /**
2523
+ * Add a bundle offer product to the cart with its discount applied.
2524
+ *
2525
+ * @param cartId - Cart ID
2526
+ * @param bundleOfferId - Bundle offer ID
2527
+ * @returns Updated cart
2528
+ *
2529
+ * @example
2530
+ * ```typescript
2531
+ * const { bundles } = await client.getCartBundles('cart_123');
2532
+ * const cart = await client.addBundleToCart('cart_123', bundles[0].id);
2533
+ * ```
2534
+ */
2535
+ async addBundleToCart(cartId, bundleOfferId) {
2536
+ if (this.isVibeCodedMode()) {
2537
+ return this.vibeCodedRequest("POST", `/cart/${cartId}/bundle`, { bundleOfferId });
2538
+ }
2539
+ if (this.storeId && !this.apiKey) {
2540
+ return this.storefrontRequest("POST", `/cart/${cartId}/bundle`, { bundleOfferId });
2541
+ }
2542
+ throw new BrainerceError("addBundleToCart() requires vibe-coded or storefront mode", 400);
2543
+ }
2544
+ /**
2545
+ * Remove a bundle offer product from the cart.
2546
+ *
2547
+ * @param cartId - Cart ID
2548
+ * @param bundleOfferId - Bundle offer ID
2549
+ * @returns Updated cart
2550
+ */
2551
+ async removeBundleFromCart(cartId, bundleOfferId) {
2552
+ if (this.isVibeCodedMode()) {
2553
+ return this.vibeCodedRequest("DELETE", `/cart/${cartId}/bundle/${bundleOfferId}`);
2554
+ }
2555
+ if (this.storeId && !this.apiKey) {
2556
+ return this.storefrontRequest("DELETE", `/cart/${cartId}/bundle/${bundleOfferId}`);
2557
+ }
2558
+ throw new BrainerceError("removeBundleFromCart() requires vibe-coded or storefront mode", 400);
2559
+ }
2522
2560
  // -------------------- Smart Cart (Auto-sync) --------------------
2523
2561
  /**
2524
2562
  * Check if customer is currently authenticated
@@ -3822,6 +3860,9 @@ var BrainerceClient = class {
3822
3860
  quantity: item.quantity,
3823
3861
  unitPrice: item.price || "0",
3824
3862
  discountAmount: "0",
3863
+ promoDiscountAmount: "0",
3864
+ promoSource: null,
3865
+ promoSourceId: null,
3825
3866
  notes: null,
3826
3867
  metadata: null,
3827
3868
  product: {
package/dist/index.mjs CHANGED
@@ -2459,6 +2459,44 @@ var BrainerceClient = class {
2459
2459
  }
2460
2460
  throw new BrainerceError("removeOrderBump() requires vibe-coded or storefront mode", 400);
2461
2461
  }
2462
+ /**
2463
+ * Add a bundle offer product to the cart with its discount applied.
2464
+ *
2465
+ * @param cartId - Cart ID
2466
+ * @param bundleOfferId - Bundle offer ID
2467
+ * @returns Updated cart
2468
+ *
2469
+ * @example
2470
+ * ```typescript
2471
+ * const { bundles } = await client.getCartBundles('cart_123');
2472
+ * const cart = await client.addBundleToCart('cart_123', bundles[0].id);
2473
+ * ```
2474
+ */
2475
+ async addBundleToCart(cartId, bundleOfferId) {
2476
+ if (this.isVibeCodedMode()) {
2477
+ return this.vibeCodedRequest("POST", `/cart/${cartId}/bundle`, { bundleOfferId });
2478
+ }
2479
+ if (this.storeId && !this.apiKey) {
2480
+ return this.storefrontRequest("POST", `/cart/${cartId}/bundle`, { bundleOfferId });
2481
+ }
2482
+ throw new BrainerceError("addBundleToCart() requires vibe-coded or storefront mode", 400);
2483
+ }
2484
+ /**
2485
+ * Remove a bundle offer product from the cart.
2486
+ *
2487
+ * @param cartId - Cart ID
2488
+ * @param bundleOfferId - Bundle offer ID
2489
+ * @returns Updated cart
2490
+ */
2491
+ async removeBundleFromCart(cartId, bundleOfferId) {
2492
+ if (this.isVibeCodedMode()) {
2493
+ return this.vibeCodedRequest("DELETE", `/cart/${cartId}/bundle/${bundleOfferId}`);
2494
+ }
2495
+ if (this.storeId && !this.apiKey) {
2496
+ return this.storefrontRequest("DELETE", `/cart/${cartId}/bundle/${bundleOfferId}`);
2497
+ }
2498
+ throw new BrainerceError("removeBundleFromCart() requires vibe-coded or storefront mode", 400);
2499
+ }
2462
2500
  // -------------------- Smart Cart (Auto-sync) --------------------
2463
2501
  /**
2464
2502
  * Check if customer is currently authenticated
@@ -3762,6 +3800,9 @@ var BrainerceClient = class {
3762
3800
  quantity: item.quantity,
3763
3801
  unitPrice: item.price || "0",
3764
3802
  discountAmount: "0",
3803
+ promoDiscountAmount: "0",
3804
+ promoSource: null,
3805
+ promoSourceId: null,
3765
3806
  notes: null,
3766
3807
  metadata: null,
3767
3808
  product: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "brainerce",
3
- "version": "1.12.0",
3
+ "version": "1.14.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",