brainerce 1.11.0 → 1.11.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/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
@@ -218,6 +218,8 @@ interface Product {
218
218
  lastSyncedAt?: string | null;
219
219
  /** Menu/display order */
220
220
  menuOrder?: number | null;
221
+ /** Tax behavior: 'taxable' follows store setting, 'exempt' always skips tax */
222
+ taxBehavior?: 'taxable' | 'exempt';
221
223
  /** Full attribute options for variant selection (admin mode only) */
222
224
  productAttributeOptions?: Array<{
223
225
  id: string;
@@ -227,11 +229,15 @@ interface Product {
227
229
  attribute: {
228
230
  id: string;
229
231
  name: string;
232
+ displayType?: string;
230
233
  } | null;
231
234
  attributeOption: {
232
235
  id: string;
233
236
  name: string;
234
237
  value?: string | null;
238
+ swatchColor?: string | null;
239
+ swatchColor2?: string | null;
240
+ swatchImageUrl?: string | null;
235
241
  } | null;
236
242
  }>;
237
243
  /** Vibe-coded sites this product is published to (admin mode only) */
@@ -244,6 +250,8 @@ interface Product {
244
250
  }>;
245
251
  /** Discount info from matching discount rules (storefront/VC mode only) */
246
252
  discount?: ProductDiscount | null;
253
+ /** Recommendations (upsells, cross-sells, related) — included in storefront/VC getProductBySlug response */
254
+ recommendations?: ProductRecommendationsResponse;
247
255
  createdAt: string;
248
256
  updatedAt: string;
249
257
  }
@@ -636,6 +644,22 @@ declare function getVariantOptions(variant: Pick<ProductVariant, 'attributes'> |
636
644
  name: string;
637
645
  value: string;
638
646
  }>;
647
+ /**
648
+ * Get structured swatch data from product attribute options.
649
+ * Groups by attribute name and includes display type + swatch details.
650
+ * Useful for rendering swatch selectors in storefronts.
651
+ */
652
+ declare function getProductSwatches(product: Pick<Product, 'productAttributeOptions'> | null | undefined): Array<{
653
+ attributeName: string;
654
+ displayType: string;
655
+ options: Array<{
656
+ name: string;
657
+ value?: string | null;
658
+ swatchColor?: string | null;
659
+ swatchColor2?: string | null;
660
+ swatchImageUrl?: string | null;
661
+ }>;
662
+ }>;
639
663
  /**
640
664
  * Get a single metafield by definition key.
641
665
  */
@@ -1283,6 +1307,7 @@ interface RegisterCustomerDto {
1283
1307
  firstName?: string;
1284
1308
  lastName?: string;
1285
1309
  phone?: string;
1310
+ acceptsMarketing?: boolean;
1286
1311
  }
1287
1312
  type CartStatus = 'ACTIVE' | 'MERGED' | 'CONVERTED' | 'ABANDONED';
1288
1313
  /**
@@ -2707,6 +2732,8 @@ interface Category {
2707
2732
  platformMetadata?: Record<string, Record<string, unknown>> | null;
2708
2733
  parentId?: string | null;
2709
2734
  isActive: boolean;
2735
+ /** Tax behavior: 'taxable' follows store setting, 'exempt' always skips tax */
2736
+ taxBehavior?: 'taxable' | 'exempt';
2710
2737
  deletedAt?: string | null;
2711
2738
  productCount?: number;
2712
2739
  products?: Array<{
@@ -2723,11 +2750,13 @@ interface CreateCategoryDto {
2723
2750
  storeId?: string;
2724
2751
  source?: string;
2725
2752
  isActive?: boolean;
2753
+ taxBehavior?: 'taxable' | 'exempt';
2726
2754
  }
2727
2755
  interface UpdateCategoryDto {
2728
2756
  name?: string;
2729
2757
  parentId?: string | null;
2730
2758
  isActive?: boolean;
2759
+ taxBehavior?: 'taxable' | 'exempt';
2731
2760
  }
2732
2761
  /**
2733
2762
  * Brand entity for product organization
@@ -2817,6 +2846,7 @@ interface Attribute {
2817
2846
  accountId: string;
2818
2847
  storeId?: string | null;
2819
2848
  name: string;
2849
+ displayType?: string;
2820
2850
  source: AttributeSource;
2821
2851
  platform?: ConnectorPlatform | null;
2822
2852
  externalId?: string | null;
@@ -2833,6 +2863,9 @@ interface AttributeOption {
2833
2863
  attributeId: string;
2834
2864
  name: string;
2835
2865
  value?: string | null;
2866
+ swatchColor?: string | null;
2867
+ swatchColor2?: string | null;
2868
+ swatchImageUrl?: string | null;
2836
2869
  source: AttributeSource;
2837
2870
  platform?: ConnectorPlatform | null;
2838
2871
  externalId?: string | null;
@@ -2845,6 +2878,7 @@ interface AttributeOption {
2845
2878
  }
2846
2879
  interface CreateAttributeDto {
2847
2880
  name: string;
2881
+ displayType?: string;
2848
2882
  source: AttributeSource;
2849
2883
  platform?: ConnectorPlatform;
2850
2884
  storeId?: string;
@@ -2854,12 +2888,16 @@ interface CreateAttributeDto {
2854
2888
  }
2855
2889
  interface UpdateAttributeDto {
2856
2890
  name?: string;
2891
+ displayType?: string;
2857
2892
  platformMetadata?: Record<string, unknown>;
2858
2893
  isActive?: boolean;
2859
2894
  }
2860
2895
  interface CreateAttributeOptionDto {
2861
2896
  name: string;
2862
2897
  value?: string;
2898
+ swatchColor?: string;
2899
+ swatchColor2?: string;
2900
+ swatchImageUrl?: string;
2863
2901
  source: AttributeSource;
2864
2902
  platform?: ConnectorPlatform;
2865
2903
  externalId?: string;
@@ -2870,6 +2908,9 @@ interface CreateAttributeOptionDto {
2870
2908
  interface UpdateAttributeOptionDto {
2871
2909
  name?: string;
2872
2910
  value?: string;
2911
+ swatchColor?: string | null;
2912
+ swatchColor2?: string | null;
2913
+ swatchImageUrl?: string | null;
2873
2914
  platformMetadata?: Record<string, unknown>;
2874
2915
  position?: number;
2875
2916
  isActive?: boolean;
@@ -6486,6 +6527,8 @@ declare class BrainerceError extends Error {
6486
6527
  constructor(message: string, statusCode: number, details?: unknown);
6487
6528
  }
6488
6529
 
6530
+ declare const SDK_VERSION = "1.11.2";
6531
+
6489
6532
  /**
6490
6533
  * Verify a webhook signature from Brainerce
6491
6534
  *
@@ -6558,4 +6601,4 @@ declare function enableDevGuards(options?: {
6558
6601
  force?: boolean;
6559
6602
  }): void;
6560
6603
 
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 };
6604
+ 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, 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
@@ -218,6 +218,8 @@ interface Product {
218
218
  lastSyncedAt?: string | null;
219
219
  /** Menu/display order */
220
220
  menuOrder?: number | null;
221
+ /** Tax behavior: 'taxable' follows store setting, 'exempt' always skips tax */
222
+ taxBehavior?: 'taxable' | 'exempt';
221
223
  /** Full attribute options for variant selection (admin mode only) */
222
224
  productAttributeOptions?: Array<{
223
225
  id: string;
@@ -227,11 +229,15 @@ interface Product {
227
229
  attribute: {
228
230
  id: string;
229
231
  name: string;
232
+ displayType?: string;
230
233
  } | null;
231
234
  attributeOption: {
232
235
  id: string;
233
236
  name: string;
234
237
  value?: string | null;
238
+ swatchColor?: string | null;
239
+ swatchColor2?: string | null;
240
+ swatchImageUrl?: string | null;
235
241
  } | null;
236
242
  }>;
237
243
  /** Vibe-coded sites this product is published to (admin mode only) */
@@ -244,6 +250,8 @@ interface Product {
244
250
  }>;
245
251
  /** Discount info from matching discount rules (storefront/VC mode only) */
246
252
  discount?: ProductDiscount | null;
253
+ /** Recommendations (upsells, cross-sells, related) — included in storefront/VC getProductBySlug response */
254
+ recommendations?: ProductRecommendationsResponse;
247
255
  createdAt: string;
248
256
  updatedAt: string;
249
257
  }
@@ -636,6 +644,22 @@ declare function getVariantOptions(variant: Pick<ProductVariant, 'attributes'> |
636
644
  name: string;
637
645
  value: string;
638
646
  }>;
647
+ /**
648
+ * Get structured swatch data from product attribute options.
649
+ * Groups by attribute name and includes display type + swatch details.
650
+ * Useful for rendering swatch selectors in storefronts.
651
+ */
652
+ declare function getProductSwatches(product: Pick<Product, 'productAttributeOptions'> | null | undefined): Array<{
653
+ attributeName: string;
654
+ displayType: string;
655
+ options: Array<{
656
+ name: string;
657
+ value?: string | null;
658
+ swatchColor?: string | null;
659
+ swatchColor2?: string | null;
660
+ swatchImageUrl?: string | null;
661
+ }>;
662
+ }>;
639
663
  /**
640
664
  * Get a single metafield by definition key.
641
665
  */
@@ -1283,6 +1307,7 @@ interface RegisterCustomerDto {
1283
1307
  firstName?: string;
1284
1308
  lastName?: string;
1285
1309
  phone?: string;
1310
+ acceptsMarketing?: boolean;
1286
1311
  }
1287
1312
  type CartStatus = 'ACTIVE' | 'MERGED' | 'CONVERTED' | 'ABANDONED';
1288
1313
  /**
@@ -2707,6 +2732,8 @@ interface Category {
2707
2732
  platformMetadata?: Record<string, Record<string, unknown>> | null;
2708
2733
  parentId?: string | null;
2709
2734
  isActive: boolean;
2735
+ /** Tax behavior: 'taxable' follows store setting, 'exempt' always skips tax */
2736
+ taxBehavior?: 'taxable' | 'exempt';
2710
2737
  deletedAt?: string | null;
2711
2738
  productCount?: number;
2712
2739
  products?: Array<{
@@ -2723,11 +2750,13 @@ interface CreateCategoryDto {
2723
2750
  storeId?: string;
2724
2751
  source?: string;
2725
2752
  isActive?: boolean;
2753
+ taxBehavior?: 'taxable' | 'exempt';
2726
2754
  }
2727
2755
  interface UpdateCategoryDto {
2728
2756
  name?: string;
2729
2757
  parentId?: string | null;
2730
2758
  isActive?: boolean;
2759
+ taxBehavior?: 'taxable' | 'exempt';
2731
2760
  }
2732
2761
  /**
2733
2762
  * Brand entity for product organization
@@ -2817,6 +2846,7 @@ interface Attribute {
2817
2846
  accountId: string;
2818
2847
  storeId?: string | null;
2819
2848
  name: string;
2849
+ displayType?: string;
2820
2850
  source: AttributeSource;
2821
2851
  platform?: ConnectorPlatform | null;
2822
2852
  externalId?: string | null;
@@ -2833,6 +2863,9 @@ interface AttributeOption {
2833
2863
  attributeId: string;
2834
2864
  name: string;
2835
2865
  value?: string | null;
2866
+ swatchColor?: string | null;
2867
+ swatchColor2?: string | null;
2868
+ swatchImageUrl?: string | null;
2836
2869
  source: AttributeSource;
2837
2870
  platform?: ConnectorPlatform | null;
2838
2871
  externalId?: string | null;
@@ -2845,6 +2878,7 @@ interface AttributeOption {
2845
2878
  }
2846
2879
  interface CreateAttributeDto {
2847
2880
  name: string;
2881
+ displayType?: string;
2848
2882
  source: AttributeSource;
2849
2883
  platform?: ConnectorPlatform;
2850
2884
  storeId?: string;
@@ -2854,12 +2888,16 @@ interface CreateAttributeDto {
2854
2888
  }
2855
2889
  interface UpdateAttributeDto {
2856
2890
  name?: string;
2891
+ displayType?: string;
2857
2892
  platformMetadata?: Record<string, unknown>;
2858
2893
  isActive?: boolean;
2859
2894
  }
2860
2895
  interface CreateAttributeOptionDto {
2861
2896
  name: string;
2862
2897
  value?: string;
2898
+ swatchColor?: string;
2899
+ swatchColor2?: string;
2900
+ swatchImageUrl?: string;
2863
2901
  source: AttributeSource;
2864
2902
  platform?: ConnectorPlatform;
2865
2903
  externalId?: string;
@@ -2870,6 +2908,9 @@ interface CreateAttributeOptionDto {
2870
2908
  interface UpdateAttributeOptionDto {
2871
2909
  name?: string;
2872
2910
  value?: string;
2911
+ swatchColor?: string | null;
2912
+ swatchColor2?: string | null;
2913
+ swatchImageUrl?: string | null;
2873
2914
  platformMetadata?: Record<string, unknown>;
2874
2915
  position?: number;
2875
2916
  isActive?: boolean;
@@ -6486,6 +6527,8 @@ declare class BrainerceError extends Error {
6486
6527
  constructor(message: string, statusCode: number, details?: unknown);
6487
6528
  }
6488
6529
 
6530
+ declare const SDK_VERSION = "1.11.2";
6531
+
6489
6532
  /**
6490
6533
  * Verify a webhook signature from Brainerce
6491
6534
  *
@@ -6558,4 +6601,4 @@ declare function enableDevGuards(options?: {
6558
6601
  force?: boolean;
6559
6602
  }): void;
6560
6603
 
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 };
6604
+ 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, 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) {
@@ -5933,6 +5938,34 @@ function getVariantOptions(variant) {
5933
5938
  ]);
5934
5939
  return Object.entries(variant.attributes).filter(([key, value]) => typeof value === "string" && !internalKeys.has(key)).map(([name, value]) => ({ name, value }));
5935
5940
  }
5941
+ function getProductSwatches(product) {
5942
+ if (!product?.productAttributeOptions) return [];
5943
+ const grouped = /* @__PURE__ */ new Map();
5944
+ for (const pao of product.productAttributeOptions) {
5945
+ if (!pao.attribute || !pao.attributeOption) continue;
5946
+ const attrName = pao.attribute.name;
5947
+ if (!grouped.has(attrName)) {
5948
+ grouped.set(attrName, {
5949
+ displayType: pao.attribute.displayType || "DEFAULT",
5950
+ options: []
5951
+ });
5952
+ }
5953
+ const entry = grouped.get(attrName);
5954
+ if (!entry.options.some((o) => o.name === pao.attributeOption.name)) {
5955
+ entry.options.push({
5956
+ name: pao.attributeOption.name,
5957
+ value: pao.attributeOption.value,
5958
+ swatchColor: pao.attributeOption.swatchColor,
5959
+ swatchColor2: pao.attributeOption.swatchColor2,
5960
+ swatchImageUrl: pao.attributeOption.swatchImageUrl
5961
+ });
5962
+ }
5963
+ }
5964
+ return Array.from(grouped.entries()).map(([attributeName, data]) => ({
5965
+ attributeName,
5966
+ ...data
5967
+ }));
5968
+ }
5936
5969
  function getProductMetafield(product, key) {
5937
5970
  return product.metafields?.find((m) => m.definitionKey === key);
5938
5971
  }
@@ -5965,6 +5998,7 @@ function isCouponApplicableToProduct(coupon, productId) {
5965
5998
  0 && (module.exports = {
5966
5999
  BrainerceClient,
5967
6000
  BrainerceError,
6001
+ SDK_VERSION,
5968
6002
  createWebhookHandler,
5969
6003
  enableDevGuards,
5970
6004
  formatPrice,
@@ -5978,6 +6012,7 @@ function isCouponApplicableToProduct(coupon, productId) {
5978
6012
  getProductMetafieldsByType,
5979
6013
  getProductPrice,
5980
6014
  getProductPriceInfo,
6015
+ getProductSwatches,
5981
6016
  getStockStatus,
5982
6017
  getVariantOptions,
5983
6018
  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) {
@@ -5875,6 +5878,34 @@ function getVariantOptions(variant) {
5875
5878
  ]);
5876
5879
  return Object.entries(variant.attributes).filter(([key, value]) => typeof value === "string" && !internalKeys.has(key)).map(([name, value]) => ({ name, value }));
5877
5880
  }
5881
+ function getProductSwatches(product) {
5882
+ if (!product?.productAttributeOptions) return [];
5883
+ const grouped = /* @__PURE__ */ new Map();
5884
+ for (const pao of product.productAttributeOptions) {
5885
+ if (!pao.attribute || !pao.attributeOption) continue;
5886
+ const attrName = pao.attribute.name;
5887
+ if (!grouped.has(attrName)) {
5888
+ grouped.set(attrName, {
5889
+ displayType: pao.attribute.displayType || "DEFAULT",
5890
+ options: []
5891
+ });
5892
+ }
5893
+ const entry = grouped.get(attrName);
5894
+ if (!entry.options.some((o) => o.name === pao.attributeOption.name)) {
5895
+ entry.options.push({
5896
+ name: pao.attributeOption.name,
5897
+ value: pao.attributeOption.value,
5898
+ swatchColor: pao.attributeOption.swatchColor,
5899
+ swatchColor2: pao.attributeOption.swatchColor2,
5900
+ swatchImageUrl: pao.attributeOption.swatchImageUrl
5901
+ });
5902
+ }
5903
+ }
5904
+ return Array.from(grouped.entries()).map(([attributeName, data]) => ({
5905
+ attributeName,
5906
+ ...data
5907
+ }));
5908
+ }
5878
5909
  function getProductMetafield(product, key) {
5879
5910
  return product.metafields?.find((m) => m.definitionKey === key);
5880
5911
  }
@@ -5906,6 +5937,7 @@ function isCouponApplicableToProduct(coupon, productId) {
5906
5937
  export {
5907
5938
  BrainerceClient,
5908
5939
  BrainerceError,
5940
+ SDK_VERSION,
5909
5941
  createWebhookHandler,
5910
5942
  enableDevGuards,
5911
5943
  formatPrice,
@@ -5919,6 +5951,7 @@ export {
5919
5951
  getProductMetafieldsByType,
5920
5952
  getProductPrice,
5921
5953
  getProductPriceInfo,
5954
+ getProductSwatches,
5922
5955
  getStockStatus,
5923
5956
  getVariantOptions,
5924
5957
  getVariantPrice,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "brainerce",
3
- "version": "1.11.0",
3
+ "version": "1.11.3",
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",