brainerce 1.16.0 → 1.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -572,7 +572,7 @@ declare function getProductPrice(product: Pick<Product, 'basePrice' | 'salePrice
572
572
  * }
573
573
  * ```
574
574
  */
575
- declare function getProductPriceInfo(product: Pick<Product, 'basePrice' | 'salePrice'> | null | undefined): {
575
+ declare function getProductPriceInfo(product: Pick<Product, 'basePrice' | 'salePrice' | 'discount'> | null | undefined): {
576
576
  price: number;
577
577
  originalPrice: number;
578
578
  isOnSale: boolean;
@@ -3456,6 +3456,7 @@ interface EmailTemplate {
3456
3456
  storeId: string;
3457
3457
  name: string;
3458
3458
  eventType: EmailEventType;
3459
+ language: string;
3459
3460
  subject: string;
3460
3461
  htmlContent: string;
3461
3462
  textContent?: string | null;
@@ -3464,10 +3465,17 @@ interface EmailTemplate {
3464
3465
  createdAt: string;
3465
3466
  updatedAt: string;
3466
3467
  }
3468
+ /** Paginated response for email templates, grouped by (eventType, language). */
3469
+ interface EmailTemplatesResponse {
3470
+ templates: EmailTemplate[];
3471
+ language: string;
3472
+ supportedLanguages: string[];
3473
+ }
3467
3474
  /** DTO for creating an email template */
3468
3475
  interface CreateEmailTemplateDto {
3469
3476
  name: string;
3470
3477
  eventType: EmailEventType;
3478
+ language: string;
3471
3479
  subject: string;
3472
3480
  htmlContent: string;
3473
3481
  textContent?: string;
@@ -3580,7 +3588,7 @@ interface UpdateOAuthProviderDto {
3580
3588
  isEnabled?: boolean;
3581
3589
  providerConfig?: Record<string, unknown>;
3582
3590
  }
3583
- type DiscountRuleType = 'PERCENTAGE' | 'FIXED_AMOUNT' | 'BUY_X_GET_Y' | 'QUANTITY_DISCOUNT' | 'FREE_SHIPPING';
3591
+ type DiscountRuleType = 'PRODUCT_DISCOUNT' | 'ORDER_DISCOUNT' | 'BUY_X_GET_Y' | 'BUY_X_GET_X' | 'VOLUME_DISCOUNT' | 'SHIPPING_DISCOUNT' | 'BUNDLE';
3584
3592
  /** Discount that was automatically applied to the cart by a rule */
3585
3593
  interface CartAppliedDiscount {
3586
3594
  ruleId: string;
@@ -3988,7 +3996,9 @@ declare class BrainerceClient {
3988
3996
  * // Use tag IDs in getProducts({ tags: ['tag_id'] })
3989
3997
  * ```
3990
3998
  */
3991
- getTags(): Promise<{
3999
+ getTags(options?: {
4000
+ locale?: string;
4001
+ }): Promise<{
3992
4002
  tags: Array<{
3993
4003
  id: string;
3994
4004
  name: string;
@@ -6798,10 +6808,12 @@ declare class BrainerceClient {
6798
6808
  */
6799
6809
  updateEmailSettings(data: UpdateEmailSettingsDto): Promise<EmailSettings>;
6800
6810
  /**
6801
- * Get all email templates for the store
6811
+ * Get all email templates for the store, grouped by (eventType, language).
6812
+ * Response includes the store's primary language and supported languages so
6813
+ * the caller can render a locale selector.
6802
6814
  * Requires Admin mode (apiKey)
6803
6815
  */
6804
- getEmailTemplates(): Promise<EmailTemplate[]>;
6816
+ getEmailTemplates(): Promise<EmailTemplatesResponse>;
6805
6817
  /**
6806
6818
  * Get a specific email template
6807
6819
  * Requires Admin mode (apiKey)
@@ -6987,4 +6999,4 @@ declare function enableDevGuards(options?: {
6987
6999
  force?: boolean;
6988
7000
  }): void;
6989
7001
 
6990
- 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 CheckoutCustomFieldDefinition, type CheckoutFieldPricing, type CheckoutFieldVisibility, 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 LockedVariant, 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 ProductCustomizationField, 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 RecommendationVariant, 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 SetCheckoutCustomFieldsDto, 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, getProductCustomizationFields, getProductMetafield, getProductMetafieldValue, getProductMetafieldsByType, getProductPrice, getProductPriceInfo, getProductSwatches, getStockStatus, getVariantOptions, getVariantPrice, isCouponApplicableToProduct, isHtmlDescription, isWebhookEventType, parseWebhookEvent, verifyWebhook };
7002
+ 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 CheckoutCustomFieldDefinition, type CheckoutFieldPricing, type CheckoutFieldVisibility, 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 EmailTemplatesResponse, 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 LockedVariant, 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 ProductCustomizationField, 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 RecommendationVariant, 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 SetCheckoutCustomFieldsDto, 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, getProductCustomizationFields, getProductMetafield, getProductMetafieldValue, getProductMetafieldsByType, getProductPrice, getProductPriceInfo, getProductSwatches, getStockStatus, getVariantOptions, getVariantPrice, isCouponApplicableToProduct, isHtmlDescription, isWebhookEventType, parseWebhookEvent, verifyWebhook };
package/dist/index.d.ts CHANGED
@@ -572,7 +572,7 @@ declare function getProductPrice(product: Pick<Product, 'basePrice' | 'salePrice
572
572
  * }
573
573
  * ```
574
574
  */
575
- declare function getProductPriceInfo(product: Pick<Product, 'basePrice' | 'salePrice'> | null | undefined): {
575
+ declare function getProductPriceInfo(product: Pick<Product, 'basePrice' | 'salePrice' | 'discount'> | null | undefined): {
576
576
  price: number;
577
577
  originalPrice: number;
578
578
  isOnSale: boolean;
@@ -3456,6 +3456,7 @@ interface EmailTemplate {
3456
3456
  storeId: string;
3457
3457
  name: string;
3458
3458
  eventType: EmailEventType;
3459
+ language: string;
3459
3460
  subject: string;
3460
3461
  htmlContent: string;
3461
3462
  textContent?: string | null;
@@ -3464,10 +3465,17 @@ interface EmailTemplate {
3464
3465
  createdAt: string;
3465
3466
  updatedAt: string;
3466
3467
  }
3468
+ /** Paginated response for email templates, grouped by (eventType, language). */
3469
+ interface EmailTemplatesResponse {
3470
+ templates: EmailTemplate[];
3471
+ language: string;
3472
+ supportedLanguages: string[];
3473
+ }
3467
3474
  /** DTO for creating an email template */
3468
3475
  interface CreateEmailTemplateDto {
3469
3476
  name: string;
3470
3477
  eventType: EmailEventType;
3478
+ language: string;
3471
3479
  subject: string;
3472
3480
  htmlContent: string;
3473
3481
  textContent?: string;
@@ -3580,7 +3588,7 @@ interface UpdateOAuthProviderDto {
3580
3588
  isEnabled?: boolean;
3581
3589
  providerConfig?: Record<string, unknown>;
3582
3590
  }
3583
- type DiscountRuleType = 'PERCENTAGE' | 'FIXED_AMOUNT' | 'BUY_X_GET_Y' | 'QUANTITY_DISCOUNT' | 'FREE_SHIPPING';
3591
+ type DiscountRuleType = 'PRODUCT_DISCOUNT' | 'ORDER_DISCOUNT' | 'BUY_X_GET_Y' | 'BUY_X_GET_X' | 'VOLUME_DISCOUNT' | 'SHIPPING_DISCOUNT' | 'BUNDLE';
3584
3592
  /** Discount that was automatically applied to the cart by a rule */
3585
3593
  interface CartAppliedDiscount {
3586
3594
  ruleId: string;
@@ -3988,7 +3996,9 @@ declare class BrainerceClient {
3988
3996
  * // Use tag IDs in getProducts({ tags: ['tag_id'] })
3989
3997
  * ```
3990
3998
  */
3991
- getTags(): Promise<{
3999
+ getTags(options?: {
4000
+ locale?: string;
4001
+ }): Promise<{
3992
4002
  tags: Array<{
3993
4003
  id: string;
3994
4004
  name: string;
@@ -6798,10 +6808,12 @@ declare class BrainerceClient {
6798
6808
  */
6799
6809
  updateEmailSettings(data: UpdateEmailSettingsDto): Promise<EmailSettings>;
6800
6810
  /**
6801
- * Get all email templates for the store
6811
+ * Get all email templates for the store, grouped by (eventType, language).
6812
+ * Response includes the store's primary language and supported languages so
6813
+ * the caller can render a locale selector.
6802
6814
  * Requires Admin mode (apiKey)
6803
6815
  */
6804
- getEmailTemplates(): Promise<EmailTemplate[]>;
6816
+ getEmailTemplates(): Promise<EmailTemplatesResponse>;
6805
6817
  /**
6806
6818
  * Get a specific email template
6807
6819
  * Requires Admin mode (apiKey)
@@ -6987,4 +6999,4 @@ declare function enableDevGuards(options?: {
6987
6999
  force?: boolean;
6988
7000
  }): void;
6989
7001
 
6990
- 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 CheckoutCustomFieldDefinition, type CheckoutFieldPricing, type CheckoutFieldVisibility, 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 LockedVariant, 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 ProductCustomizationField, 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 RecommendationVariant, 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 SetCheckoutCustomFieldsDto, 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, getProductCustomizationFields, getProductMetafield, getProductMetafieldValue, getProductMetafieldsByType, getProductPrice, getProductPriceInfo, getProductSwatches, getStockStatus, getVariantOptions, getVariantPrice, isCouponApplicableToProduct, isHtmlDescription, isWebhookEventType, parseWebhookEvent, verifyWebhook };
7002
+ 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 CheckoutCustomFieldDefinition, type CheckoutFieldPricing, type CheckoutFieldVisibility, 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 EmailTemplatesResponse, 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 LockedVariant, 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 ProductCustomizationField, 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 RecommendationVariant, 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 SetCheckoutCustomFieldsDto, 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, getProductCustomizationFields, getProductMetafield, getProductMetafieldValue, getProductMetafieldsByType, getProductPrice, getProductPriceInfo, getProductSwatches, getStockStatus, getVariantOptions, getVariantPrice, isCouponApplicableToProduct, isHtmlDescription, isWebhookEventType, parseWebhookEvent, verifyWebhook };
package/dist/index.js CHANGED
@@ -386,6 +386,9 @@ var BrainerceClient = class {
386
386
  if (this.origin) {
387
387
  headers["Origin"] = this.origin;
388
388
  }
389
+ if (this.locale) {
390
+ headers["Accept-Language"] = this.locale;
391
+ }
389
392
  const response = await fetch(url.toString(), {
390
393
  method,
391
394
  headers,
@@ -421,7 +424,7 @@ var BrainerceClient = class {
421
424
  /**
422
425
  * Make a request to the Vibe-Coded API (public, uses connectionId)
423
426
  */
424
- async vibeCodedRequest(method, path, body, queryParams) {
427
+ async vibeCodedRequest(method, path, body, queryParams, headerOverrides) {
425
428
  if (!this.connectionId) {
426
429
  throw new BrainerceError("connectionId is required for vibe-coded requests", 400);
427
430
  }
@@ -444,6 +447,12 @@ var BrainerceClient = class {
444
447
  if (this.origin) {
445
448
  headers["Origin"] = this.origin;
446
449
  }
450
+ if (this.locale) {
451
+ headers["Accept-Language"] = this.locale;
452
+ }
453
+ if (headerOverrides) {
454
+ Object.assign(headers, headerOverrides);
455
+ }
447
456
  if (this.proxyMode && method !== "GET") {
448
457
  headers["X-Requested-With"] = "brainerce";
449
458
  }
@@ -492,7 +501,7 @@ var BrainerceClient = class {
492
501
  /**
493
502
  * Make a request to the Storefront API (public, uses storeId)
494
503
  */
495
- async storefrontRequest(method, path, body, queryParams) {
504
+ async storefrontRequest(method, path, body, queryParams, headerOverrides) {
496
505
  if (!this.storeId) {
497
506
  throw new BrainerceError("storeId is required for storefront requests", 400);
498
507
  }
@@ -515,6 +524,12 @@ var BrainerceClient = class {
515
524
  if (this.origin) {
516
525
  headers["Origin"] = this.origin;
517
526
  }
527
+ if (this.locale) {
528
+ headers["Accept-Language"] = this.locale;
529
+ }
530
+ if (headerOverrides) {
531
+ Object.assign(headers, headerOverrides);
532
+ }
518
533
  if (this.customerToken) {
519
534
  headers["Authorization"] = `Bearer ${this.customerToken}`;
520
535
  }
@@ -616,7 +631,6 @@ var BrainerceClient = class {
616
631
  maxPrice: params?.maxPrice,
617
632
  sortBy: params?.sortBy,
618
633
  sortOrder: params?.sortOrder,
619
- locale: params?.locale || this.locale,
620
634
  // Admin-only params
621
635
  type: params?.type
622
636
  };
@@ -648,13 +662,14 @@ var BrainerceClient = class {
648
662
  * Works in vibe-coded, storefront (public), and admin mode
649
663
  */
650
664
  async getProduct(productId, options) {
651
- const localeParams = { locale: options?.locale || this.locale };
665
+ const headerOverrides = options?.locale ? { "Accept-Language": options.locale } : void 0;
652
666
  if (this.isVibeCodedMode()) {
653
667
  return this.vibeCodedRequest(
654
668
  "GET",
655
669
  `/products/${productId}`,
656
670
  void 0,
657
- localeParams
671
+ void 0,
672
+ headerOverrides
658
673
  );
659
674
  }
660
675
  if (this.storeId && !this.apiKey) {
@@ -662,7 +677,8 @@ var BrainerceClient = class {
662
677
  "GET",
663
678
  `/products/${productId}`,
664
679
  void 0,
665
- localeParams
680
+ void 0,
681
+ headerOverrides
666
682
  );
667
683
  }
668
684
  return this.adminRequest("GET", `/api/v1/products/${productId}`);
@@ -678,13 +694,14 @@ var BrainerceClient = class {
678
694
  * ```
679
695
  */
680
696
  async getProductBySlug(slug, options) {
681
- const localeParams = { locale: options?.locale || this.locale };
697
+ const headerOverrides = options?.locale ? { "Accept-Language": options.locale } : void 0;
682
698
  if (this.isVibeCodedMode()) {
683
699
  return this.vibeCodedRequest(
684
700
  "GET",
685
701
  `/products/slug/${slug}`,
686
702
  void 0,
687
- localeParams
703
+ void 0,
704
+ headerOverrides
688
705
  );
689
706
  }
690
707
  if (this.storeId && !this.apiKey) {
@@ -692,7 +709,8 @@ var BrainerceClient = class {
692
709
  "GET",
693
710
  `/products/slug/${slug}`,
694
711
  void 0,
695
- localeParams
712
+ void 0,
713
+ headerOverrides
696
714
  );
697
715
  }
698
716
  return this.adminRequest("GET", `/api/v1/products/by-slug/${slug}`);
@@ -708,9 +726,9 @@ var BrainerceClient = class {
708
726
  * ```
709
727
  */
710
728
  async getCategories(options) {
711
- const localeParams = { locale: options?.locale || this.locale };
729
+ const headerOverrides = options?.locale ? { "Accept-Language": options.locale } : void 0;
712
730
  if (this.isVibeCodedMode()) {
713
- return this.vibeCodedRequest("GET", "/categories", void 0, localeParams);
731
+ return this.vibeCodedRequest("GET", "/categories", void 0, void 0, headerOverrides);
714
732
  }
715
733
  throw new BrainerceError("getCategories is only available in vibe-coded mode", 400);
716
734
  }
@@ -725,9 +743,9 @@ var BrainerceClient = class {
725
743
  * ```
726
744
  */
727
745
  async getBrands(options) {
728
- const localeParams = { locale: options?.locale || this.locale };
746
+ const headerOverrides = options?.locale ? { "Accept-Language": options.locale } : void 0;
729
747
  if (this.isVibeCodedMode()) {
730
- return this.vibeCodedRequest("GET", "/brands", void 0, localeParams);
748
+ return this.vibeCodedRequest("GET", "/brands", void 0, void 0, headerOverrides);
731
749
  }
732
750
  throw new BrainerceError("getBrands is only available in vibe-coded mode", 400);
733
751
  }
@@ -741,11 +759,10 @@ var BrainerceClient = class {
741
759
  * // Use tag IDs in getProducts({ tags: ['tag_id'] })
742
760
  * ```
743
761
  */
744
- async getTags() {
762
+ async getTags(options) {
763
+ const headerOverrides = options?.locale ? { "Accept-Language": options.locale } : void 0;
745
764
  if (this.isVibeCodedMode()) {
746
- return this.vibeCodedRequest("GET", "/tags", void 0, {
747
- locale: this.locale
748
- });
765
+ return this.vibeCodedRequest("GET", "/tags", void 0, void 0, headerOverrides);
749
766
  }
750
767
  throw new BrainerceError("getTags is only available in vibe-coded mode", 400);
751
768
  }
@@ -789,7 +806,7 @@ var BrainerceClient = class {
789
806
  if (!query || query.trim().length === 0) {
790
807
  return { products: [], categories: [] };
791
808
  }
792
- const queryParams = { q: query, limit, locale: this.locale };
809
+ const queryParams = { q: query, limit };
793
810
  if (this.isVibeCodedMode()) {
794
811
  return this.vibeCodedRequest(
795
812
  "GET",
@@ -2451,17 +2468,21 @@ var BrainerceClient = class {
2451
2468
  * ```
2452
2469
  */
2453
2470
  async getProductRecommendations(productId, type) {
2454
- const params = type ? `?type=${type}` : "";
2471
+ const queryParams = type ? { type } : void 0;
2455
2472
  if (this.isVibeCodedMode()) {
2456
2473
  return this.vibeCodedRequest(
2457
2474
  "GET",
2458
- `/products/${productId}/recommendations${params}`
2475
+ `/products/${productId}/recommendations`,
2476
+ void 0,
2477
+ queryParams
2459
2478
  );
2460
2479
  }
2461
2480
  if (this.storeId && !this.apiKey) {
2462
2481
  return this.storefrontRequest(
2463
2482
  "GET",
2464
- `/products/${productId}/recommendations${params}`
2483
+ `/products/${productId}/recommendations`,
2484
+ void 0,
2485
+ queryParams
2465
2486
  );
2466
2487
  }
2467
2488
  throw new BrainerceError(
@@ -2485,17 +2506,21 @@ var BrainerceClient = class {
2485
2506
  * ```
2486
2507
  */
2487
2508
  async getCartRecommendations(cartId, limit) {
2488
- const params = limit ? `?limit=${limit}` : "";
2509
+ const queryParams = limit ? { limit } : void 0;
2489
2510
  if (this.isVibeCodedMode()) {
2490
2511
  return this.vibeCodedRequest(
2491
2512
  "GET",
2492
- `/cart/${cartId}/recommendations${params}`
2513
+ `/cart/${cartId}/recommendations`,
2514
+ void 0,
2515
+ queryParams
2493
2516
  );
2494
2517
  }
2495
2518
  if (this.storeId && !this.apiKey) {
2496
2519
  return this.storefrontRequest(
2497
2520
  "GET",
2498
- `/cart/${cartId}/recommendations${params}`
2521
+ `/cart/${cartId}/recommendations`,
2522
+ void 0,
2523
+ queryParams
2499
2524
  );
2500
2525
  }
2501
2526
  throw new BrainerceError(
@@ -5890,7 +5915,9 @@ var BrainerceClient = class {
5890
5915
  return this.adminRequest("PUT", "/api/v1/email/settings", data);
5891
5916
  }
5892
5917
  /**
5893
- * Get all email templates for the store
5918
+ * Get all email templates for the store, grouped by (eventType, language).
5919
+ * Response includes the store's primary language and supported languages so
5920
+ * the caller can render a locale selector.
5894
5921
  * Requires Admin mode (apiKey)
5895
5922
  */
5896
5923
  async getEmailTemplates() {
@@ -6195,6 +6222,19 @@ function getProductPriceInfo(product) {
6195
6222
  if (!product) {
6196
6223
  return { price: 0, originalPrice: 0, isOnSale: false, discountAmount: 0, discountPercent: 0 };
6197
6224
  }
6225
+ if (product.discount) {
6226
+ const ruleOriginal = parseFloat(product.discount.originalPrice) || 0;
6227
+ const ruleDiscounted = parseFloat(product.discount.discountedPrice) || 0;
6228
+ const ruleAmount = Math.max(0, ruleOriginal - ruleDiscounted);
6229
+ const rulePercent = ruleOriginal > 0 ? Math.round(ruleAmount / ruleOriginal * 100) : 0;
6230
+ return {
6231
+ price: ruleDiscounted,
6232
+ originalPrice: ruleOriginal,
6233
+ isOnSale: ruleDiscounted < ruleOriginal,
6234
+ discountAmount: ruleAmount,
6235
+ discountPercent: rulePercent
6236
+ };
6237
+ }
6198
6238
  const basePrice = parseFloat(product.basePrice) || 0;
6199
6239
  const salePrice = product.salePrice ? parseFloat(product.salePrice) : null;
6200
6240
  const isOnSale = salePrice !== null && salePrice < basePrice;
package/dist/index.mjs CHANGED
@@ -325,6 +325,9 @@ var BrainerceClient = class {
325
325
  if (this.origin) {
326
326
  headers["Origin"] = this.origin;
327
327
  }
328
+ if (this.locale) {
329
+ headers["Accept-Language"] = this.locale;
330
+ }
328
331
  const response = await fetch(url.toString(), {
329
332
  method,
330
333
  headers,
@@ -360,7 +363,7 @@ var BrainerceClient = class {
360
363
  /**
361
364
  * Make a request to the Vibe-Coded API (public, uses connectionId)
362
365
  */
363
- async vibeCodedRequest(method, path, body, queryParams) {
366
+ async vibeCodedRequest(method, path, body, queryParams, headerOverrides) {
364
367
  if (!this.connectionId) {
365
368
  throw new BrainerceError("connectionId is required for vibe-coded requests", 400);
366
369
  }
@@ -383,6 +386,12 @@ var BrainerceClient = class {
383
386
  if (this.origin) {
384
387
  headers["Origin"] = this.origin;
385
388
  }
389
+ if (this.locale) {
390
+ headers["Accept-Language"] = this.locale;
391
+ }
392
+ if (headerOverrides) {
393
+ Object.assign(headers, headerOverrides);
394
+ }
386
395
  if (this.proxyMode && method !== "GET") {
387
396
  headers["X-Requested-With"] = "brainerce";
388
397
  }
@@ -431,7 +440,7 @@ var BrainerceClient = class {
431
440
  /**
432
441
  * Make a request to the Storefront API (public, uses storeId)
433
442
  */
434
- async storefrontRequest(method, path, body, queryParams) {
443
+ async storefrontRequest(method, path, body, queryParams, headerOverrides) {
435
444
  if (!this.storeId) {
436
445
  throw new BrainerceError("storeId is required for storefront requests", 400);
437
446
  }
@@ -454,6 +463,12 @@ var BrainerceClient = class {
454
463
  if (this.origin) {
455
464
  headers["Origin"] = this.origin;
456
465
  }
466
+ if (this.locale) {
467
+ headers["Accept-Language"] = this.locale;
468
+ }
469
+ if (headerOverrides) {
470
+ Object.assign(headers, headerOverrides);
471
+ }
457
472
  if (this.customerToken) {
458
473
  headers["Authorization"] = `Bearer ${this.customerToken}`;
459
474
  }
@@ -555,7 +570,6 @@ var BrainerceClient = class {
555
570
  maxPrice: params?.maxPrice,
556
571
  sortBy: params?.sortBy,
557
572
  sortOrder: params?.sortOrder,
558
- locale: params?.locale || this.locale,
559
573
  // Admin-only params
560
574
  type: params?.type
561
575
  };
@@ -587,13 +601,14 @@ var BrainerceClient = class {
587
601
  * Works in vibe-coded, storefront (public), and admin mode
588
602
  */
589
603
  async getProduct(productId, options) {
590
- const localeParams = { locale: options?.locale || this.locale };
604
+ const headerOverrides = options?.locale ? { "Accept-Language": options.locale } : void 0;
591
605
  if (this.isVibeCodedMode()) {
592
606
  return this.vibeCodedRequest(
593
607
  "GET",
594
608
  `/products/${productId}`,
595
609
  void 0,
596
- localeParams
610
+ void 0,
611
+ headerOverrides
597
612
  );
598
613
  }
599
614
  if (this.storeId && !this.apiKey) {
@@ -601,7 +616,8 @@ var BrainerceClient = class {
601
616
  "GET",
602
617
  `/products/${productId}`,
603
618
  void 0,
604
- localeParams
619
+ void 0,
620
+ headerOverrides
605
621
  );
606
622
  }
607
623
  return this.adminRequest("GET", `/api/v1/products/${productId}`);
@@ -617,13 +633,14 @@ var BrainerceClient = class {
617
633
  * ```
618
634
  */
619
635
  async getProductBySlug(slug, options) {
620
- const localeParams = { locale: options?.locale || this.locale };
636
+ const headerOverrides = options?.locale ? { "Accept-Language": options.locale } : void 0;
621
637
  if (this.isVibeCodedMode()) {
622
638
  return this.vibeCodedRequest(
623
639
  "GET",
624
640
  `/products/slug/${slug}`,
625
641
  void 0,
626
- localeParams
642
+ void 0,
643
+ headerOverrides
627
644
  );
628
645
  }
629
646
  if (this.storeId && !this.apiKey) {
@@ -631,7 +648,8 @@ var BrainerceClient = class {
631
648
  "GET",
632
649
  `/products/slug/${slug}`,
633
650
  void 0,
634
- localeParams
651
+ void 0,
652
+ headerOverrides
635
653
  );
636
654
  }
637
655
  return this.adminRequest("GET", `/api/v1/products/by-slug/${slug}`);
@@ -647,9 +665,9 @@ var BrainerceClient = class {
647
665
  * ```
648
666
  */
649
667
  async getCategories(options) {
650
- const localeParams = { locale: options?.locale || this.locale };
668
+ const headerOverrides = options?.locale ? { "Accept-Language": options.locale } : void 0;
651
669
  if (this.isVibeCodedMode()) {
652
- return this.vibeCodedRequest("GET", "/categories", void 0, localeParams);
670
+ return this.vibeCodedRequest("GET", "/categories", void 0, void 0, headerOverrides);
653
671
  }
654
672
  throw new BrainerceError("getCategories is only available in vibe-coded mode", 400);
655
673
  }
@@ -664,9 +682,9 @@ var BrainerceClient = class {
664
682
  * ```
665
683
  */
666
684
  async getBrands(options) {
667
- const localeParams = { locale: options?.locale || this.locale };
685
+ const headerOverrides = options?.locale ? { "Accept-Language": options.locale } : void 0;
668
686
  if (this.isVibeCodedMode()) {
669
- return this.vibeCodedRequest("GET", "/brands", void 0, localeParams);
687
+ return this.vibeCodedRequest("GET", "/brands", void 0, void 0, headerOverrides);
670
688
  }
671
689
  throw new BrainerceError("getBrands is only available in vibe-coded mode", 400);
672
690
  }
@@ -680,11 +698,10 @@ var BrainerceClient = class {
680
698
  * // Use tag IDs in getProducts({ tags: ['tag_id'] })
681
699
  * ```
682
700
  */
683
- async getTags() {
701
+ async getTags(options) {
702
+ const headerOverrides = options?.locale ? { "Accept-Language": options.locale } : void 0;
684
703
  if (this.isVibeCodedMode()) {
685
- return this.vibeCodedRequest("GET", "/tags", void 0, {
686
- locale: this.locale
687
- });
704
+ return this.vibeCodedRequest("GET", "/tags", void 0, void 0, headerOverrides);
688
705
  }
689
706
  throw new BrainerceError("getTags is only available in vibe-coded mode", 400);
690
707
  }
@@ -728,7 +745,7 @@ var BrainerceClient = class {
728
745
  if (!query || query.trim().length === 0) {
729
746
  return { products: [], categories: [] };
730
747
  }
731
- const queryParams = { q: query, limit, locale: this.locale };
748
+ const queryParams = { q: query, limit };
732
749
  if (this.isVibeCodedMode()) {
733
750
  return this.vibeCodedRequest(
734
751
  "GET",
@@ -2390,17 +2407,21 @@ var BrainerceClient = class {
2390
2407
  * ```
2391
2408
  */
2392
2409
  async getProductRecommendations(productId, type) {
2393
- const params = type ? `?type=${type}` : "";
2410
+ const queryParams = type ? { type } : void 0;
2394
2411
  if (this.isVibeCodedMode()) {
2395
2412
  return this.vibeCodedRequest(
2396
2413
  "GET",
2397
- `/products/${productId}/recommendations${params}`
2414
+ `/products/${productId}/recommendations`,
2415
+ void 0,
2416
+ queryParams
2398
2417
  );
2399
2418
  }
2400
2419
  if (this.storeId && !this.apiKey) {
2401
2420
  return this.storefrontRequest(
2402
2421
  "GET",
2403
- `/products/${productId}/recommendations${params}`
2422
+ `/products/${productId}/recommendations`,
2423
+ void 0,
2424
+ queryParams
2404
2425
  );
2405
2426
  }
2406
2427
  throw new BrainerceError(
@@ -2424,17 +2445,21 @@ var BrainerceClient = class {
2424
2445
  * ```
2425
2446
  */
2426
2447
  async getCartRecommendations(cartId, limit) {
2427
- const params = limit ? `?limit=${limit}` : "";
2448
+ const queryParams = limit ? { limit } : void 0;
2428
2449
  if (this.isVibeCodedMode()) {
2429
2450
  return this.vibeCodedRequest(
2430
2451
  "GET",
2431
- `/cart/${cartId}/recommendations${params}`
2452
+ `/cart/${cartId}/recommendations`,
2453
+ void 0,
2454
+ queryParams
2432
2455
  );
2433
2456
  }
2434
2457
  if (this.storeId && !this.apiKey) {
2435
2458
  return this.storefrontRequest(
2436
2459
  "GET",
2437
- `/cart/${cartId}/recommendations${params}`
2460
+ `/cart/${cartId}/recommendations`,
2461
+ void 0,
2462
+ queryParams
2438
2463
  );
2439
2464
  }
2440
2465
  throw new BrainerceError(
@@ -5829,7 +5854,9 @@ var BrainerceClient = class {
5829
5854
  return this.adminRequest("PUT", "/api/v1/email/settings", data);
5830
5855
  }
5831
5856
  /**
5832
- * Get all email templates for the store
5857
+ * Get all email templates for the store, grouped by (eventType, language).
5858
+ * Response includes the store's primary language and supported languages so
5859
+ * the caller can render a locale selector.
5833
5860
  * Requires Admin mode (apiKey)
5834
5861
  */
5835
5862
  async getEmailTemplates() {
@@ -6134,6 +6161,19 @@ function getProductPriceInfo(product) {
6134
6161
  if (!product) {
6135
6162
  return { price: 0, originalPrice: 0, isOnSale: false, discountAmount: 0, discountPercent: 0 };
6136
6163
  }
6164
+ if (product.discount) {
6165
+ const ruleOriginal = parseFloat(product.discount.originalPrice) || 0;
6166
+ const ruleDiscounted = parseFloat(product.discount.discountedPrice) || 0;
6167
+ const ruleAmount = Math.max(0, ruleOriginal - ruleDiscounted);
6168
+ const rulePercent = ruleOriginal > 0 ? Math.round(ruleAmount / ruleOriginal * 100) : 0;
6169
+ return {
6170
+ price: ruleDiscounted,
6171
+ originalPrice: ruleOriginal,
6172
+ isOnSale: ruleDiscounted < ruleOriginal,
6173
+ discountAmount: ruleAmount,
6174
+ discountPercent: rulePercent
6175
+ };
6176
+ }
6137
6177
  const basePrice = parseFloat(product.basePrice) || 0;
6138
6178
  const salePrice = product.salePrice ? parseFloat(product.salePrice) : null;
6139
6179
  const isOnSale = salePrice !== null && salePrice < basePrice;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "brainerce",
3
- "version": "1.16.0",
3
+ "version": "1.17.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",