brainerce 1.0.1 → 1.0.2

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
@@ -3362,9 +3362,15 @@ declare class BrainerceClient {
3362
3362
  private readonly timeout;
3363
3363
  private customerToken;
3364
3364
  private customerCartId;
3365
+ private sessionCartId;
3366
+ private sessionToken;
3367
+ private _sessionCartPromise;
3368
+ private _migrationDone;
3369
+ /** localStorage key for session cart reference (sessionToken + cartId) */
3370
+ private readonly SESSION_CART_KEY;
3365
3371
  /**
3366
3372
  * Virtual cart ID used for localStorage carts (guest users not logged in).
3367
- * When a cart has this ID, operations use localStorage instead of server API.
3373
+ * @deprecated Guest carts now use server-side sessions. Kept for backward compatibility.
3368
3374
  */
3369
3375
  private readonly VIRTUAL_LOCAL_CART_ID;
3370
3376
  /**
@@ -4585,6 +4591,64 @@ declare class BrainerceClient {
4585
4591
  * ```
4586
4592
  */
4587
4593
  isCustomerLoggedIn(): boolean;
4594
+ /**
4595
+ * Hydrate session cart state from localStorage on construction.
4596
+ * @internal
4597
+ */
4598
+ private hydrateSessionCart;
4599
+ /**
4600
+ * Persist session cart reference to localStorage.
4601
+ * @internal
4602
+ */
4603
+ private saveSessionCart;
4604
+ /**
4605
+ * Clear session cart reference from localStorage and memory.
4606
+ * @internal
4607
+ */
4608
+ private clearSessionCart;
4609
+ /**
4610
+ * Update the cached item count in the session reference.
4611
+ * @internal
4612
+ */
4613
+ private updateSessionCartItemCount;
4614
+ /**
4615
+ * Return a synthetic empty Cart object for display when no server cart exists yet.
4616
+ * Avoids creating a server cart just to show "your cart is empty."
4617
+ * @internal
4618
+ */
4619
+ private emptyCart;
4620
+ /**
4621
+ * Create a server-side cart via API. Never falls back to localStorage.
4622
+ * @internal
4623
+ */
4624
+ private createServerCart;
4625
+ /**
4626
+ * Get or create a server-side session cart for guest users.
4627
+ * Lazily creates the cart on first call (e.g., first add-to-cart).
4628
+ * Uses promise dedup lock to prevent race conditions on parallel calls.
4629
+ * @internal
4630
+ */
4631
+ private getOrCreateSessionCart;
4632
+ /** @internal */
4633
+ private _getOrCreateSessionCartImpl;
4634
+ /**
4635
+ * Migrate legacy localStorage cart to server session cart.
4636
+ * Called once, on first smart method call if migration is needed.
4637
+ * @internal
4638
+ */
4639
+ private migrateLocalCartToSession;
4640
+ /**
4641
+ * Merge the guest session cart into the customer's cart on the server.
4642
+ * Tries linkCart first (fast, single call), falls back to mergeCarts endpoint.
4643
+ * @internal
4644
+ */
4645
+ private mergeSessionCartOnLogin;
4646
+ /**
4647
+ * Get the cart item count without a full cart fetch.
4648
+ * Returns the cached count from localStorage if available, or 0.
4649
+ * For accurate counts, use smartGetCart() and read cart.itemCount.
4650
+ */
4651
+ getSmartCartItemCount(): number;
4588
4652
  /**
4589
4653
  * Get or create a server cart for the logged-in customer
4590
4654
  * Caches the cart ID for subsequent calls
@@ -4597,10 +4661,10 @@ declare class BrainerceClient {
4597
4661
  */
4598
4662
  private fetchCustomerCart;
4599
4663
  /**
4600
- * Smart add to cart - automatically uses localStorage or server based on auth state
4664
+ * Smart add to cart - automatically uses the correct cart based on auth state
4601
4665
  *
4602
- * - **Guest (not logged in)**: Stores in localStorage
4603
- * - **Logged in**: Stores on server (database)
4666
+ * - **Logged in**: Uses customer's server cart
4667
+ * - **Guest**: Uses server-side session cart (creates one if needed)
4604
4668
  *
4605
4669
  * @example
4606
4670
  * ```typescript
@@ -4608,14 +4672,20 @@ declare class BrainerceClient {
4608
4672
  * await client.smartAddToCart({
4609
4673
  * productId: 'prod_123',
4610
4674
  * quantity: 2,
4611
- * name: 'Cool Product', // Optional: for localStorage display
4612
- * price: '29.99',
4613
4675
  * });
4614
4676
  * ```
4615
4677
  */
4616
- smartAddToCart(item: Omit<LocalCartItem, 'addedAt'>): Promise<Cart | LocalCart>;
4678
+ smartAddToCart(item: {
4679
+ productId: string;
4680
+ variantId?: string;
4681
+ quantity: number;
4682
+ }): Promise<Cart>;
4617
4683
  /**
4618
- * Smart get cart - returns server cart if logged in, localStorage if guest
4684
+ * Smart get cart - returns the current cart (server-side for both guests and logged-in users)
4685
+ *
4686
+ * - **Logged in**: Returns customer's server cart
4687
+ * - **Guest with session**: Returns server-side session cart
4688
+ * - **Guest without session**: Returns empty cart (no server call, cart created lazily on add)
4619
4689
  *
4620
4690
  * @example
4621
4691
  * ```typescript
@@ -4623,7 +4693,7 @@ declare class BrainerceClient {
4623
4693
  * console.log('Items:', cart.items.length);
4624
4694
  * ```
4625
4695
  */
4626
- smartGetCart(): Promise<Cart | LocalCart>;
4696
+ smartGetCart(): Promise<Cart>;
4627
4697
  /**
4628
4698
  * Smart update cart item quantity
4629
4699
  *
@@ -4633,7 +4703,7 @@ declare class BrainerceClient {
4633
4703
  * await client.smartUpdateCartItem('prod_123', 0); // Remove item
4634
4704
  * ```
4635
4705
  */
4636
- smartUpdateCartItem(productId: string, quantity: number, variantId?: string): Promise<Cart | LocalCart>;
4706
+ smartUpdateCartItem(productId: string, quantity: number, variantId?: string): Promise<Cart>;
4637
4707
  /**
4638
4708
  * Smart remove from cart
4639
4709
  *
@@ -4643,17 +4713,15 @@ declare class BrainerceClient {
4643
4713
  * await client.smartRemoveFromCart('prod_456', 'variant_789');
4644
4714
  * ```
4645
4715
  */
4646
- smartRemoveFromCart(productId: string, variantId?: string): Promise<Cart | LocalCart>;
4716
+ smartRemoveFromCart(productId: string, variantId?: string): Promise<Cart>;
4647
4717
  /**
4648
- * Sync local cart to server on login
4718
+ * Sync guest cart to customer cart on login
4649
4719
  *
4650
4720
  * Call this AFTER setCustomerToken() when a customer logs in.
4651
4721
  * This will:
4652
- * 1. Get or create a server cart for the customer
4653
- * 2. Add all items from localStorage to the server cart (merging with existing)
4654
- * 3. Clear localStorage
4655
- *
4656
- * Items that fail to sync (e.g., out of stock) are silently skipped.
4722
+ * 1. If a server-side session cart exists, merge it into the customer cart (atomic, server-side)
4723
+ * 2. If only a legacy localStorage cart exists, sync items one by one (backward compat)
4724
+ * 3. Clear the session/localStorage after merge
4657
4725
  *
4658
4726
  * @example
4659
4727
  * ```typescript
@@ -4661,7 +4729,7 @@ declare class BrainerceClient {
4661
4729
  * const auth = await client.login(email, password);
4662
4730
  * client.setCustomerToken(auth.token);
4663
4731
  *
4664
- * // Sync their local cart to server
4732
+ * // Merge their guest cart into customer cart
4665
4733
  * const cart = await client.syncCartOnLogin();
4666
4734
  * console.log('Cart synced, items:', cart.items.length);
4667
4735
  * ```
@@ -4670,15 +4738,15 @@ declare class BrainerceClient {
4670
4738
  /**
4671
4739
  * Clear cart state on logout
4672
4740
  *
4673
- * Call this when a customer logs out to clear the cached cart ID.
4674
- * The localStorage cart remains available for the next guest session.
4741
+ * Call this when a customer logs out to clear the cached customer cart ID.
4742
+ * The session cart (if any) remains available for the next guest session.
4675
4743
  *
4676
4744
  * @example
4677
4745
  * ```typescript
4678
4746
  * client.clearCustomerToken();
4679
4747
  * client.onLogout();
4680
4748
  *
4681
- * // Now back to guest mode - cart uses localStorage
4749
+ * // Now back to guest mode - cart uses server-side session
4682
4750
  * await client.smartAddToCart({ productId: 'prod_123', quantity: 1 });
4683
4751
  * ```
4684
4752
  */
@@ -4694,7 +4762,6 @@ declare class BrainerceClient {
4694
4762
  * // After payment success
4695
4763
  * if (paymentStatus === 'succeeded') {
4696
4764
  * client.onCheckoutComplete();
4697
- * client.clearLocalCart(); // Also clear localStorage for guests
4698
4765
  * }
4699
4766
  * ```
4700
4767
  */
@@ -5016,14 +5083,8 @@ declare class BrainerceClient {
5016
5083
  */
5017
5084
  private isLocalStorageAvailable;
5018
5085
  /**
5019
- * Get local cart from localStorage
5020
- * Returns empty cart if none exists
5021
- *
5022
- * @example
5023
- * ```typescript
5024
- * const cart = client.getLocalCart();
5025
- * console.log('Items in cart:', cart.items.length);
5026
- * ```
5086
+ * @deprecated Use `smartGetCart()` instead. Guest carts are now stored on the server.
5087
+ * Get local cart from localStorage. Returns empty cart if none exists.
5027
5088
  */
5028
5089
  getLocalCart(): LocalCart;
5029
5090
  /**
@@ -5041,89 +5102,44 @@ declare class BrainerceClient {
5041
5102
  */
5042
5103
  private localCartToCart;
5043
5104
  /**
5044
- * Add item to local cart (NO API call)
5045
- * If item already exists, updates quantity
5046
- *
5047
- * @example
5048
- * ```typescript
5049
- * client.addToLocalCart({
5050
- * productId: 'prod_123',
5051
- * quantity: 2,
5052
- * name: 'Cool Shirt',
5053
- * price: '29.99',
5054
- * });
5055
- * ```
5105
+ * @deprecated Use `smartAddToCart()` instead. Guest carts are now stored on the server.
5106
+ * Add item to local cart (NO API call). If item already exists, updates quantity.
5056
5107
  */
5057
5108
  addToLocalCart(item: Omit<LocalCartItem, 'addedAt'>): LocalCart;
5058
5109
  /**
5059
- * Update item quantity in local cart
5060
- * Set quantity to 0 to remove item
5061
- *
5062
- * @example
5063
- * ```typescript
5064
- * client.updateLocalCartItem('prod_123', 3); // Set quantity to 3
5065
- * client.updateLocalCartItem('prod_123', 0); // Remove item
5066
- * ```
5110
+ * @deprecated Use `smartUpdateCartItem()` instead. Guest carts are now stored on the server.
5111
+ * Update item quantity in local cart. Set quantity to 0 to remove item.
5067
5112
  */
5068
5113
  updateLocalCartItem(productId: string, quantity: number, variantId?: string): LocalCart;
5069
5114
  /**
5070
- * Remove item from local cart
5071
- *
5072
- * @example
5073
- * ```typescript
5074
- * client.removeFromLocalCart('prod_123');
5075
- * client.removeFromLocalCart('prod_456', 'variant_789');
5076
- * ```
5115
+ * @deprecated Use `smartRemoveFromCart()` instead. Guest carts are now stored on the server.
5077
5116
  */
5078
5117
  removeFromLocalCart(productId: string, variantId?: string): LocalCart;
5079
5118
  /**
5080
- * Clear all items from local cart
5081
- *
5082
- * @example
5083
- * ```typescript
5084
- * client.clearLocalCart();
5085
- * ```
5119
+ * @deprecated Use `onCheckoutComplete()` instead. Guest carts are now stored on the server.
5086
5120
  */
5087
5121
  clearLocalCart(): LocalCart;
5088
5122
  /**
5089
- * Set customer info on local cart
5090
- *
5091
- * @example
5092
- * ```typescript
5093
- * client.setLocalCartCustomer({
5094
- * email: 'john@example.com',
5095
- * firstName: 'John',
5096
- * lastName: 'Doe',
5097
- * });
5098
- * ```
5123
+ * @deprecated Customer info is now set via checkout address methods.
5124
+ * Still used by `submitGuestOrder()` for backward compatibility.
5099
5125
  */
5100
5126
  setLocalCartCustomer(customer: LocalCart['customer']): LocalCart;
5101
5127
  /**
5102
- * Set shipping address on local cart
5103
- *
5104
- * @example
5105
- * ```typescript
5106
- * client.setLocalCartShippingAddress({
5107
- * firstName: 'John',
5108
- * lastName: 'Doe',
5109
- * line1: '123 Main St',
5110
- * city: 'Tel Aviv',
5111
- * postalCode: '6100000',
5112
- * country: 'IL',
5113
- * });
5114
- * ```
5128
+ * @deprecated Address is now set via `updateGuestCheckoutAddress()` after `startGuestCheckout()`.
5129
+ * Still used by `submitGuestOrder()` for backward compatibility.
5115
5130
  */
5116
5131
  setLocalCartShippingAddress(address: LocalCart['shippingAddress']): LocalCart;
5117
5132
  /**
5118
- * Set billing address on local cart
5133
+ * @deprecated Address is now set via `updateGuestCheckoutAddress()` after `startGuestCheckout()`.
5134
+ * Still used by `submitGuestOrder()` for backward compatibility.
5119
5135
  */
5120
5136
  setLocalCartBillingAddress(address: LocalCart['billingAddress']): LocalCart;
5121
5137
  /**
5122
- * Set coupon code on local cart
5138
+ * @deprecated Coupons are now applied via `applyCoupon()` on the server cart.
5123
5139
  */
5124
5140
  setLocalCartCoupon(couponCode: string | undefined): LocalCart;
5125
5141
  /**
5126
- * Get total items count in local cart
5142
+ * @deprecated Use `getSmartCartItemCount()` instead.
5127
5143
  */
5128
5144
  getLocalCartItemCount(): number;
5129
5145
  /**
@@ -5222,16 +5238,8 @@ declare class BrainerceClient {
5222
5238
  */
5223
5239
  private clearActiveCheckoutStorage;
5224
5240
  /**
5241
+ * @deprecated Partial checkout is now handled server-side via `selectedItemIds`.
5225
5242
  * Remove specific items from local cart by their indices.
5226
- * Use after partial checkout to remove only the purchased items.
5227
- *
5228
- * @param indices - Array of item indices to remove
5229
- *
5230
- * @example
5231
- * ```typescript
5232
- * // After partial checkout success, remove purchased items
5233
- * client.removeLocalCartItemsByIndex([0, 2]); // Removes items at index 0 and 2
5234
- * ```
5235
5243
  */
5236
5244
  removeLocalCartItemsByIndex(indices: number[]): void;
5237
5245
  /**
package/dist/index.d.ts CHANGED
@@ -3362,9 +3362,15 @@ declare class BrainerceClient {
3362
3362
  private readonly timeout;
3363
3363
  private customerToken;
3364
3364
  private customerCartId;
3365
+ private sessionCartId;
3366
+ private sessionToken;
3367
+ private _sessionCartPromise;
3368
+ private _migrationDone;
3369
+ /** localStorage key for session cart reference (sessionToken + cartId) */
3370
+ private readonly SESSION_CART_KEY;
3365
3371
  /**
3366
3372
  * Virtual cart ID used for localStorage carts (guest users not logged in).
3367
- * When a cart has this ID, operations use localStorage instead of server API.
3373
+ * @deprecated Guest carts now use server-side sessions. Kept for backward compatibility.
3368
3374
  */
3369
3375
  private readonly VIRTUAL_LOCAL_CART_ID;
3370
3376
  /**
@@ -4585,6 +4591,64 @@ declare class BrainerceClient {
4585
4591
  * ```
4586
4592
  */
4587
4593
  isCustomerLoggedIn(): boolean;
4594
+ /**
4595
+ * Hydrate session cart state from localStorage on construction.
4596
+ * @internal
4597
+ */
4598
+ private hydrateSessionCart;
4599
+ /**
4600
+ * Persist session cart reference to localStorage.
4601
+ * @internal
4602
+ */
4603
+ private saveSessionCart;
4604
+ /**
4605
+ * Clear session cart reference from localStorage and memory.
4606
+ * @internal
4607
+ */
4608
+ private clearSessionCart;
4609
+ /**
4610
+ * Update the cached item count in the session reference.
4611
+ * @internal
4612
+ */
4613
+ private updateSessionCartItemCount;
4614
+ /**
4615
+ * Return a synthetic empty Cart object for display when no server cart exists yet.
4616
+ * Avoids creating a server cart just to show "your cart is empty."
4617
+ * @internal
4618
+ */
4619
+ private emptyCart;
4620
+ /**
4621
+ * Create a server-side cart via API. Never falls back to localStorage.
4622
+ * @internal
4623
+ */
4624
+ private createServerCart;
4625
+ /**
4626
+ * Get or create a server-side session cart for guest users.
4627
+ * Lazily creates the cart on first call (e.g., first add-to-cart).
4628
+ * Uses promise dedup lock to prevent race conditions on parallel calls.
4629
+ * @internal
4630
+ */
4631
+ private getOrCreateSessionCart;
4632
+ /** @internal */
4633
+ private _getOrCreateSessionCartImpl;
4634
+ /**
4635
+ * Migrate legacy localStorage cart to server session cart.
4636
+ * Called once, on first smart method call if migration is needed.
4637
+ * @internal
4638
+ */
4639
+ private migrateLocalCartToSession;
4640
+ /**
4641
+ * Merge the guest session cart into the customer's cart on the server.
4642
+ * Tries linkCart first (fast, single call), falls back to mergeCarts endpoint.
4643
+ * @internal
4644
+ */
4645
+ private mergeSessionCartOnLogin;
4646
+ /**
4647
+ * Get the cart item count without a full cart fetch.
4648
+ * Returns the cached count from localStorage if available, or 0.
4649
+ * For accurate counts, use smartGetCart() and read cart.itemCount.
4650
+ */
4651
+ getSmartCartItemCount(): number;
4588
4652
  /**
4589
4653
  * Get or create a server cart for the logged-in customer
4590
4654
  * Caches the cart ID for subsequent calls
@@ -4597,10 +4661,10 @@ declare class BrainerceClient {
4597
4661
  */
4598
4662
  private fetchCustomerCart;
4599
4663
  /**
4600
- * Smart add to cart - automatically uses localStorage or server based on auth state
4664
+ * Smart add to cart - automatically uses the correct cart based on auth state
4601
4665
  *
4602
- * - **Guest (not logged in)**: Stores in localStorage
4603
- * - **Logged in**: Stores on server (database)
4666
+ * - **Logged in**: Uses customer's server cart
4667
+ * - **Guest**: Uses server-side session cart (creates one if needed)
4604
4668
  *
4605
4669
  * @example
4606
4670
  * ```typescript
@@ -4608,14 +4672,20 @@ declare class BrainerceClient {
4608
4672
  * await client.smartAddToCart({
4609
4673
  * productId: 'prod_123',
4610
4674
  * quantity: 2,
4611
- * name: 'Cool Product', // Optional: for localStorage display
4612
- * price: '29.99',
4613
4675
  * });
4614
4676
  * ```
4615
4677
  */
4616
- smartAddToCart(item: Omit<LocalCartItem, 'addedAt'>): Promise<Cart | LocalCart>;
4678
+ smartAddToCart(item: {
4679
+ productId: string;
4680
+ variantId?: string;
4681
+ quantity: number;
4682
+ }): Promise<Cart>;
4617
4683
  /**
4618
- * Smart get cart - returns server cart if logged in, localStorage if guest
4684
+ * Smart get cart - returns the current cart (server-side for both guests and logged-in users)
4685
+ *
4686
+ * - **Logged in**: Returns customer's server cart
4687
+ * - **Guest with session**: Returns server-side session cart
4688
+ * - **Guest without session**: Returns empty cart (no server call, cart created lazily on add)
4619
4689
  *
4620
4690
  * @example
4621
4691
  * ```typescript
@@ -4623,7 +4693,7 @@ declare class BrainerceClient {
4623
4693
  * console.log('Items:', cart.items.length);
4624
4694
  * ```
4625
4695
  */
4626
- smartGetCart(): Promise<Cart | LocalCart>;
4696
+ smartGetCart(): Promise<Cart>;
4627
4697
  /**
4628
4698
  * Smart update cart item quantity
4629
4699
  *
@@ -4633,7 +4703,7 @@ declare class BrainerceClient {
4633
4703
  * await client.smartUpdateCartItem('prod_123', 0); // Remove item
4634
4704
  * ```
4635
4705
  */
4636
- smartUpdateCartItem(productId: string, quantity: number, variantId?: string): Promise<Cart | LocalCart>;
4706
+ smartUpdateCartItem(productId: string, quantity: number, variantId?: string): Promise<Cart>;
4637
4707
  /**
4638
4708
  * Smart remove from cart
4639
4709
  *
@@ -4643,17 +4713,15 @@ declare class BrainerceClient {
4643
4713
  * await client.smartRemoveFromCart('prod_456', 'variant_789');
4644
4714
  * ```
4645
4715
  */
4646
- smartRemoveFromCart(productId: string, variantId?: string): Promise<Cart | LocalCart>;
4716
+ smartRemoveFromCart(productId: string, variantId?: string): Promise<Cart>;
4647
4717
  /**
4648
- * Sync local cart to server on login
4718
+ * Sync guest cart to customer cart on login
4649
4719
  *
4650
4720
  * Call this AFTER setCustomerToken() when a customer logs in.
4651
4721
  * This will:
4652
- * 1. Get or create a server cart for the customer
4653
- * 2. Add all items from localStorage to the server cart (merging with existing)
4654
- * 3. Clear localStorage
4655
- *
4656
- * Items that fail to sync (e.g., out of stock) are silently skipped.
4722
+ * 1. If a server-side session cart exists, merge it into the customer cart (atomic, server-side)
4723
+ * 2. If only a legacy localStorage cart exists, sync items one by one (backward compat)
4724
+ * 3. Clear the session/localStorage after merge
4657
4725
  *
4658
4726
  * @example
4659
4727
  * ```typescript
@@ -4661,7 +4729,7 @@ declare class BrainerceClient {
4661
4729
  * const auth = await client.login(email, password);
4662
4730
  * client.setCustomerToken(auth.token);
4663
4731
  *
4664
- * // Sync their local cart to server
4732
+ * // Merge their guest cart into customer cart
4665
4733
  * const cart = await client.syncCartOnLogin();
4666
4734
  * console.log('Cart synced, items:', cart.items.length);
4667
4735
  * ```
@@ -4670,15 +4738,15 @@ declare class BrainerceClient {
4670
4738
  /**
4671
4739
  * Clear cart state on logout
4672
4740
  *
4673
- * Call this when a customer logs out to clear the cached cart ID.
4674
- * The localStorage cart remains available for the next guest session.
4741
+ * Call this when a customer logs out to clear the cached customer cart ID.
4742
+ * The session cart (if any) remains available for the next guest session.
4675
4743
  *
4676
4744
  * @example
4677
4745
  * ```typescript
4678
4746
  * client.clearCustomerToken();
4679
4747
  * client.onLogout();
4680
4748
  *
4681
- * // Now back to guest mode - cart uses localStorage
4749
+ * // Now back to guest mode - cart uses server-side session
4682
4750
  * await client.smartAddToCart({ productId: 'prod_123', quantity: 1 });
4683
4751
  * ```
4684
4752
  */
@@ -4694,7 +4762,6 @@ declare class BrainerceClient {
4694
4762
  * // After payment success
4695
4763
  * if (paymentStatus === 'succeeded') {
4696
4764
  * client.onCheckoutComplete();
4697
- * client.clearLocalCart(); // Also clear localStorage for guests
4698
4765
  * }
4699
4766
  * ```
4700
4767
  */
@@ -5016,14 +5083,8 @@ declare class BrainerceClient {
5016
5083
  */
5017
5084
  private isLocalStorageAvailable;
5018
5085
  /**
5019
- * Get local cart from localStorage
5020
- * Returns empty cart if none exists
5021
- *
5022
- * @example
5023
- * ```typescript
5024
- * const cart = client.getLocalCart();
5025
- * console.log('Items in cart:', cart.items.length);
5026
- * ```
5086
+ * @deprecated Use `smartGetCart()` instead. Guest carts are now stored on the server.
5087
+ * Get local cart from localStorage. Returns empty cart if none exists.
5027
5088
  */
5028
5089
  getLocalCart(): LocalCart;
5029
5090
  /**
@@ -5041,89 +5102,44 @@ declare class BrainerceClient {
5041
5102
  */
5042
5103
  private localCartToCart;
5043
5104
  /**
5044
- * Add item to local cart (NO API call)
5045
- * If item already exists, updates quantity
5046
- *
5047
- * @example
5048
- * ```typescript
5049
- * client.addToLocalCart({
5050
- * productId: 'prod_123',
5051
- * quantity: 2,
5052
- * name: 'Cool Shirt',
5053
- * price: '29.99',
5054
- * });
5055
- * ```
5105
+ * @deprecated Use `smartAddToCart()` instead. Guest carts are now stored on the server.
5106
+ * Add item to local cart (NO API call). If item already exists, updates quantity.
5056
5107
  */
5057
5108
  addToLocalCart(item: Omit<LocalCartItem, 'addedAt'>): LocalCart;
5058
5109
  /**
5059
- * Update item quantity in local cart
5060
- * Set quantity to 0 to remove item
5061
- *
5062
- * @example
5063
- * ```typescript
5064
- * client.updateLocalCartItem('prod_123', 3); // Set quantity to 3
5065
- * client.updateLocalCartItem('prod_123', 0); // Remove item
5066
- * ```
5110
+ * @deprecated Use `smartUpdateCartItem()` instead. Guest carts are now stored on the server.
5111
+ * Update item quantity in local cart. Set quantity to 0 to remove item.
5067
5112
  */
5068
5113
  updateLocalCartItem(productId: string, quantity: number, variantId?: string): LocalCart;
5069
5114
  /**
5070
- * Remove item from local cart
5071
- *
5072
- * @example
5073
- * ```typescript
5074
- * client.removeFromLocalCart('prod_123');
5075
- * client.removeFromLocalCart('prod_456', 'variant_789');
5076
- * ```
5115
+ * @deprecated Use `smartRemoveFromCart()` instead. Guest carts are now stored on the server.
5077
5116
  */
5078
5117
  removeFromLocalCart(productId: string, variantId?: string): LocalCart;
5079
5118
  /**
5080
- * Clear all items from local cart
5081
- *
5082
- * @example
5083
- * ```typescript
5084
- * client.clearLocalCart();
5085
- * ```
5119
+ * @deprecated Use `onCheckoutComplete()` instead. Guest carts are now stored on the server.
5086
5120
  */
5087
5121
  clearLocalCart(): LocalCart;
5088
5122
  /**
5089
- * Set customer info on local cart
5090
- *
5091
- * @example
5092
- * ```typescript
5093
- * client.setLocalCartCustomer({
5094
- * email: 'john@example.com',
5095
- * firstName: 'John',
5096
- * lastName: 'Doe',
5097
- * });
5098
- * ```
5123
+ * @deprecated Customer info is now set via checkout address methods.
5124
+ * Still used by `submitGuestOrder()` for backward compatibility.
5099
5125
  */
5100
5126
  setLocalCartCustomer(customer: LocalCart['customer']): LocalCart;
5101
5127
  /**
5102
- * Set shipping address on local cart
5103
- *
5104
- * @example
5105
- * ```typescript
5106
- * client.setLocalCartShippingAddress({
5107
- * firstName: 'John',
5108
- * lastName: 'Doe',
5109
- * line1: '123 Main St',
5110
- * city: 'Tel Aviv',
5111
- * postalCode: '6100000',
5112
- * country: 'IL',
5113
- * });
5114
- * ```
5128
+ * @deprecated Address is now set via `updateGuestCheckoutAddress()` after `startGuestCheckout()`.
5129
+ * Still used by `submitGuestOrder()` for backward compatibility.
5115
5130
  */
5116
5131
  setLocalCartShippingAddress(address: LocalCart['shippingAddress']): LocalCart;
5117
5132
  /**
5118
- * Set billing address on local cart
5133
+ * @deprecated Address is now set via `updateGuestCheckoutAddress()` after `startGuestCheckout()`.
5134
+ * Still used by `submitGuestOrder()` for backward compatibility.
5119
5135
  */
5120
5136
  setLocalCartBillingAddress(address: LocalCart['billingAddress']): LocalCart;
5121
5137
  /**
5122
- * Set coupon code on local cart
5138
+ * @deprecated Coupons are now applied via `applyCoupon()` on the server cart.
5123
5139
  */
5124
5140
  setLocalCartCoupon(couponCode: string | undefined): LocalCart;
5125
5141
  /**
5126
- * Get total items count in local cart
5142
+ * @deprecated Use `getSmartCartItemCount()` instead.
5127
5143
  */
5128
5144
  getLocalCartItemCount(): number;
5129
5145
  /**
@@ -5222,16 +5238,8 @@ declare class BrainerceClient {
5222
5238
  */
5223
5239
  private clearActiveCheckoutStorage;
5224
5240
  /**
5241
+ * @deprecated Partial checkout is now handled server-side via `selectedItemIds`.
5225
5242
  * Remove specific items from local cart by their indices.
5226
- * Use after partial checkout to remove only the purchased items.
5227
- *
5228
- * @param indices - Array of item indices to remove
5229
- *
5230
- * @example
5231
- * ```typescript
5232
- * // After partial checkout success, remove purchased items
5233
- * client.removeLocalCartItemsByIndex([0, 2]); // Removes items at index 0 and 2
5234
- * ```
5235
5243
  */
5236
5244
  removeLocalCartItemsByIndex(indices: number[]): void;
5237
5245
  /**