brainerce 1.11.0 → 1.12.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/README.md CHANGED
@@ -2827,11 +2827,70 @@ const brand = await client.createBrand({ name: 'Nike', slug: 'nike' });
2827
2827
  const tags = await client.listTags();
2828
2828
  const tag = await client.createTag({ name: 'Sale', slug: 'sale' });
2829
2829
 
2830
- // Attributes (for variant options)
2830
+ // Attributes (for variant options like Size, Color, Material)
2831
2831
  const attributes = await client.listAttributes();
2832
- const attribute = await client.createAttribute({ name: 'Color', slug: 'color' });
2833
- const options = await client.getAttributeOptions('attr_id');
2834
- await client.createAttributeOption('attr_id', { value: 'Red', slug: 'red' });
2832
+
2833
+ // Create a color swatch attribute
2834
+ const colorAttr = await client.createAttribute({
2835
+ name: 'Color',
2836
+ displayType: 'COLOR_SWATCH', // Options: 'DEFAULT' | 'COLOR_SWATCH' | 'IMAGE_SWATCH'
2837
+ source: 'GLOBAL',
2838
+ });
2839
+
2840
+ // Add color swatch options
2841
+ await client.createAttributeOption(colorAttr.id, {
2842
+ name: 'Red',
2843
+ value: 'red',
2844
+ swatchColor: '#FF0000',
2845
+ source: 'GLOBAL',
2846
+ });
2847
+
2848
+ // Gradient swatch (two colors)
2849
+ await client.createAttributeOption(colorAttr.id, {
2850
+ name: 'Sunset',
2851
+ value: 'sunset',
2852
+ swatchColor: '#FF6B35',
2853
+ swatchColor2: '#FFD700',
2854
+ source: 'GLOBAL',
2855
+ });
2856
+
2857
+ // Image swatch attribute
2858
+ const materialAttr = await client.createAttribute({
2859
+ name: 'Material',
2860
+ displayType: 'IMAGE_SWATCH',
2861
+ source: 'GLOBAL',
2862
+ });
2863
+ await client.createAttributeOption(materialAttr.id, {
2864
+ name: 'Leather',
2865
+ value: 'leather',
2866
+ swatchImageUrl: 'https://example.com/leather-texture.jpg',
2867
+ source: 'GLOBAL',
2868
+ });
2869
+
2870
+ // Default attribute (text buttons/dropdown)
2871
+ const sizeAttr = await client.createAttribute({
2872
+ name: 'Size',
2873
+ source: 'GLOBAL',
2874
+ });
2875
+ await client.createAttributeOption(sizeAttr.id, {
2876
+ name: 'Large',
2877
+ value: 'L',
2878
+ source: 'GLOBAL',
2879
+ });
2880
+
2881
+ // Get options, update, delete
2882
+ const options = await client.getAttributeOptions(colorAttr.id);
2883
+ await client.updateAttribute(colorAttr.id, { displayType: 'IMAGE_SWATCH' });
2884
+ await client.updateAttributeOption(colorAttr.id, options[0].id, { swatchColor: '#CC0000' });
2885
+ await client.deleteAttributeOption(colorAttr.id, options[0].id);
2886
+ await client.deleteAttribute(colorAttr.id);
2887
+
2888
+ // Storefront: render swatches from product data
2889
+ import { getProductSwatches } from 'brainerce';
2890
+
2891
+ const product = await client.getProductBySlug('my-product');
2892
+ const swatches = getProductSwatches(product);
2893
+ // Returns: [{ attributeName: 'Color', displayType: 'COLOR_SWATCH', options: [{ name: 'Red', swatchColor: '#FF0000', ... }] }]
2835
2894
  ```
2836
2895
 
2837
2896
  ### Shipping Configuration
package/dist/index.d.mts CHANGED
@@ -135,6 +135,23 @@ interface StoreInfo {
135
135
  * 3. Call verifyEmail(code) with the code they received via email
136
136
  */
137
137
  requireEmailVerification?: boolean;
138
+ /** Upsell feature settings (storefront mode) */
139
+ upsell?: UpsellSettings;
140
+ }
141
+ /** Upsell feature configuration exposed to the storefront */
142
+ interface UpsellSettings {
143
+ /** Minimum cart amount for free shipping (null = disabled) */
144
+ freeShippingThreshold: number | null;
145
+ /** Show free shipping progress bar in cart */
146
+ freeShippingBarEnabled: boolean;
147
+ /** Show "Frequently Bought Together" on product page */
148
+ frequentlyBoughtTogetherEnabled: boolean;
149
+ /** Show upgrade banner per cart item */
150
+ cartUpgradeBannerEnabled: boolean;
151
+ /** Show bundle offers in cart */
152
+ cartBundleEnabled: boolean;
153
+ /** Show order bump checkbox at checkout */
154
+ checkoutOrderBumpEnabled: boolean;
138
155
  }
139
156
  interface CustomerProfile {
140
157
  id: string;
@@ -218,7 +235,9 @@ interface Product {
218
235
  lastSyncedAt?: string | null;
219
236
  /** Menu/display order */
220
237
  menuOrder?: number | null;
221
- /** Full attribute options for variant selection (admin mode only) */
238
+ /** Tax behavior: 'taxable' follows store setting, 'exempt' always skips tax */
239
+ taxBehavior?: 'taxable' | 'exempt';
240
+ /** Full attribute options for variant selection (admin, storefront, and vibe-coded modes) */
222
241
  productAttributeOptions?: Array<{
223
242
  id: string;
224
243
  attributeId: string;
@@ -227,11 +246,15 @@ interface Product {
227
246
  attribute: {
228
247
  id: string;
229
248
  name: string;
249
+ displayType?: string;
230
250
  } | null;
231
251
  attributeOption: {
232
252
  id: string;
233
253
  name: string;
234
254
  value?: string | null;
255
+ swatchColor?: string | null;
256
+ swatchColor2?: string | null;
257
+ swatchImageUrl?: string | null;
235
258
  } | null;
236
259
  }>;
237
260
  /** Vibe-coded sites this product is published to (admin mode only) */
@@ -244,6 +267,8 @@ interface Product {
244
267
  }>;
245
268
  /** Discount info from matching discount rules (storefront/VC mode only) */
246
269
  discount?: ProductDiscount | null;
270
+ /** Recommendations (upsells, cross-sells, related) — included in storefront/VC getProductBySlug response */
271
+ recommendations?: ProductRecommendationsResponse;
247
272
  createdAt: string;
248
273
  updatedAt: string;
249
274
  }
@@ -636,6 +661,22 @@ declare function getVariantOptions(variant: Pick<ProductVariant, 'attributes'> |
636
661
  name: string;
637
662
  value: string;
638
663
  }>;
664
+ /**
665
+ * Get structured swatch data from product attribute options.
666
+ * Groups by attribute name and includes display type + swatch details.
667
+ * Useful for rendering swatch selectors in storefronts.
668
+ */
669
+ declare function getProductSwatches(product: Pick<Product, 'productAttributeOptions'> | null | undefined): Array<{
670
+ attributeName: string;
671
+ displayType: string;
672
+ options: Array<{
673
+ name: string;
674
+ value?: string | null;
675
+ swatchColor?: string | null;
676
+ swatchColor2?: string | null;
677
+ swatchImageUrl?: string | null;
678
+ }>;
679
+ }>;
639
680
  /**
640
681
  * Get a single metafield by definition key.
641
682
  */
@@ -1283,6 +1324,7 @@ interface RegisterCustomerDto {
1283
1324
  firstName?: string;
1284
1325
  lastName?: string;
1285
1326
  phone?: string;
1327
+ acceptsMarketing?: boolean;
1286
1328
  }
1287
1329
  type CartStatus = 'ACTIVE' | 'MERGED' | 'CONVERTED' | 'ABANDONED';
1288
1330
  /**
@@ -2707,6 +2749,8 @@ interface Category {
2707
2749
  platformMetadata?: Record<string, Record<string, unknown>> | null;
2708
2750
  parentId?: string | null;
2709
2751
  isActive: boolean;
2752
+ /** Tax behavior: 'taxable' follows store setting, 'exempt' always skips tax */
2753
+ taxBehavior?: 'taxable' | 'exempt';
2710
2754
  deletedAt?: string | null;
2711
2755
  productCount?: number;
2712
2756
  products?: Array<{
@@ -2723,11 +2767,13 @@ interface CreateCategoryDto {
2723
2767
  storeId?: string;
2724
2768
  source?: string;
2725
2769
  isActive?: boolean;
2770
+ taxBehavior?: 'taxable' | 'exempt';
2726
2771
  }
2727
2772
  interface UpdateCategoryDto {
2728
2773
  name?: string;
2729
2774
  parentId?: string | null;
2730
2775
  isActive?: boolean;
2776
+ taxBehavior?: 'taxable' | 'exempt';
2731
2777
  }
2732
2778
  /**
2733
2779
  * Brand entity for product organization
@@ -2817,6 +2863,7 @@ interface Attribute {
2817
2863
  accountId: string;
2818
2864
  storeId?: string | null;
2819
2865
  name: string;
2866
+ displayType?: string;
2820
2867
  source: AttributeSource;
2821
2868
  platform?: ConnectorPlatform | null;
2822
2869
  externalId?: string | null;
@@ -2833,6 +2880,9 @@ interface AttributeOption {
2833
2880
  attributeId: string;
2834
2881
  name: string;
2835
2882
  value?: string | null;
2883
+ swatchColor?: string | null;
2884
+ swatchColor2?: string | null;
2885
+ swatchImageUrl?: string | null;
2836
2886
  source: AttributeSource;
2837
2887
  platform?: ConnectorPlatform | null;
2838
2888
  externalId?: string | null;
@@ -2845,6 +2895,7 @@ interface AttributeOption {
2845
2895
  }
2846
2896
  interface CreateAttributeDto {
2847
2897
  name: string;
2898
+ displayType?: string;
2848
2899
  source: AttributeSource;
2849
2900
  platform?: ConnectorPlatform;
2850
2901
  storeId?: string;
@@ -2854,12 +2905,16 @@ interface CreateAttributeDto {
2854
2905
  }
2855
2906
  interface UpdateAttributeDto {
2856
2907
  name?: string;
2908
+ displayType?: string;
2857
2909
  platformMetadata?: Record<string, unknown>;
2858
2910
  isActive?: boolean;
2859
2911
  }
2860
2912
  interface CreateAttributeOptionDto {
2861
2913
  name: string;
2862
2914
  value?: string;
2915
+ swatchColor?: string;
2916
+ swatchColor2?: string;
2917
+ swatchImageUrl?: string;
2863
2918
  source: AttributeSource;
2864
2919
  platform?: ConnectorPlatform;
2865
2920
  externalId?: string;
@@ -2870,6 +2925,9 @@ interface CreateAttributeOptionDto {
2870
2925
  interface UpdateAttributeOptionDto {
2871
2926
  name?: string;
2872
2927
  value?: string;
2928
+ swatchColor?: string | null;
2929
+ swatchColor2?: string | null;
2930
+ swatchImageUrl?: string | null;
2873
2931
  platformMetadata?: Record<string, unknown>;
2874
2932
  position?: number;
2875
2933
  isActive?: boolean;
@@ -3503,6 +3561,44 @@ interface ProductRecommendationsResponse {
3503
3561
  interface CartRecommendationsResponse {
3504
3562
  recommendations: ProductRecommendation[];
3505
3563
  }
3564
+ interface CartUpgradeSuggestion {
3565
+ sourceProductId: string;
3566
+ targetProduct: ProductRecommendation;
3567
+ priceDelta: string;
3568
+ deltaPercent: number;
3569
+ }
3570
+ interface CartUpgradesResponse {
3571
+ upgrades: Record<string, CartUpgradeSuggestion>;
3572
+ }
3573
+ interface CartBundleOffer {
3574
+ id: string;
3575
+ name: string;
3576
+ description: string | null;
3577
+ sourceProductId: string;
3578
+ bundleProduct: ProductRecommendation;
3579
+ bundleVariantId: string | null;
3580
+ discountType: 'PERCENTAGE' | 'FIXED_AMOUNT';
3581
+ discountValue: string;
3582
+ originalPrice: string;
3583
+ discountedPrice: string;
3584
+ }
3585
+ interface CartBundlesResponse {
3586
+ bundles: CartBundleOffer[];
3587
+ }
3588
+ interface OrderBump {
3589
+ id: string;
3590
+ title: string;
3591
+ description: string | null;
3592
+ bumpProduct: ProductRecommendation;
3593
+ bumpVariantId: string | null;
3594
+ originalPrice: string;
3595
+ discountedPrice: string | null;
3596
+ discountType: string | null;
3597
+ discountValue: string | null;
3598
+ }
3599
+ interface CheckoutBumpsResponse {
3600
+ bumps: OrderBump[];
3601
+ }
3506
3602
  interface BrainerceApiError {
3507
3603
  statusCode: number;
3508
3604
  message: string;
@@ -4766,6 +4862,61 @@ declare class BrainerceClient {
4766
4862
  * ```
4767
4863
  */
4768
4864
  getCartRecommendations(cartId: string, limit?: number): Promise<CartRecommendationsResponse>;
4865
+ /**
4866
+ * Get upgrade suggestions for cart items (upsell relations with small price delta).
4867
+ * Returns a map keyed by source product ID with the best upgrade option.
4868
+ *
4869
+ * @param cartId - Cart ID
4870
+ * @returns Map of upgrade suggestions keyed by source product ID
4871
+ *
4872
+ * @example
4873
+ * ```typescript
4874
+ * const { upgrades } = await client.getCartUpgrades('cart_123');
4875
+ * for (const [productId, suggestion] of Object.entries(upgrades)) {
4876
+ * console.log(`Upgrade from ${productId} to ${suggestion.targetProduct.name} for +$${suggestion.priceDelta}`);
4877
+ * }
4878
+ * ```
4879
+ */
4880
+ getCartUpgrades(cartId: string): Promise<CartUpgradesResponse>;
4881
+ /**
4882
+ * Get matching bundle offers for cart items.
4883
+ * Returns bundle products with discounted prices for items currently in the cart.
4884
+ *
4885
+ * @param cartId - Cart ID
4886
+ * @returns Array of bundle offers
4887
+ *
4888
+ * @example
4889
+ * ```typescript
4890
+ * const { bundles } = await client.getCartBundles('cart_123');
4891
+ * bundles.forEach(b => {
4892
+ * console.log(`Add ${b.bundleProduct.name} and save! Was ${b.originalPrice}, now ${b.discountedPrice}`);
4893
+ * });
4894
+ * ```
4895
+ */
4896
+ getCartBundles(cartId: string): Promise<CartBundlesResponse>;
4897
+ /**
4898
+ * Get matching order bumps for a checkout session.
4899
+ *
4900
+ * @param checkoutId - Checkout ID
4901
+ * @returns Array of order bumps
4902
+ */
4903
+ getCheckoutBumps(checkoutId: string): Promise<CheckoutBumpsResponse>;
4904
+ /**
4905
+ * Add an order bump to the cart.
4906
+ *
4907
+ * @param cartId - Cart ID
4908
+ * @param bumpConfigId - Order bump config ID
4909
+ * @returns Updated cart
4910
+ */
4911
+ addOrderBump(cartId: string, bumpConfigId: string): Promise<Cart>;
4912
+ /**
4913
+ * Remove an order bump from the cart.
4914
+ *
4915
+ * @param cartId - Cart ID
4916
+ * @param bumpConfigId - Order bump config ID
4917
+ * @returns Updated cart
4918
+ */
4919
+ removeOrderBump(cartId: string, bumpConfigId: string): Promise<Cart>;
4769
4920
  /**
4770
4921
  * Check if customer is currently authenticated
4771
4922
  * Used internally by smart cart methods to determine storage strategy
@@ -6486,6 +6637,8 @@ declare class BrainerceError extends Error {
6486
6637
  constructor(message: string, statusCode: number, details?: unknown);
6487
6638
  }
6488
6639
 
6640
+ declare const SDK_VERSION = "1.11.2";
6641
+
6489
6642
  /**
6490
6643
  * Verify a webhook signature from Brainerce
6491
6644
  *
@@ -6558,4 +6711,4 @@ declare function enableDevGuards(options?: {
6558
6711
  force?: boolean;
6559
6712
  }): void;
6560
6713
 
6561
- export { type AddToCartDto, type AppliedDiscount, type ApplyCouponDto, type Attribute, type AttributeOption, type AttributeSource, type BrainerceApiError, BrainerceClient, type BrainerceClientOptions, BrainerceError, type Brand, type BulkInventoryResponse, type BulkSaveVariantsDto, type BulkSaveVariantsResponse, type BulkVariantInput, type Cart, type CartAppliedDiscount, type CartItem, type CartNudge, type CartRecommendationsResponse, type CartStatus, type Category, type CategoryNode, type CategorySuggestion, type Checkout, type CheckoutAddress, type CheckoutLineItem, type CheckoutPrefillData, type CheckoutStatus, type CompleteCheckoutResponse, type CompleteDraftDto, type ConfigureOAuthProviderDto as ConfigureOAuthProviderInput, type ConflictStatus, type ConnectorPlatform, type Coupon, type CouponCreateResponse, type CouponQueryParams, type CouponStatus, type CouponType, type CouponValidationWarning, type CreateAddressDto, type CreateAttributeDto as CreateAttributeInput, type CreateAttributeOptionDto as CreateAttributeOptionInput, type CreateBrandDto as CreateBrandInput, type CreateCategoryDto as CreateCategoryInput, type CreateCheckoutDto, type CreateCouponDto, type CreateCustomApiDto, type CreateCustomerDto, type CreateEmailTemplateDto as CreateEmailTemplateInput, type CreateGuestOrderDto, type CreateMetafieldDefinitionDto as CreateMetafieldDefinitionInput, type CreateOrderDto, type CreateProductDto, type CreateRefundDto, type CreateShippingRateDto as CreateShippingRateInput, type CreateShippingZoneDto as CreateShippingZoneInput, type CreateTagDto as CreateTagInput, type CreateTaxRateDto as CreateTaxRateInput, type CreateVariantDto, type CustomApiAuthType, type CustomApiConnectionStatus, type CustomApiCredentials, type CustomApiIntegration, type CustomApiSyncConfig, type CustomApiSyncDirection, type CustomApiTestResult, type Customer, type CustomerAddress, type CustomerAuthResponse, type CustomerOAuthProvider, type CustomerProfile, type CustomerQueryParams, type DeleteProductResponse, type DiscountBanner, type DiscountRuleType, type DownloadFile, type DraftLineItem, type EditInventoryDto, type EmailDomain, type EmailEventSettings, type EmailEventType, type EmailSettings, type EmailTemplate, type EmailTemplatePreview, type EmailVerificationResponse, type ExtendReservationResponse, type FormatPriceOptions, type FulfillOrderDto, type GuestCheckoutStartResponse, type GuestOrderResponse, type InsufficientStockError, type InventoryInfo, type InventoryReservationStrategy, type InventorySyncStatus, type InventoryTrackingMode, type InvitationStatus, type InviteMemberDto as InviteMemberInput, type InviteStoreMemberDto as InviteStoreMemberInput, type LocalCart, type LocalCartItem, type MergeCartsDto, type MetafieldConflict, type MetafieldConflictResolution, type MetafieldDefinition, type MetafieldPlatformMapping, type MetafieldType, type OAuthAuthorizeResponse, type OAuthCallbackResponse, type OAuthConnection, type OAuthConnectionsResponse, type OAuthProviderConfig, type OAuthProviderType, type OAuthProvidersResponse, type Order, type OrderAddress, type OrderCustomer, type OrderDownloadLink, type OrderItem, type OrderQueryParams, type OrderStatus, type PaginatedResponse, type PaymentClientSdk, type PaymentConfig, type PaymentIntent, type PaymentProvider, type PaymentProviderConfig, type PaymentProvidersConfig, type PaymentStatus, type PickupLocation, type PlatformCouponCapabilities, type PreviewEmailTemplateDto as PreviewEmailTemplateInput, type Product, type ProductAttributeInput, type ProductAvailability, type ProductDiscount, type ProductDiscountBadge, type ProductImage, type ProductMetafield, type ProductMetafieldValue, type ProductQueryParams, type ProductRecommendation, type ProductRecommendationsResponse, type ProductRelationType, type ProductSuggestion, type ProductVariant, type PublicMetafieldDefinition, type PublishProductResponse, type ReconcileInventoryResponse, type Refund, type RefundLineItem, type RefundLineItemResponse, type RefundType, type RegisterCustomerDto, type ReservationInfo, type ResolveMetafieldConflictDto as ResolveMetafieldConflictInput, type ResolveSyncConflictDto as ResolveSyncConflictInput, type SearchSuggestions, type SelectPickupLocationDto, type SelectShippingMethodDto, type SendInvoiceDto, type SessionCartRef, type SetBillingAddressDto, type SetCheckoutCustomerDto, type SetShippingAddressDto, type SetShippingAddressResponse, type ShippingDestinations, type ShippingLine, type ShippingRate, type ShippingRateConfig, type ShippingRateType, type ShippingZone, type ShippingZoneQueryParams, type StockAvailabilityRequest, type StockAvailabilityResponse, type StockAvailabilityResult, type StoreInfo, type StoreInvitation, type StoreInvitationDetails, type StoreMember, type StorePermission, type StoreRole, type StoreTeamResponse, type SyncConflict, type SyncConflictResolution, type SyncJob, type Tag, type TaxBreakdown, type TaxBreakdownItem, type TaxRate, type TaxonomyQueryParams, type TeamInvitation, type TeamInvitationsResponse, type TeamMember, type TeamMembersResponse, type TeamRole, type UpdateAddressDto, type UpdateAttributeDto as UpdateAttributeInput, type UpdateAttributeOptionDto as UpdateAttributeOptionInput, type UpdateBrandDto as UpdateBrandInput, type UpdateCartItemDto, type UpdateCategoryDto as UpdateCategoryInput, type UpdateCouponDto, type UpdateCustomApiDto, type UpdateCustomerDto, type UpdateDraftDto, type UpdateEmailSettingsDto as UpdateEmailSettingsInput, type UpdateEmailTemplateDto as UpdateEmailTemplateInput, type UpdateInventoryDto, type UpdateMemberRoleDto as UpdateMemberRoleInput, type UpdateMetafieldDefinitionDto as UpdateMetafieldDefinitionInput, type UpdateOAuthProviderDto as UpdateOAuthProviderInput, type UpdateOrderDto, type UpdateOrderShippingDto, type UpdateProductDto, type UpdateShippingRateDto as UpdateShippingRateInput, type UpdateShippingZoneDto as UpdateShippingZoneInput, type UpdateStoreMemberDto as UpdateStoreMemberInput, type UpdateTagDto as UpdateTagInput, type UpdateTaxRateDto as UpdateTaxRateInput, type UpdateVariantDto, type UpdateVariantInventoryDto, type UpsertProductMetafieldDto as UpsertProductMetafieldInput, type UserStore, type UserStorePermissions, type VariantInventoryResponse, type VariantPlatformOverlay, type VariantStatus, type WaitForOrderOptions, type WaitForOrderResult, type WebhookEvent, type WebhookEventType, createWebhookHandler, enableDevGuards, formatPrice, getCartItemImage, getCartItemName, getCartTotals, getDescriptionContent, formatPrice as getPriceDisplay, getProductMetafield, getProductMetafieldValue, getProductMetafieldsByType, getProductPrice, getProductPriceInfo, getStockStatus, getVariantOptions, getVariantPrice, isCouponApplicableToProduct, isHtmlDescription, isWebhookEventType, parseWebhookEvent, verifyWebhook };
6714
+ export { type AddToCartDto, type AppliedDiscount, type ApplyCouponDto, type Attribute, type AttributeOption, type AttributeSource, type BrainerceApiError, BrainerceClient, type BrainerceClientOptions, BrainerceError, type Brand, type BulkInventoryResponse, type BulkSaveVariantsDto, type BulkSaveVariantsResponse, type BulkVariantInput, type Cart, type CartAppliedDiscount, type CartBundleOffer, type CartBundlesResponse, type CartItem, type CartNudge, type CartRecommendationsResponse, type CartStatus, type CartUpgradeSuggestion, type CartUpgradesResponse, type Category, type CategoryNode, type CategorySuggestion, type Checkout, type CheckoutAddress, type CheckoutBumpsResponse, type CheckoutLineItem, type CheckoutPrefillData, type CheckoutStatus, type CompleteCheckoutResponse, type CompleteDraftDto, type ConfigureOAuthProviderDto as ConfigureOAuthProviderInput, type ConflictStatus, type ConnectorPlatform, type Coupon, type CouponCreateResponse, type CouponQueryParams, type CouponStatus, type CouponType, type CouponValidationWarning, type CreateAddressDto, type CreateAttributeDto as CreateAttributeInput, type CreateAttributeOptionDto as CreateAttributeOptionInput, type CreateBrandDto as CreateBrandInput, type CreateCategoryDto as CreateCategoryInput, type CreateCheckoutDto, type CreateCouponDto, type CreateCustomApiDto, type CreateCustomerDto, type CreateEmailTemplateDto as CreateEmailTemplateInput, type CreateGuestOrderDto, type CreateMetafieldDefinitionDto as CreateMetafieldDefinitionInput, type CreateOrderDto, type CreateProductDto, type CreateRefundDto, type CreateShippingRateDto as CreateShippingRateInput, type CreateShippingZoneDto as CreateShippingZoneInput, type CreateTagDto as CreateTagInput, type CreateTaxRateDto as CreateTaxRateInput, type CreateVariantDto, type CustomApiAuthType, type CustomApiConnectionStatus, type CustomApiCredentials, type CustomApiIntegration, type CustomApiSyncConfig, type CustomApiSyncDirection, type CustomApiTestResult, type Customer, type CustomerAddress, type CustomerAuthResponse, type CustomerOAuthProvider, type CustomerProfile, type CustomerQueryParams, type DeleteProductResponse, type DiscountBanner, type DiscountRuleType, type DownloadFile, type DraftLineItem, type EditInventoryDto, type EmailDomain, type EmailEventSettings, type EmailEventType, type EmailSettings, type EmailTemplate, type EmailTemplatePreview, type EmailVerificationResponse, type ExtendReservationResponse, type FormatPriceOptions, type FulfillOrderDto, type GuestCheckoutStartResponse, type GuestOrderResponse, type InsufficientStockError, type InventoryInfo, type InventoryReservationStrategy, type InventorySyncStatus, type InventoryTrackingMode, type InvitationStatus, type InviteMemberDto as InviteMemberInput, type InviteStoreMemberDto as InviteStoreMemberInput, type LocalCart, type LocalCartItem, type MergeCartsDto, type MetafieldConflict, type MetafieldConflictResolution, type MetafieldDefinition, type MetafieldPlatformMapping, type MetafieldType, type OAuthAuthorizeResponse, type OAuthCallbackResponse, type OAuthConnection, type OAuthConnectionsResponse, type OAuthProviderConfig, type OAuthProviderType, type OAuthProvidersResponse, type Order, type OrderAddress, type OrderBump, type OrderCustomer, type OrderDownloadLink, type OrderItem, type OrderQueryParams, type OrderStatus, type PaginatedResponse, type PaymentClientSdk, type PaymentConfig, type PaymentIntent, type PaymentProvider, type PaymentProviderConfig, type PaymentProvidersConfig, type PaymentStatus, type PickupLocation, type PlatformCouponCapabilities, type PreviewEmailTemplateDto as PreviewEmailTemplateInput, type Product, type ProductAttributeInput, type ProductAvailability, type ProductDiscount, type ProductDiscountBadge, type ProductImage, type ProductMetafield, type ProductMetafieldValue, type ProductQueryParams, type ProductRecommendation, type ProductRecommendationsResponse, type ProductRelationType, type ProductSuggestion, type ProductVariant, type PublicMetafieldDefinition, type PublishProductResponse, type ReconcileInventoryResponse, type Refund, type RefundLineItem, type RefundLineItemResponse, type RefundType, type RegisterCustomerDto, type ReservationInfo, type ResolveMetafieldConflictDto as ResolveMetafieldConflictInput, type ResolveSyncConflictDto as ResolveSyncConflictInput, SDK_VERSION, type SearchSuggestions, type SelectPickupLocationDto, type SelectShippingMethodDto, type SendInvoiceDto, type SessionCartRef, type SetBillingAddressDto, type SetCheckoutCustomerDto, type SetShippingAddressDto, type SetShippingAddressResponse, type ShippingDestinations, type ShippingLine, type ShippingRate, type ShippingRateConfig, type ShippingRateType, type ShippingZone, type ShippingZoneQueryParams, type StockAvailabilityRequest, type StockAvailabilityResponse, type StockAvailabilityResult, type StoreInfo, type StoreInvitation, type StoreInvitationDetails, type StoreMember, type StorePermission, type StoreRole, type StoreTeamResponse, type SyncConflict, type SyncConflictResolution, type SyncJob, type Tag, type TaxBreakdown, type TaxBreakdownItem, type TaxRate, type TaxonomyQueryParams, type TeamInvitation, type TeamInvitationsResponse, type TeamMember, type TeamMembersResponse, type TeamRole, type UpdateAddressDto, type UpdateAttributeDto as UpdateAttributeInput, type UpdateAttributeOptionDto as UpdateAttributeOptionInput, type UpdateBrandDto as UpdateBrandInput, type UpdateCartItemDto, type UpdateCategoryDto as UpdateCategoryInput, type UpdateCouponDto, type UpdateCustomApiDto, type UpdateCustomerDto, type UpdateDraftDto, type UpdateEmailSettingsDto as UpdateEmailSettingsInput, type UpdateEmailTemplateDto as UpdateEmailTemplateInput, type UpdateInventoryDto, type UpdateMemberRoleDto as UpdateMemberRoleInput, type UpdateMetafieldDefinitionDto as UpdateMetafieldDefinitionInput, type UpdateOAuthProviderDto as UpdateOAuthProviderInput, type UpdateOrderDto, type UpdateOrderShippingDto, type UpdateProductDto, type UpdateShippingRateDto as UpdateShippingRateInput, type UpdateShippingZoneDto as UpdateShippingZoneInput, type UpdateStoreMemberDto as UpdateStoreMemberInput, type UpdateTagDto as UpdateTagInput, type UpdateTaxRateDto as UpdateTaxRateInput, type UpdateVariantDto, type UpdateVariantInventoryDto, type UpsertProductMetafieldDto as UpsertProductMetafieldInput, type UserStore, type UserStorePermissions, type VariantInventoryResponse, type VariantPlatformOverlay, type VariantStatus, type WaitForOrderOptions, type WaitForOrderResult, type WebhookEvent, type WebhookEventType, createWebhookHandler, enableDevGuards, formatPrice, getCartItemImage, getCartItemName, getCartTotals, getDescriptionContent, formatPrice as getPriceDisplay, getProductMetafield, getProductMetafieldValue, getProductMetafieldsByType, getProductPrice, getProductPriceInfo, getProductSwatches, getStockStatus, getVariantOptions, getVariantPrice, isCouponApplicableToProduct, isHtmlDescription, isWebhookEventType, parseWebhookEvent, verifyWebhook };
package/dist/index.d.ts CHANGED
@@ -135,6 +135,23 @@ interface StoreInfo {
135
135
  * 3. Call verifyEmail(code) with the code they received via email
136
136
  */
137
137
  requireEmailVerification?: boolean;
138
+ /** Upsell feature settings (storefront mode) */
139
+ upsell?: UpsellSettings;
140
+ }
141
+ /** Upsell feature configuration exposed to the storefront */
142
+ interface UpsellSettings {
143
+ /** Minimum cart amount for free shipping (null = disabled) */
144
+ freeShippingThreshold: number | null;
145
+ /** Show free shipping progress bar in cart */
146
+ freeShippingBarEnabled: boolean;
147
+ /** Show "Frequently Bought Together" on product page */
148
+ frequentlyBoughtTogetherEnabled: boolean;
149
+ /** Show upgrade banner per cart item */
150
+ cartUpgradeBannerEnabled: boolean;
151
+ /** Show bundle offers in cart */
152
+ cartBundleEnabled: boolean;
153
+ /** Show order bump checkbox at checkout */
154
+ checkoutOrderBumpEnabled: boolean;
138
155
  }
139
156
  interface CustomerProfile {
140
157
  id: string;
@@ -218,7 +235,9 @@ interface Product {
218
235
  lastSyncedAt?: string | null;
219
236
  /** Menu/display order */
220
237
  menuOrder?: number | null;
221
- /** Full attribute options for variant selection (admin mode only) */
238
+ /** Tax behavior: 'taxable' follows store setting, 'exempt' always skips tax */
239
+ taxBehavior?: 'taxable' | 'exempt';
240
+ /** Full attribute options for variant selection (admin, storefront, and vibe-coded modes) */
222
241
  productAttributeOptions?: Array<{
223
242
  id: string;
224
243
  attributeId: string;
@@ -227,11 +246,15 @@ interface Product {
227
246
  attribute: {
228
247
  id: string;
229
248
  name: string;
249
+ displayType?: string;
230
250
  } | null;
231
251
  attributeOption: {
232
252
  id: string;
233
253
  name: string;
234
254
  value?: string | null;
255
+ swatchColor?: string | null;
256
+ swatchColor2?: string | null;
257
+ swatchImageUrl?: string | null;
235
258
  } | null;
236
259
  }>;
237
260
  /** Vibe-coded sites this product is published to (admin mode only) */
@@ -244,6 +267,8 @@ interface Product {
244
267
  }>;
245
268
  /** Discount info from matching discount rules (storefront/VC mode only) */
246
269
  discount?: ProductDiscount | null;
270
+ /** Recommendations (upsells, cross-sells, related) — included in storefront/VC getProductBySlug response */
271
+ recommendations?: ProductRecommendationsResponse;
247
272
  createdAt: string;
248
273
  updatedAt: string;
249
274
  }
@@ -636,6 +661,22 @@ declare function getVariantOptions(variant: Pick<ProductVariant, 'attributes'> |
636
661
  name: string;
637
662
  value: string;
638
663
  }>;
664
+ /**
665
+ * Get structured swatch data from product attribute options.
666
+ * Groups by attribute name and includes display type + swatch details.
667
+ * Useful for rendering swatch selectors in storefronts.
668
+ */
669
+ declare function getProductSwatches(product: Pick<Product, 'productAttributeOptions'> | null | undefined): Array<{
670
+ attributeName: string;
671
+ displayType: string;
672
+ options: Array<{
673
+ name: string;
674
+ value?: string | null;
675
+ swatchColor?: string | null;
676
+ swatchColor2?: string | null;
677
+ swatchImageUrl?: string | null;
678
+ }>;
679
+ }>;
639
680
  /**
640
681
  * Get a single metafield by definition key.
641
682
  */
@@ -1283,6 +1324,7 @@ interface RegisterCustomerDto {
1283
1324
  firstName?: string;
1284
1325
  lastName?: string;
1285
1326
  phone?: string;
1327
+ acceptsMarketing?: boolean;
1286
1328
  }
1287
1329
  type CartStatus = 'ACTIVE' | 'MERGED' | 'CONVERTED' | 'ABANDONED';
1288
1330
  /**
@@ -2707,6 +2749,8 @@ interface Category {
2707
2749
  platformMetadata?: Record<string, Record<string, unknown>> | null;
2708
2750
  parentId?: string | null;
2709
2751
  isActive: boolean;
2752
+ /** Tax behavior: 'taxable' follows store setting, 'exempt' always skips tax */
2753
+ taxBehavior?: 'taxable' | 'exempt';
2710
2754
  deletedAt?: string | null;
2711
2755
  productCount?: number;
2712
2756
  products?: Array<{
@@ -2723,11 +2767,13 @@ interface CreateCategoryDto {
2723
2767
  storeId?: string;
2724
2768
  source?: string;
2725
2769
  isActive?: boolean;
2770
+ taxBehavior?: 'taxable' | 'exempt';
2726
2771
  }
2727
2772
  interface UpdateCategoryDto {
2728
2773
  name?: string;
2729
2774
  parentId?: string | null;
2730
2775
  isActive?: boolean;
2776
+ taxBehavior?: 'taxable' | 'exempt';
2731
2777
  }
2732
2778
  /**
2733
2779
  * Brand entity for product organization
@@ -2817,6 +2863,7 @@ interface Attribute {
2817
2863
  accountId: string;
2818
2864
  storeId?: string | null;
2819
2865
  name: string;
2866
+ displayType?: string;
2820
2867
  source: AttributeSource;
2821
2868
  platform?: ConnectorPlatform | null;
2822
2869
  externalId?: string | null;
@@ -2833,6 +2880,9 @@ interface AttributeOption {
2833
2880
  attributeId: string;
2834
2881
  name: string;
2835
2882
  value?: string | null;
2883
+ swatchColor?: string | null;
2884
+ swatchColor2?: string | null;
2885
+ swatchImageUrl?: string | null;
2836
2886
  source: AttributeSource;
2837
2887
  platform?: ConnectorPlatform | null;
2838
2888
  externalId?: string | null;
@@ -2845,6 +2895,7 @@ interface AttributeOption {
2845
2895
  }
2846
2896
  interface CreateAttributeDto {
2847
2897
  name: string;
2898
+ displayType?: string;
2848
2899
  source: AttributeSource;
2849
2900
  platform?: ConnectorPlatform;
2850
2901
  storeId?: string;
@@ -2854,12 +2905,16 @@ interface CreateAttributeDto {
2854
2905
  }
2855
2906
  interface UpdateAttributeDto {
2856
2907
  name?: string;
2908
+ displayType?: string;
2857
2909
  platformMetadata?: Record<string, unknown>;
2858
2910
  isActive?: boolean;
2859
2911
  }
2860
2912
  interface CreateAttributeOptionDto {
2861
2913
  name: string;
2862
2914
  value?: string;
2915
+ swatchColor?: string;
2916
+ swatchColor2?: string;
2917
+ swatchImageUrl?: string;
2863
2918
  source: AttributeSource;
2864
2919
  platform?: ConnectorPlatform;
2865
2920
  externalId?: string;
@@ -2870,6 +2925,9 @@ interface CreateAttributeOptionDto {
2870
2925
  interface UpdateAttributeOptionDto {
2871
2926
  name?: string;
2872
2927
  value?: string;
2928
+ swatchColor?: string | null;
2929
+ swatchColor2?: string | null;
2930
+ swatchImageUrl?: string | null;
2873
2931
  platformMetadata?: Record<string, unknown>;
2874
2932
  position?: number;
2875
2933
  isActive?: boolean;
@@ -3503,6 +3561,44 @@ interface ProductRecommendationsResponse {
3503
3561
  interface CartRecommendationsResponse {
3504
3562
  recommendations: ProductRecommendation[];
3505
3563
  }
3564
+ interface CartUpgradeSuggestion {
3565
+ sourceProductId: string;
3566
+ targetProduct: ProductRecommendation;
3567
+ priceDelta: string;
3568
+ deltaPercent: number;
3569
+ }
3570
+ interface CartUpgradesResponse {
3571
+ upgrades: Record<string, CartUpgradeSuggestion>;
3572
+ }
3573
+ interface CartBundleOffer {
3574
+ id: string;
3575
+ name: string;
3576
+ description: string | null;
3577
+ sourceProductId: string;
3578
+ bundleProduct: ProductRecommendation;
3579
+ bundleVariantId: string | null;
3580
+ discountType: 'PERCENTAGE' | 'FIXED_AMOUNT';
3581
+ discountValue: string;
3582
+ originalPrice: string;
3583
+ discountedPrice: string;
3584
+ }
3585
+ interface CartBundlesResponse {
3586
+ bundles: CartBundleOffer[];
3587
+ }
3588
+ interface OrderBump {
3589
+ id: string;
3590
+ title: string;
3591
+ description: string | null;
3592
+ bumpProduct: ProductRecommendation;
3593
+ bumpVariantId: string | null;
3594
+ originalPrice: string;
3595
+ discountedPrice: string | null;
3596
+ discountType: string | null;
3597
+ discountValue: string | null;
3598
+ }
3599
+ interface CheckoutBumpsResponse {
3600
+ bumps: OrderBump[];
3601
+ }
3506
3602
  interface BrainerceApiError {
3507
3603
  statusCode: number;
3508
3604
  message: string;
@@ -4766,6 +4862,61 @@ declare class BrainerceClient {
4766
4862
  * ```
4767
4863
  */
4768
4864
  getCartRecommendations(cartId: string, limit?: number): Promise<CartRecommendationsResponse>;
4865
+ /**
4866
+ * Get upgrade suggestions for cart items (upsell relations with small price delta).
4867
+ * Returns a map keyed by source product ID with the best upgrade option.
4868
+ *
4869
+ * @param cartId - Cart ID
4870
+ * @returns Map of upgrade suggestions keyed by source product ID
4871
+ *
4872
+ * @example
4873
+ * ```typescript
4874
+ * const { upgrades } = await client.getCartUpgrades('cart_123');
4875
+ * for (const [productId, suggestion] of Object.entries(upgrades)) {
4876
+ * console.log(`Upgrade from ${productId} to ${suggestion.targetProduct.name} for +$${suggestion.priceDelta}`);
4877
+ * }
4878
+ * ```
4879
+ */
4880
+ getCartUpgrades(cartId: string): Promise<CartUpgradesResponse>;
4881
+ /**
4882
+ * Get matching bundle offers for cart items.
4883
+ * Returns bundle products with discounted prices for items currently in the cart.
4884
+ *
4885
+ * @param cartId - Cart ID
4886
+ * @returns Array of bundle offers
4887
+ *
4888
+ * @example
4889
+ * ```typescript
4890
+ * const { bundles } = await client.getCartBundles('cart_123');
4891
+ * bundles.forEach(b => {
4892
+ * console.log(`Add ${b.bundleProduct.name} and save! Was ${b.originalPrice}, now ${b.discountedPrice}`);
4893
+ * });
4894
+ * ```
4895
+ */
4896
+ getCartBundles(cartId: string): Promise<CartBundlesResponse>;
4897
+ /**
4898
+ * Get matching order bumps for a checkout session.
4899
+ *
4900
+ * @param checkoutId - Checkout ID
4901
+ * @returns Array of order bumps
4902
+ */
4903
+ getCheckoutBumps(checkoutId: string): Promise<CheckoutBumpsResponse>;
4904
+ /**
4905
+ * Add an order bump to the cart.
4906
+ *
4907
+ * @param cartId - Cart ID
4908
+ * @param bumpConfigId - Order bump config ID
4909
+ * @returns Updated cart
4910
+ */
4911
+ addOrderBump(cartId: string, bumpConfigId: string): Promise<Cart>;
4912
+ /**
4913
+ * Remove an order bump from the cart.
4914
+ *
4915
+ * @param cartId - Cart ID
4916
+ * @param bumpConfigId - Order bump config ID
4917
+ * @returns Updated cart
4918
+ */
4919
+ removeOrderBump(cartId: string, bumpConfigId: string): Promise<Cart>;
4769
4920
  /**
4770
4921
  * Check if customer is currently authenticated
4771
4922
  * Used internally by smart cart methods to determine storage strategy
@@ -6486,6 +6637,8 @@ declare class BrainerceError extends Error {
6486
6637
  constructor(message: string, statusCode: number, details?: unknown);
6487
6638
  }
6488
6639
 
6640
+ declare const SDK_VERSION = "1.11.2";
6641
+
6489
6642
  /**
6490
6643
  * Verify a webhook signature from Brainerce
6491
6644
  *
@@ -6558,4 +6711,4 @@ declare function enableDevGuards(options?: {
6558
6711
  force?: boolean;
6559
6712
  }): void;
6560
6713
 
6561
- export { type AddToCartDto, type AppliedDiscount, type ApplyCouponDto, type Attribute, type AttributeOption, type AttributeSource, type BrainerceApiError, BrainerceClient, type BrainerceClientOptions, BrainerceError, type Brand, type BulkInventoryResponse, type BulkSaveVariantsDto, type BulkSaveVariantsResponse, type BulkVariantInput, type Cart, type CartAppliedDiscount, type CartItem, type CartNudge, type CartRecommendationsResponse, type CartStatus, type Category, type CategoryNode, type CategorySuggestion, type Checkout, type CheckoutAddress, type CheckoutLineItem, type CheckoutPrefillData, type CheckoutStatus, type CompleteCheckoutResponse, type CompleteDraftDto, type ConfigureOAuthProviderDto as ConfigureOAuthProviderInput, type ConflictStatus, type ConnectorPlatform, type Coupon, type CouponCreateResponse, type CouponQueryParams, type CouponStatus, type CouponType, type CouponValidationWarning, type CreateAddressDto, type CreateAttributeDto as CreateAttributeInput, type CreateAttributeOptionDto as CreateAttributeOptionInput, type CreateBrandDto as CreateBrandInput, type CreateCategoryDto as CreateCategoryInput, type CreateCheckoutDto, type CreateCouponDto, type CreateCustomApiDto, type CreateCustomerDto, type CreateEmailTemplateDto as CreateEmailTemplateInput, type CreateGuestOrderDto, type CreateMetafieldDefinitionDto as CreateMetafieldDefinitionInput, type CreateOrderDto, type CreateProductDto, type CreateRefundDto, type CreateShippingRateDto as CreateShippingRateInput, type CreateShippingZoneDto as CreateShippingZoneInput, type CreateTagDto as CreateTagInput, type CreateTaxRateDto as CreateTaxRateInput, type CreateVariantDto, type CustomApiAuthType, type CustomApiConnectionStatus, type CustomApiCredentials, type CustomApiIntegration, type CustomApiSyncConfig, type CustomApiSyncDirection, type CustomApiTestResult, type Customer, type CustomerAddress, type CustomerAuthResponse, type CustomerOAuthProvider, type CustomerProfile, type CustomerQueryParams, type DeleteProductResponse, type DiscountBanner, type DiscountRuleType, type DownloadFile, type DraftLineItem, type EditInventoryDto, type EmailDomain, type EmailEventSettings, type EmailEventType, type EmailSettings, type EmailTemplate, type EmailTemplatePreview, type EmailVerificationResponse, type ExtendReservationResponse, type FormatPriceOptions, type FulfillOrderDto, type GuestCheckoutStartResponse, type GuestOrderResponse, type InsufficientStockError, type InventoryInfo, type InventoryReservationStrategy, type InventorySyncStatus, type InventoryTrackingMode, type InvitationStatus, type InviteMemberDto as InviteMemberInput, type InviteStoreMemberDto as InviteStoreMemberInput, type LocalCart, type LocalCartItem, type MergeCartsDto, type MetafieldConflict, type MetafieldConflictResolution, type MetafieldDefinition, type MetafieldPlatformMapping, type MetafieldType, type OAuthAuthorizeResponse, type OAuthCallbackResponse, type OAuthConnection, type OAuthConnectionsResponse, type OAuthProviderConfig, type OAuthProviderType, type OAuthProvidersResponse, type Order, type OrderAddress, type OrderCustomer, type OrderDownloadLink, type OrderItem, type OrderQueryParams, type OrderStatus, type PaginatedResponse, type PaymentClientSdk, type PaymentConfig, type PaymentIntent, type PaymentProvider, type PaymentProviderConfig, type PaymentProvidersConfig, type PaymentStatus, type PickupLocation, type PlatformCouponCapabilities, type PreviewEmailTemplateDto as PreviewEmailTemplateInput, type Product, type ProductAttributeInput, type ProductAvailability, type ProductDiscount, type ProductDiscountBadge, type ProductImage, type ProductMetafield, type ProductMetafieldValue, type ProductQueryParams, type ProductRecommendation, type ProductRecommendationsResponse, type ProductRelationType, type ProductSuggestion, type ProductVariant, type PublicMetafieldDefinition, type PublishProductResponse, type ReconcileInventoryResponse, type Refund, type RefundLineItem, type RefundLineItemResponse, type RefundType, type RegisterCustomerDto, type ReservationInfo, type ResolveMetafieldConflictDto as ResolveMetafieldConflictInput, type ResolveSyncConflictDto as ResolveSyncConflictInput, type SearchSuggestions, type SelectPickupLocationDto, type SelectShippingMethodDto, type SendInvoiceDto, type SessionCartRef, type SetBillingAddressDto, type SetCheckoutCustomerDto, type SetShippingAddressDto, type SetShippingAddressResponse, type ShippingDestinations, type ShippingLine, type ShippingRate, type ShippingRateConfig, type ShippingRateType, type ShippingZone, type ShippingZoneQueryParams, type StockAvailabilityRequest, type StockAvailabilityResponse, type StockAvailabilityResult, type StoreInfo, type StoreInvitation, type StoreInvitationDetails, type StoreMember, type StorePermission, type StoreRole, type StoreTeamResponse, type SyncConflict, type SyncConflictResolution, type SyncJob, type Tag, type TaxBreakdown, type TaxBreakdownItem, type TaxRate, type TaxonomyQueryParams, type TeamInvitation, type TeamInvitationsResponse, type TeamMember, type TeamMembersResponse, type TeamRole, type UpdateAddressDto, type UpdateAttributeDto as UpdateAttributeInput, type UpdateAttributeOptionDto as UpdateAttributeOptionInput, type UpdateBrandDto as UpdateBrandInput, type UpdateCartItemDto, type UpdateCategoryDto as UpdateCategoryInput, type UpdateCouponDto, type UpdateCustomApiDto, type UpdateCustomerDto, type UpdateDraftDto, type UpdateEmailSettingsDto as UpdateEmailSettingsInput, type UpdateEmailTemplateDto as UpdateEmailTemplateInput, type UpdateInventoryDto, type UpdateMemberRoleDto as UpdateMemberRoleInput, type UpdateMetafieldDefinitionDto as UpdateMetafieldDefinitionInput, type UpdateOAuthProviderDto as UpdateOAuthProviderInput, type UpdateOrderDto, type UpdateOrderShippingDto, type UpdateProductDto, type UpdateShippingRateDto as UpdateShippingRateInput, type UpdateShippingZoneDto as UpdateShippingZoneInput, type UpdateStoreMemberDto as UpdateStoreMemberInput, type UpdateTagDto as UpdateTagInput, type UpdateTaxRateDto as UpdateTaxRateInput, type UpdateVariantDto, type UpdateVariantInventoryDto, type UpsertProductMetafieldDto as UpsertProductMetafieldInput, type UserStore, type UserStorePermissions, type VariantInventoryResponse, type VariantPlatformOverlay, type VariantStatus, type WaitForOrderOptions, type WaitForOrderResult, type WebhookEvent, type WebhookEventType, createWebhookHandler, enableDevGuards, formatPrice, getCartItemImage, getCartItemName, getCartTotals, getDescriptionContent, formatPrice as getPriceDisplay, getProductMetafield, getProductMetafieldValue, getProductMetafieldsByType, getProductPrice, getProductPriceInfo, getStockStatus, getVariantOptions, getVariantPrice, isCouponApplicableToProduct, isHtmlDescription, isWebhookEventType, parseWebhookEvent, verifyWebhook };
6714
+ export { type AddToCartDto, type AppliedDiscount, type ApplyCouponDto, type Attribute, type AttributeOption, type AttributeSource, type BrainerceApiError, BrainerceClient, type BrainerceClientOptions, BrainerceError, type Brand, type BulkInventoryResponse, type BulkSaveVariantsDto, type BulkSaveVariantsResponse, type BulkVariantInput, type Cart, type CartAppliedDiscount, type CartBundleOffer, type CartBundlesResponse, type CartItem, type CartNudge, type CartRecommendationsResponse, type CartStatus, type CartUpgradeSuggestion, type CartUpgradesResponse, type Category, type CategoryNode, type CategorySuggestion, type Checkout, type CheckoutAddress, type CheckoutBumpsResponse, type CheckoutLineItem, type CheckoutPrefillData, type CheckoutStatus, type CompleteCheckoutResponse, type CompleteDraftDto, type ConfigureOAuthProviderDto as ConfigureOAuthProviderInput, type ConflictStatus, type ConnectorPlatform, type Coupon, type CouponCreateResponse, type CouponQueryParams, type CouponStatus, type CouponType, type CouponValidationWarning, type CreateAddressDto, type CreateAttributeDto as CreateAttributeInput, type CreateAttributeOptionDto as CreateAttributeOptionInput, type CreateBrandDto as CreateBrandInput, type CreateCategoryDto as CreateCategoryInput, type CreateCheckoutDto, type CreateCouponDto, type CreateCustomApiDto, type CreateCustomerDto, type CreateEmailTemplateDto as CreateEmailTemplateInput, type CreateGuestOrderDto, type CreateMetafieldDefinitionDto as CreateMetafieldDefinitionInput, type CreateOrderDto, type CreateProductDto, type CreateRefundDto, type CreateShippingRateDto as CreateShippingRateInput, type CreateShippingZoneDto as CreateShippingZoneInput, type CreateTagDto as CreateTagInput, type CreateTaxRateDto as CreateTaxRateInput, type CreateVariantDto, type CustomApiAuthType, type CustomApiConnectionStatus, type CustomApiCredentials, type CustomApiIntegration, type CustomApiSyncConfig, type CustomApiSyncDirection, type CustomApiTestResult, type Customer, type CustomerAddress, type CustomerAuthResponse, type CustomerOAuthProvider, type CustomerProfile, type CustomerQueryParams, type DeleteProductResponse, type DiscountBanner, type DiscountRuleType, type DownloadFile, type DraftLineItem, type EditInventoryDto, type EmailDomain, type EmailEventSettings, type EmailEventType, type EmailSettings, type EmailTemplate, type EmailTemplatePreview, type EmailVerificationResponse, type ExtendReservationResponse, type FormatPriceOptions, type FulfillOrderDto, type GuestCheckoutStartResponse, type GuestOrderResponse, type InsufficientStockError, type InventoryInfo, type InventoryReservationStrategy, type InventorySyncStatus, type InventoryTrackingMode, type InvitationStatus, type InviteMemberDto as InviteMemberInput, type InviteStoreMemberDto as InviteStoreMemberInput, type LocalCart, type LocalCartItem, type MergeCartsDto, type MetafieldConflict, type MetafieldConflictResolution, type MetafieldDefinition, type MetafieldPlatformMapping, type MetafieldType, type OAuthAuthorizeResponse, type OAuthCallbackResponse, type OAuthConnection, type OAuthConnectionsResponse, type OAuthProviderConfig, type OAuthProviderType, type OAuthProvidersResponse, type Order, type OrderAddress, type OrderBump, type OrderCustomer, type OrderDownloadLink, type OrderItem, type OrderQueryParams, type OrderStatus, type PaginatedResponse, type PaymentClientSdk, type PaymentConfig, type PaymentIntent, type PaymentProvider, type PaymentProviderConfig, type PaymentProvidersConfig, type PaymentStatus, type PickupLocation, type PlatformCouponCapabilities, type PreviewEmailTemplateDto as PreviewEmailTemplateInput, type Product, type ProductAttributeInput, type ProductAvailability, type ProductDiscount, type ProductDiscountBadge, type ProductImage, type ProductMetafield, type ProductMetafieldValue, type ProductQueryParams, type ProductRecommendation, type ProductRecommendationsResponse, type ProductRelationType, type ProductSuggestion, type ProductVariant, type PublicMetafieldDefinition, type PublishProductResponse, type ReconcileInventoryResponse, type Refund, type RefundLineItem, type RefundLineItemResponse, type RefundType, type RegisterCustomerDto, type ReservationInfo, type ResolveMetafieldConflictDto as ResolveMetafieldConflictInput, type ResolveSyncConflictDto as ResolveSyncConflictInput, SDK_VERSION, type SearchSuggestions, type SelectPickupLocationDto, type SelectShippingMethodDto, type SendInvoiceDto, type SessionCartRef, type SetBillingAddressDto, type SetCheckoutCustomerDto, type SetShippingAddressDto, type SetShippingAddressResponse, type ShippingDestinations, type ShippingLine, type ShippingRate, type ShippingRateConfig, type ShippingRateType, type ShippingZone, type ShippingZoneQueryParams, type StockAvailabilityRequest, type StockAvailabilityResponse, type StockAvailabilityResult, type StoreInfo, type StoreInvitation, type StoreInvitationDetails, type StoreMember, type StorePermission, type StoreRole, type StoreTeamResponse, type SyncConflict, type SyncConflictResolution, type SyncJob, type Tag, type TaxBreakdown, type TaxBreakdownItem, type TaxRate, type TaxonomyQueryParams, type TeamInvitation, type TeamInvitationsResponse, type TeamMember, type TeamMembersResponse, type TeamRole, type UpdateAddressDto, type UpdateAttributeDto as UpdateAttributeInput, type UpdateAttributeOptionDto as UpdateAttributeOptionInput, type UpdateBrandDto as UpdateBrandInput, type UpdateCartItemDto, type UpdateCategoryDto as UpdateCategoryInput, type UpdateCouponDto, type UpdateCustomApiDto, type UpdateCustomerDto, type UpdateDraftDto, type UpdateEmailSettingsDto as UpdateEmailSettingsInput, type UpdateEmailTemplateDto as UpdateEmailTemplateInput, type UpdateInventoryDto, type UpdateMemberRoleDto as UpdateMemberRoleInput, type UpdateMetafieldDefinitionDto as UpdateMetafieldDefinitionInput, type UpdateOAuthProviderDto as UpdateOAuthProviderInput, type UpdateOrderDto, type UpdateOrderShippingDto, type UpdateProductDto, type UpdateShippingRateDto as UpdateShippingRateInput, type UpdateShippingZoneDto as UpdateShippingZoneInput, type UpdateStoreMemberDto as UpdateStoreMemberInput, type UpdateTagDto as UpdateTagInput, type UpdateTaxRateDto as UpdateTaxRateInput, type UpdateVariantDto, type UpdateVariantInventoryDto, type UpsertProductMetafieldDto as UpsertProductMetafieldInput, type UserStore, type UserStorePermissions, type VariantInventoryResponse, type VariantPlatformOverlay, type VariantStatus, type WaitForOrderOptions, type WaitForOrderResult, type WebhookEvent, type WebhookEventType, createWebhookHandler, enableDevGuards, formatPrice, getCartItemImage, getCartItemName, getCartTotals, getDescriptionContent, formatPrice as getPriceDisplay, getProductMetafield, getProductMetafieldValue, getProductMetafieldsByType, getProductPrice, getProductPriceInfo, getProductSwatches, getStockStatus, getVariantOptions, getVariantPrice, isCouponApplicableToProduct, isHtmlDescription, isWebhookEventType, parseWebhookEvent, verifyWebhook };
package/dist/index.js CHANGED
@@ -32,6 +32,7 @@ var index_exports = {};
32
32
  __export(index_exports, {
33
33
  BrainerceClient: () => BrainerceClient,
34
34
  BrainerceError: () => BrainerceError,
35
+ SDK_VERSION: () => SDK_VERSION,
35
36
  createWebhookHandler: () => createWebhookHandler,
36
37
  enableDevGuards: () => enableDevGuards,
37
38
  formatPrice: () => formatPrice,
@@ -45,6 +46,7 @@ __export(index_exports, {
45
46
  getProductMetafieldsByType: () => getProductMetafieldsByType,
46
47
  getProductPrice: () => getProductPrice,
47
48
  getProductPriceInfo: () => getProductPriceInfo,
49
+ getProductSwatches: () => getProductSwatches,
48
50
  getStockStatus: () => getStockStatus,
49
51
  getVariantOptions: () => getVariantOptions,
50
52
  getVariantPrice: () => getVariantPrice,
@@ -172,6 +174,9 @@ function isDevGuardsEnabled() {
172
174
  return _devGuardsEnabled;
173
175
  }
174
176
 
177
+ // src/version.ts
178
+ var SDK_VERSION = "1.11.2";
179
+
175
180
  // src/client.ts
176
181
  var DEFAULT_BASE_URL = "https://api.brainerce.com";
177
182
  var DEFAULT_TIMEOUT = 3e4;
@@ -339,7 +344,7 @@ var BrainerceClient = class {
339
344
  const headers = {
340
345
  Authorization: `Bearer ${this.apiKey}`,
341
346
  "Content-Type": "application/json",
342
- "X-SDK-Version": "1.11.0",
347
+ "X-SDK-Version": SDK_VERSION,
343
348
  "ngrok-skip-browser-warning": "true"
344
349
  };
345
350
  if (this.origin) {
@@ -397,7 +402,7 @@ var BrainerceClient = class {
397
402
  try {
398
403
  const headers = {
399
404
  "Content-Type": "application/json",
400
- "X-SDK-Version": "1.11.0",
405
+ "X-SDK-Version": SDK_VERSION,
401
406
  "ngrok-skip-browser-warning": "true"
402
407
  };
403
408
  if (this.origin) {
@@ -468,7 +473,7 @@ var BrainerceClient = class {
468
473
  try {
469
474
  const headers = {
470
475
  "Content-Type": "application/json",
471
- "X-SDK-Version": "1.11.0",
476
+ "X-SDK-Version": SDK_VERSION,
472
477
  "ngrok-skip-browser-warning": "true"
473
478
  };
474
479
  if (this.origin) {
@@ -2419,6 +2424,101 @@ var BrainerceClient = class {
2419
2424
  400
2420
2425
  );
2421
2426
  }
2427
+ /**
2428
+ * Get upgrade suggestions for cart items (upsell relations with small price delta).
2429
+ * Returns a map keyed by source product ID with the best upgrade option.
2430
+ *
2431
+ * @param cartId - Cart ID
2432
+ * @returns Map of upgrade suggestions keyed by source product ID
2433
+ *
2434
+ * @example
2435
+ * ```typescript
2436
+ * const { upgrades } = await client.getCartUpgrades('cart_123');
2437
+ * for (const [productId, suggestion] of Object.entries(upgrades)) {
2438
+ * console.log(`Upgrade from ${productId} to ${suggestion.targetProduct.name} for +$${suggestion.priceDelta}`);
2439
+ * }
2440
+ * ```
2441
+ */
2442
+ async getCartUpgrades(cartId) {
2443
+ if (this.isVibeCodedMode()) {
2444
+ return this.vibeCodedRequest("GET", `/cart/${cartId}/upgrades`);
2445
+ }
2446
+ if (this.storeId && !this.apiKey) {
2447
+ return this.storefrontRequest("GET", `/cart/${cartId}/upgrades`);
2448
+ }
2449
+ throw new BrainerceError("getCartUpgrades() requires vibe-coded or storefront mode", 400);
2450
+ }
2451
+ /**
2452
+ * Get matching bundle offers for cart items.
2453
+ * Returns bundle products with discounted prices for items currently in the cart.
2454
+ *
2455
+ * @param cartId - Cart ID
2456
+ * @returns Array of bundle offers
2457
+ *
2458
+ * @example
2459
+ * ```typescript
2460
+ * const { bundles } = await client.getCartBundles('cart_123');
2461
+ * bundles.forEach(b => {
2462
+ * console.log(`Add ${b.bundleProduct.name} and save! Was ${b.originalPrice}, now ${b.discountedPrice}`);
2463
+ * });
2464
+ * ```
2465
+ */
2466
+ async getCartBundles(cartId) {
2467
+ if (this.isVibeCodedMode()) {
2468
+ return this.vibeCodedRequest("GET", `/cart/${cartId}/bundles`);
2469
+ }
2470
+ if (this.storeId && !this.apiKey) {
2471
+ return this.storefrontRequest("GET", `/cart/${cartId}/bundles`);
2472
+ }
2473
+ throw new BrainerceError("getCartBundles() requires vibe-coded or storefront mode", 400);
2474
+ }
2475
+ /**
2476
+ * Get matching order bumps for a checkout session.
2477
+ *
2478
+ * @param checkoutId - Checkout ID
2479
+ * @returns Array of order bumps
2480
+ */
2481
+ async getCheckoutBumps(checkoutId) {
2482
+ if (this.isVibeCodedMode()) {
2483
+ return this.vibeCodedRequest("GET", `/checkout/${checkoutId}/bumps`);
2484
+ }
2485
+ if (this.storeId && !this.apiKey) {
2486
+ return this.storefrontRequest("GET", `/checkout/${checkoutId}/bumps`);
2487
+ }
2488
+ throw new BrainerceError("getCheckoutBumps() requires vibe-coded or storefront mode", 400);
2489
+ }
2490
+ /**
2491
+ * Add an order bump to the cart.
2492
+ *
2493
+ * @param cartId - Cart ID
2494
+ * @param bumpConfigId - Order bump config ID
2495
+ * @returns Updated cart
2496
+ */
2497
+ async addOrderBump(cartId, bumpConfigId) {
2498
+ if (this.isVibeCodedMode()) {
2499
+ return this.vibeCodedRequest("POST", `/cart/${cartId}/bump`, { bumpConfigId });
2500
+ }
2501
+ if (this.storeId && !this.apiKey) {
2502
+ return this.storefrontRequest("POST", `/cart/${cartId}/bump`, { bumpConfigId });
2503
+ }
2504
+ throw new BrainerceError("addOrderBump() requires vibe-coded or storefront mode", 400);
2505
+ }
2506
+ /**
2507
+ * Remove an order bump from the cart.
2508
+ *
2509
+ * @param cartId - Cart ID
2510
+ * @param bumpConfigId - Order bump config ID
2511
+ * @returns Updated cart
2512
+ */
2513
+ async removeOrderBump(cartId, bumpConfigId) {
2514
+ if (this.isVibeCodedMode()) {
2515
+ return this.vibeCodedRequest("DELETE", `/cart/${cartId}/bump/${bumpConfigId}`);
2516
+ }
2517
+ if (this.storeId && !this.apiKey) {
2518
+ return this.storefrontRequest("DELETE", `/cart/${cartId}/bump/${bumpConfigId}`);
2519
+ }
2520
+ throw new BrainerceError("removeOrderBump() requires vibe-coded or storefront mode", 400);
2521
+ }
2422
2522
  // -------------------- Smart Cart (Auto-sync) --------------------
2423
2523
  /**
2424
2524
  * Check if customer is currently authenticated
@@ -5933,6 +6033,34 @@ function getVariantOptions(variant) {
5933
6033
  ]);
5934
6034
  return Object.entries(variant.attributes).filter(([key, value]) => typeof value === "string" && !internalKeys.has(key)).map(([name, value]) => ({ name, value }));
5935
6035
  }
6036
+ function getProductSwatches(product) {
6037
+ if (!product?.productAttributeOptions) return [];
6038
+ const grouped = /* @__PURE__ */ new Map();
6039
+ for (const pao of product.productAttributeOptions) {
6040
+ if (!pao.attribute || !pao.attributeOption) continue;
6041
+ const attrName = pao.attribute.name;
6042
+ if (!grouped.has(attrName)) {
6043
+ grouped.set(attrName, {
6044
+ displayType: pao.attribute.displayType || "DEFAULT",
6045
+ options: []
6046
+ });
6047
+ }
6048
+ const entry = grouped.get(attrName);
6049
+ if (!entry.options.some((o) => o.name === pao.attributeOption.name)) {
6050
+ entry.options.push({
6051
+ name: pao.attributeOption.name,
6052
+ value: pao.attributeOption.value,
6053
+ swatchColor: pao.attributeOption.swatchColor,
6054
+ swatchColor2: pao.attributeOption.swatchColor2,
6055
+ swatchImageUrl: pao.attributeOption.swatchImageUrl
6056
+ });
6057
+ }
6058
+ }
6059
+ return Array.from(grouped.entries()).map(([attributeName, data]) => ({
6060
+ attributeName,
6061
+ ...data
6062
+ }));
6063
+ }
5936
6064
  function getProductMetafield(product, key) {
5937
6065
  return product.metafields?.find((m) => m.definitionKey === key);
5938
6066
  }
@@ -5965,6 +6093,7 @@ function isCouponApplicableToProduct(coupon, productId) {
5965
6093
  0 && (module.exports = {
5966
6094
  BrainerceClient,
5967
6095
  BrainerceError,
6096
+ SDK_VERSION,
5968
6097
  createWebhookHandler,
5969
6098
  enableDevGuards,
5970
6099
  formatPrice,
@@ -5978,6 +6107,7 @@ function isCouponApplicableToProduct(coupon, productId) {
5978
6107
  getProductMetafieldsByType,
5979
6108
  getProductPrice,
5980
6109
  getProductPriceInfo,
6110
+ getProductSwatches,
5981
6111
  getStockStatus,
5982
6112
  getVariantOptions,
5983
6113
  getVariantPrice,
package/dist/index.mjs CHANGED
@@ -114,6 +114,9 @@ function isDevGuardsEnabled() {
114
114
  return _devGuardsEnabled;
115
115
  }
116
116
 
117
+ // src/version.ts
118
+ var SDK_VERSION = "1.11.2";
119
+
117
120
  // src/client.ts
118
121
  var DEFAULT_BASE_URL = "https://api.brainerce.com";
119
122
  var DEFAULT_TIMEOUT = 3e4;
@@ -281,7 +284,7 @@ var BrainerceClient = class {
281
284
  const headers = {
282
285
  Authorization: `Bearer ${this.apiKey}`,
283
286
  "Content-Type": "application/json",
284
- "X-SDK-Version": "1.11.0",
287
+ "X-SDK-Version": SDK_VERSION,
285
288
  "ngrok-skip-browser-warning": "true"
286
289
  };
287
290
  if (this.origin) {
@@ -339,7 +342,7 @@ var BrainerceClient = class {
339
342
  try {
340
343
  const headers = {
341
344
  "Content-Type": "application/json",
342
- "X-SDK-Version": "1.11.0",
345
+ "X-SDK-Version": SDK_VERSION,
343
346
  "ngrok-skip-browser-warning": "true"
344
347
  };
345
348
  if (this.origin) {
@@ -410,7 +413,7 @@ var BrainerceClient = class {
410
413
  try {
411
414
  const headers = {
412
415
  "Content-Type": "application/json",
413
- "X-SDK-Version": "1.11.0",
416
+ "X-SDK-Version": SDK_VERSION,
414
417
  "ngrok-skip-browser-warning": "true"
415
418
  };
416
419
  if (this.origin) {
@@ -2361,6 +2364,101 @@ var BrainerceClient = class {
2361
2364
  400
2362
2365
  );
2363
2366
  }
2367
+ /**
2368
+ * Get upgrade suggestions for cart items (upsell relations with small price delta).
2369
+ * Returns a map keyed by source product ID with the best upgrade option.
2370
+ *
2371
+ * @param cartId - Cart ID
2372
+ * @returns Map of upgrade suggestions keyed by source product ID
2373
+ *
2374
+ * @example
2375
+ * ```typescript
2376
+ * const { upgrades } = await client.getCartUpgrades('cart_123');
2377
+ * for (const [productId, suggestion] of Object.entries(upgrades)) {
2378
+ * console.log(`Upgrade from ${productId} to ${suggestion.targetProduct.name} for +$${suggestion.priceDelta}`);
2379
+ * }
2380
+ * ```
2381
+ */
2382
+ async getCartUpgrades(cartId) {
2383
+ if (this.isVibeCodedMode()) {
2384
+ return this.vibeCodedRequest("GET", `/cart/${cartId}/upgrades`);
2385
+ }
2386
+ if (this.storeId && !this.apiKey) {
2387
+ return this.storefrontRequest("GET", `/cart/${cartId}/upgrades`);
2388
+ }
2389
+ throw new BrainerceError("getCartUpgrades() requires vibe-coded or storefront mode", 400);
2390
+ }
2391
+ /**
2392
+ * Get matching bundle offers for cart items.
2393
+ * Returns bundle products with discounted prices for items currently in the cart.
2394
+ *
2395
+ * @param cartId - Cart ID
2396
+ * @returns Array of bundle offers
2397
+ *
2398
+ * @example
2399
+ * ```typescript
2400
+ * const { bundles } = await client.getCartBundles('cart_123');
2401
+ * bundles.forEach(b => {
2402
+ * console.log(`Add ${b.bundleProduct.name} and save! Was ${b.originalPrice}, now ${b.discountedPrice}`);
2403
+ * });
2404
+ * ```
2405
+ */
2406
+ async getCartBundles(cartId) {
2407
+ if (this.isVibeCodedMode()) {
2408
+ return this.vibeCodedRequest("GET", `/cart/${cartId}/bundles`);
2409
+ }
2410
+ if (this.storeId && !this.apiKey) {
2411
+ return this.storefrontRequest("GET", `/cart/${cartId}/bundles`);
2412
+ }
2413
+ throw new BrainerceError("getCartBundles() requires vibe-coded or storefront mode", 400);
2414
+ }
2415
+ /**
2416
+ * Get matching order bumps for a checkout session.
2417
+ *
2418
+ * @param checkoutId - Checkout ID
2419
+ * @returns Array of order bumps
2420
+ */
2421
+ async getCheckoutBumps(checkoutId) {
2422
+ if (this.isVibeCodedMode()) {
2423
+ return this.vibeCodedRequest("GET", `/checkout/${checkoutId}/bumps`);
2424
+ }
2425
+ if (this.storeId && !this.apiKey) {
2426
+ return this.storefrontRequest("GET", `/checkout/${checkoutId}/bumps`);
2427
+ }
2428
+ throw new BrainerceError("getCheckoutBumps() requires vibe-coded or storefront mode", 400);
2429
+ }
2430
+ /**
2431
+ * Add an order bump to the cart.
2432
+ *
2433
+ * @param cartId - Cart ID
2434
+ * @param bumpConfigId - Order bump config ID
2435
+ * @returns Updated cart
2436
+ */
2437
+ async addOrderBump(cartId, bumpConfigId) {
2438
+ if (this.isVibeCodedMode()) {
2439
+ return this.vibeCodedRequest("POST", `/cart/${cartId}/bump`, { bumpConfigId });
2440
+ }
2441
+ if (this.storeId && !this.apiKey) {
2442
+ return this.storefrontRequest("POST", `/cart/${cartId}/bump`, { bumpConfigId });
2443
+ }
2444
+ throw new BrainerceError("addOrderBump() requires vibe-coded or storefront mode", 400);
2445
+ }
2446
+ /**
2447
+ * Remove an order bump from the cart.
2448
+ *
2449
+ * @param cartId - Cart ID
2450
+ * @param bumpConfigId - Order bump config ID
2451
+ * @returns Updated cart
2452
+ */
2453
+ async removeOrderBump(cartId, bumpConfigId) {
2454
+ if (this.isVibeCodedMode()) {
2455
+ return this.vibeCodedRequest("DELETE", `/cart/${cartId}/bump/${bumpConfigId}`);
2456
+ }
2457
+ if (this.storeId && !this.apiKey) {
2458
+ return this.storefrontRequest("DELETE", `/cart/${cartId}/bump/${bumpConfigId}`);
2459
+ }
2460
+ throw new BrainerceError("removeOrderBump() requires vibe-coded or storefront mode", 400);
2461
+ }
2364
2462
  // -------------------- Smart Cart (Auto-sync) --------------------
2365
2463
  /**
2366
2464
  * Check if customer is currently authenticated
@@ -5875,6 +5973,34 @@ function getVariantOptions(variant) {
5875
5973
  ]);
5876
5974
  return Object.entries(variant.attributes).filter(([key, value]) => typeof value === "string" && !internalKeys.has(key)).map(([name, value]) => ({ name, value }));
5877
5975
  }
5976
+ function getProductSwatches(product) {
5977
+ if (!product?.productAttributeOptions) return [];
5978
+ const grouped = /* @__PURE__ */ new Map();
5979
+ for (const pao of product.productAttributeOptions) {
5980
+ if (!pao.attribute || !pao.attributeOption) continue;
5981
+ const attrName = pao.attribute.name;
5982
+ if (!grouped.has(attrName)) {
5983
+ grouped.set(attrName, {
5984
+ displayType: pao.attribute.displayType || "DEFAULT",
5985
+ options: []
5986
+ });
5987
+ }
5988
+ const entry = grouped.get(attrName);
5989
+ if (!entry.options.some((o) => o.name === pao.attributeOption.name)) {
5990
+ entry.options.push({
5991
+ name: pao.attributeOption.name,
5992
+ value: pao.attributeOption.value,
5993
+ swatchColor: pao.attributeOption.swatchColor,
5994
+ swatchColor2: pao.attributeOption.swatchColor2,
5995
+ swatchImageUrl: pao.attributeOption.swatchImageUrl
5996
+ });
5997
+ }
5998
+ }
5999
+ return Array.from(grouped.entries()).map(([attributeName, data]) => ({
6000
+ attributeName,
6001
+ ...data
6002
+ }));
6003
+ }
5878
6004
  function getProductMetafield(product, key) {
5879
6005
  return product.metafields?.find((m) => m.definitionKey === key);
5880
6006
  }
@@ -5906,6 +6032,7 @@ function isCouponApplicableToProduct(coupon, productId) {
5906
6032
  export {
5907
6033
  BrainerceClient,
5908
6034
  BrainerceError,
6035
+ SDK_VERSION,
5909
6036
  createWebhookHandler,
5910
6037
  enableDevGuards,
5911
6038
  formatPrice,
@@ -5919,6 +6046,7 @@ export {
5919
6046
  getProductMetafieldsByType,
5920
6047
  getProductPrice,
5921
6048
  getProductPriceInfo,
6049
+ getProductSwatches,
5922
6050
  getStockStatus,
5923
6051
  getVariantOptions,
5924
6052
  getVariantPrice,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "brainerce",
3
- "version": "1.11.0",
3
+ "version": "1.12.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",