brainerce 1.4.1 → 1.6.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
@@ -73,6 +73,26 @@ interface BrainerceClientOptions {
73
73
  statusCode: number;
74
74
  path?: string;
75
75
  }) => void;
76
+ /**
77
+ * Enable proxy mode for BFF (Backend-for-Frontend) pattern.
78
+ * When true, the SDK skips client-side customer token checks and does not
79
+ * add Authorization headers for customer requests. A server-side proxy
80
+ * is expected to handle authentication via httpOnly cookies.
81
+ *
82
+ * @example
83
+ * ```typescript
84
+ * // Next.js template with BFF proxy
85
+ * const client = new BrainerceClient({
86
+ * connectionId: 'vc_abc123...',
87
+ * baseUrl: '/api/store', // same-origin proxy
88
+ * proxyMode: true,
89
+ * });
90
+ *
91
+ * // Customer methods work without calling setCustomerToken()
92
+ * const profile = await client.getMyProfile();
93
+ * ```
94
+ */
95
+ proxyMode?: boolean;
76
96
  }
77
97
  interface StoreInfo {
78
98
  id: string;
@@ -662,6 +682,25 @@ interface ProductSuggestion {
662
682
  salePrice?: string | null;
663
683
  type: 'SIMPLE' | 'VARIABLE';
664
684
  }
685
+ /**
686
+ * Category node in the tree returned by `getCategories()`.
687
+ * Categories can be nested to any depth via `children`.
688
+ *
689
+ * @example
690
+ * ```typescript
691
+ * const { categories } = await client.getCategories();
692
+ * // Each category has children which are also CategoryNode[]
693
+ * categories.forEach(cat => {
694
+ * console.log(cat.name, cat.children.length);
695
+ * });
696
+ * ```
697
+ */
698
+ interface CategoryNode {
699
+ id: string;
700
+ name: string;
701
+ parentId?: string | null;
702
+ children: CategoryNode[];
703
+ }
665
704
  /**
666
705
  * Category suggestion for autocomplete.
667
706
  *
@@ -3468,6 +3507,7 @@ declare class BrainerceClient {
3468
3507
  * This is needed because Stripe redirects lose in-memory state.
3469
3508
  */
3470
3509
  private readonly ACTIVE_CHECKOUT_KEY;
3510
+ private readonly proxyMode;
3471
3511
  private readonly onAuthError?;
3472
3512
  constructor(options: BrainerceClientOptions);
3473
3513
  /**
@@ -3582,12 +3622,7 @@ declare class BrainerceClient {
3582
3622
  * ```
3583
3623
  */
3584
3624
  getCategories(): Promise<{
3585
- categories: Array<{
3586
- id: string;
3587
- name: string;
3588
- parentId?: string;
3589
- children?: unknown[];
3590
- }>;
3625
+ categories: CategoryNode[];
3591
3626
  }>;
3592
3627
  /**
3593
3628
  * Get available brands for filtering products
@@ -4225,8 +4260,14 @@ declare class BrainerceClient {
4225
4260
  /**
4226
4261
  * Request a password reset email for a customer
4227
4262
  * Works in vibe-coded, storefront, and admin mode
4263
+ *
4264
+ * @param email - Customer email address
4265
+ * @param options - Optional settings
4266
+ * @param options.resetUrl - Override the auto-detected reset URL (e.g. for BFF proxy callback)
4228
4267
  */
4229
- forgotPassword(email: string): Promise<{
4268
+ forgotPassword(email: string, options?: {
4269
+ resetUrl?: string;
4270
+ }): Promise<{
4230
4271
  message: string;
4231
4272
  }>;
4232
4273
  /**
@@ -6444,4 +6485,4 @@ declare function enableDevGuards(options?: {
6444
6485
  force?: boolean;
6445
6486
  }): void;
6446
6487
 
6447
- 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 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 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 };
6488
+ 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 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 };
package/dist/index.d.ts CHANGED
@@ -73,6 +73,26 @@ interface BrainerceClientOptions {
73
73
  statusCode: number;
74
74
  path?: string;
75
75
  }) => void;
76
+ /**
77
+ * Enable proxy mode for BFF (Backend-for-Frontend) pattern.
78
+ * When true, the SDK skips client-side customer token checks and does not
79
+ * add Authorization headers for customer requests. A server-side proxy
80
+ * is expected to handle authentication via httpOnly cookies.
81
+ *
82
+ * @example
83
+ * ```typescript
84
+ * // Next.js template with BFF proxy
85
+ * const client = new BrainerceClient({
86
+ * connectionId: 'vc_abc123...',
87
+ * baseUrl: '/api/store', // same-origin proxy
88
+ * proxyMode: true,
89
+ * });
90
+ *
91
+ * // Customer methods work without calling setCustomerToken()
92
+ * const profile = await client.getMyProfile();
93
+ * ```
94
+ */
95
+ proxyMode?: boolean;
76
96
  }
77
97
  interface StoreInfo {
78
98
  id: string;
@@ -662,6 +682,25 @@ interface ProductSuggestion {
662
682
  salePrice?: string | null;
663
683
  type: 'SIMPLE' | 'VARIABLE';
664
684
  }
685
+ /**
686
+ * Category node in the tree returned by `getCategories()`.
687
+ * Categories can be nested to any depth via `children`.
688
+ *
689
+ * @example
690
+ * ```typescript
691
+ * const { categories } = await client.getCategories();
692
+ * // Each category has children which are also CategoryNode[]
693
+ * categories.forEach(cat => {
694
+ * console.log(cat.name, cat.children.length);
695
+ * });
696
+ * ```
697
+ */
698
+ interface CategoryNode {
699
+ id: string;
700
+ name: string;
701
+ parentId?: string | null;
702
+ children: CategoryNode[];
703
+ }
665
704
  /**
666
705
  * Category suggestion for autocomplete.
667
706
  *
@@ -3468,6 +3507,7 @@ declare class BrainerceClient {
3468
3507
  * This is needed because Stripe redirects lose in-memory state.
3469
3508
  */
3470
3509
  private readonly ACTIVE_CHECKOUT_KEY;
3510
+ private readonly proxyMode;
3471
3511
  private readonly onAuthError?;
3472
3512
  constructor(options: BrainerceClientOptions);
3473
3513
  /**
@@ -3582,12 +3622,7 @@ declare class BrainerceClient {
3582
3622
  * ```
3583
3623
  */
3584
3624
  getCategories(): Promise<{
3585
- categories: Array<{
3586
- id: string;
3587
- name: string;
3588
- parentId?: string;
3589
- children?: unknown[];
3590
- }>;
3625
+ categories: CategoryNode[];
3591
3626
  }>;
3592
3627
  /**
3593
3628
  * Get available brands for filtering products
@@ -4225,8 +4260,14 @@ declare class BrainerceClient {
4225
4260
  /**
4226
4261
  * Request a password reset email for a customer
4227
4262
  * Works in vibe-coded, storefront, and admin mode
4263
+ *
4264
+ * @param email - Customer email address
4265
+ * @param options - Optional settings
4266
+ * @param options.resetUrl - Override the auto-detected reset URL (e.g. for BFF proxy callback)
4228
4267
  */
4229
- forgotPassword(email: string): Promise<{
4268
+ forgotPassword(email: string, options?: {
4269
+ resetUrl?: string;
4270
+ }): Promise<{
4230
4271
  message: string;
4231
4272
  }>;
4232
4273
  /**
@@ -6444,4 +6485,4 @@ declare function enableDevGuards(options?: {
6444
6485
  force?: boolean;
6445
6486
  }): void;
6446
6487
 
6447
- 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 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 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 };
6488
+ 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 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 };
package/dist/index.js CHANGED
@@ -217,8 +217,13 @@ var BrainerceClient = class {
217
217
  this.apiKey = options.apiKey;
218
218
  this.storeId = options.storeId;
219
219
  this.connectionId = options.connectionId;
220
- this.baseUrl = (options.baseUrl || DEFAULT_BASE_URL).replace(/\/$/, "");
220
+ let resolvedBase = (options.baseUrl || DEFAULT_BASE_URL).replace(/\/$/, "");
221
+ if (resolvedBase.startsWith("/") && typeof window !== "undefined" && window.location?.origin) {
222
+ resolvedBase = window.location.origin + resolvedBase;
223
+ }
224
+ this.baseUrl = resolvedBase;
221
225
  this.timeout = options.timeout || DEFAULT_TIMEOUT;
226
+ this.proxyMode = options.proxyMode || false;
222
227
  this.onAuthError = options.onAuthError;
223
228
  this.hydrateSessionCart();
224
229
  }
@@ -382,6 +387,9 @@ var BrainerceClient = class {
382
387
  "X-SDK-Version": "0.3.0",
383
388
  "ngrok-skip-browser-warning": "true"
384
389
  };
390
+ if (this.proxyMode && method !== "GET") {
391
+ headers["X-Requested-With"] = "brainerce";
392
+ }
385
393
  if (this.customerToken) {
386
394
  headers["Authorization"] = `Bearer ${this.customerToken}`;
387
395
  }
@@ -1485,9 +1493,13 @@ var BrainerceClient = class {
1485
1493
  /**
1486
1494
  * Request a password reset email for a customer
1487
1495
  * Works in vibe-coded, storefront, and admin mode
1496
+ *
1497
+ * @param email - Customer email address
1498
+ * @param options - Optional settings
1499
+ * @param options.resetUrl - Override the auto-detected reset URL (e.g. for BFF proxy callback)
1488
1500
  */
1489
- async forgotPassword(email) {
1490
- const resetUrl = typeof window !== "undefined" ? `${window.location.origin}/reset-password` : void 0;
1501
+ async forgotPassword(email, options) {
1502
+ const resetUrl = options?.resetUrl ?? (typeof window !== "undefined" ? `${window.location.origin}/reset-password` : void 0);
1491
1503
  if (this.isVibeCodedMode()) {
1492
1504
  return this.vibeCodedRequest("POST", "/customers/forgot-password", {
1493
1505
  email,
@@ -1541,7 +1553,7 @@ var BrainerceClient = class {
1541
1553
  */
1542
1554
  async verifyEmail(code, token) {
1543
1555
  const effectiveToken = token || this.customerToken;
1544
- if (!effectiveToken) {
1556
+ if (!effectiveToken && !this.proxyMode) {
1545
1557
  throw new BrainerceError(
1546
1558
  "Customer token is required. Pass token parameter or call setCustomerToken() first.",
1547
1559
  401
@@ -1587,7 +1599,7 @@ var BrainerceClient = class {
1587
1599
  */
1588
1600
  async resendVerificationEmail(token) {
1589
1601
  const effectiveToken = token || this.customerToken;
1590
- if (!effectiveToken) {
1602
+ if (!effectiveToken && !this.proxyMode) {
1591
1603
  throw new BrainerceError(
1592
1604
  "Customer token is required. Pass token parameter or call setCustomerToken() first.",
1593
1605
  401
@@ -2403,7 +2415,7 @@ var BrainerceClient = class {
2403
2415
  * ```
2404
2416
  */
2405
2417
  isCustomerLoggedIn() {
2406
- return !!this.customerToken;
2418
+ return this.proxyMode || !!this.customerToken;
2407
2419
  }
2408
2420
  // -------------------- Session Cart Helpers --------------------
2409
2421
  /**
package/dist/index.mjs CHANGED
@@ -159,8 +159,13 @@ var BrainerceClient = class {
159
159
  this.apiKey = options.apiKey;
160
160
  this.storeId = options.storeId;
161
161
  this.connectionId = options.connectionId;
162
- this.baseUrl = (options.baseUrl || DEFAULT_BASE_URL).replace(/\/$/, "");
162
+ let resolvedBase = (options.baseUrl || DEFAULT_BASE_URL).replace(/\/$/, "");
163
+ if (resolvedBase.startsWith("/") && typeof window !== "undefined" && window.location?.origin) {
164
+ resolvedBase = window.location.origin + resolvedBase;
165
+ }
166
+ this.baseUrl = resolvedBase;
163
167
  this.timeout = options.timeout || DEFAULT_TIMEOUT;
168
+ this.proxyMode = options.proxyMode || false;
164
169
  this.onAuthError = options.onAuthError;
165
170
  this.hydrateSessionCart();
166
171
  }
@@ -324,6 +329,9 @@ var BrainerceClient = class {
324
329
  "X-SDK-Version": "0.3.0",
325
330
  "ngrok-skip-browser-warning": "true"
326
331
  };
332
+ if (this.proxyMode && method !== "GET") {
333
+ headers["X-Requested-With"] = "brainerce";
334
+ }
327
335
  if (this.customerToken) {
328
336
  headers["Authorization"] = `Bearer ${this.customerToken}`;
329
337
  }
@@ -1427,9 +1435,13 @@ var BrainerceClient = class {
1427
1435
  /**
1428
1436
  * Request a password reset email for a customer
1429
1437
  * Works in vibe-coded, storefront, and admin mode
1438
+ *
1439
+ * @param email - Customer email address
1440
+ * @param options - Optional settings
1441
+ * @param options.resetUrl - Override the auto-detected reset URL (e.g. for BFF proxy callback)
1430
1442
  */
1431
- async forgotPassword(email) {
1432
- const resetUrl = typeof window !== "undefined" ? `${window.location.origin}/reset-password` : void 0;
1443
+ async forgotPassword(email, options) {
1444
+ const resetUrl = options?.resetUrl ?? (typeof window !== "undefined" ? `${window.location.origin}/reset-password` : void 0);
1433
1445
  if (this.isVibeCodedMode()) {
1434
1446
  return this.vibeCodedRequest("POST", "/customers/forgot-password", {
1435
1447
  email,
@@ -1483,7 +1495,7 @@ var BrainerceClient = class {
1483
1495
  */
1484
1496
  async verifyEmail(code, token) {
1485
1497
  const effectiveToken = token || this.customerToken;
1486
- if (!effectiveToken) {
1498
+ if (!effectiveToken && !this.proxyMode) {
1487
1499
  throw new BrainerceError(
1488
1500
  "Customer token is required. Pass token parameter or call setCustomerToken() first.",
1489
1501
  401
@@ -1529,7 +1541,7 @@ var BrainerceClient = class {
1529
1541
  */
1530
1542
  async resendVerificationEmail(token) {
1531
1543
  const effectiveToken = token || this.customerToken;
1532
- if (!effectiveToken) {
1544
+ if (!effectiveToken && !this.proxyMode) {
1533
1545
  throw new BrainerceError(
1534
1546
  "Customer token is required. Pass token parameter or call setCustomerToken() first.",
1535
1547
  401
@@ -2345,7 +2357,7 @@ var BrainerceClient = class {
2345
2357
  * ```
2346
2358
  */
2347
2359
  isCustomerLoggedIn() {
2348
- return !!this.customerToken;
2360
+ return this.proxyMode || !!this.customerToken;
2349
2361
  }
2350
2362
  // -------------------- Session Cart Helpers --------------------
2351
2363
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "brainerce",
3
- "version": "1.4.1",
3
+ "version": "1.6.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",