brainerce 1.41.0 → 1.43.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -46,6 +46,7 @@ Every Brainerce storefront must include **all mandatory features** below. Featur
46
46
  | Forgot / reset password | `client.forgotPassword()`, `client.resetPassword()` | ✅ |
47
47
  | OAuth sign-in buttons + callback handler | `client.getAvailableOAuthProviders()` | ✅ |
48
48
  | Account area (profile + order history) | `client.getMyProfile()`, `client.getMyOrders()` | ✅ |
49
+ | Loyalty & rewards (points balance + tiers + redeem) | `client.getLoyaltyStatus()`, `client.getAvailableRewards()`, `client.redeemLoyaltyReward(id)`, `client.reportSocialShare()` | conditional |
49
50
  | Global header: cart count + search autocomplete | `client.getCart()`, `client.getSearchSuggestions(query)` | ✅ |
50
51
  | Discount banners + product badges | `client.getDiscountBanners()`, `client.getProductDiscountBadge(productId)` | ✅ |
51
52
  | Product reviews on PDP + JSON-LD aggregateRating | `client.listProductReviews(id)`, `client.submitProductReview(id, …)` | ✅ |
@@ -376,7 +377,7 @@ await client.addToCart(cart.id, {
376
377
 
377
378
  Money on the wire is **always strings** (`priceDelta: "5.00"`). Validation failures arrive as a structured 400 envelope on `BrainerceError.details` with `code: 'MODIFIER_VALIDATION_FAILED'` and `errors[]` — see INTEGRATION-RULES.md "Modifier validation errors" for the full code list.
378
379
 
379
- Full rendering guide: [Core Integration §2.9](https://brainerce.com/docs/integration/core). Restaurant features (allergens, scheduled availability, nested combos to depth 3, downsell modifiers): [Optional Features "Restaurant / build-your-own products"](https://brainerce.com/docs/integration/optional).
380
+ Full rendering guide: [Core Integration §2.9](https://brainerce.com/docs/integration/core). Restaurant features (scheduled availability, nested combos to depth 3, downsell modifiers): [Optional Features "Restaurant / build-your-own products"](https://brainerce.com/docs/integration/optional).
380
381
 
381
382
  ### Content (FAQ / Footer / Header / Announcements / Pages)
382
383
 
@@ -2479,6 +2480,25 @@ const intent = await client.createPaymentIntent(checkout.id);
2479
2480
  // }
2480
2481
  ```
2481
2482
 
2483
+ **Routing to a specific provider (`providerId`).** With `getPaymentProviders()` you
2484
+ render additive **express buttons** (e.g. PayPal as a `WALLET`) alongside the primary
2485
+ card form. When the buyer taps one, pass that provider's `id` so the charge routes to
2486
+ it instead of the store's default card processor:
2487
+
2488
+ ```typescript
2489
+ const { providers } = await client.getPaymentProviders();
2490
+ const paypal = providers.find((p) => p.isAdditive && p.provider === 'paypal');
2491
+
2492
+ // Buyer tapped the PayPal express button:
2493
+ const intent = await client.createPaymentIntent(checkout.id, {
2494
+ providerId: paypal.id,
2495
+ });
2496
+ ```
2497
+
2498
+ Omit `providerId` to settle through the primary card processor (`defaultProvider`).
2499
+ The platform scopes it to the store, so only that store's own installed providers are
2500
+ selectable.
2501
+
2482
2502
  #### Confirm Payment with Stripe.js
2483
2503
 
2484
2504
  Use the client secret with Stripe.js to collect payment:
@@ -2893,6 +2913,44 @@ const { data: orders, meta } = await client.getMyOrders({
2893
2913
  });
2894
2914
  ```
2895
2915
 
2916
+ #### Loyalty & Rewards
2917
+
2918
+ Storefront-mode only (requires `storeId` + `customerToken`). Let logged-in
2919
+ customers check their points balance, enroll, and redeem rewards for one-time
2920
+ coupons that apply at checkout.
2921
+
2922
+ ```typescript
2923
+ // Current status — points balance + program display config + tier progress.
2924
+ // `program`/`tier`/`nextTier` are null if the store has no loyalty program
2925
+ // (or no tiers configured / the customer hasn't reached one yet).
2926
+ const status = await client.getLoyaltyStatus();
2927
+ if (status.enrolled) {
2928
+ console.log(`${status.pointsBalance} ${status.program?.pointsName}`);
2929
+ if (status.nextTier) {
2930
+ console.log(`${status.pointsToNextTier} to reach ${status.nextTier.name}`);
2931
+ }
2932
+ }
2933
+
2934
+ // Enroll (idempotent) — only if the program is ACTIVE. May grant a one-time
2935
+ // "join the program" bonus if the store has one configured.
2936
+ await client.enrollInLoyalty();
2937
+
2938
+ // Rewards the customer can redeem, cheapest first (already filtered to ones
2939
+ // their current tier qualifies for).
2940
+ const rewards = await client.getAvailableRewards();
2941
+
2942
+ // Redeem → spends points, returns a one-time coupon code to apply to the cart.
2943
+ // `discountType` tells you how to interpret `discountValue` (currency amount
2944
+ // for FIXED_DISCOUNT, 0-100 percent for PERCENT_DISCOUNT).
2945
+ const { couponCode, discountType, discountValue, pointsBalance } =
2946
+ await client.redeemLoyaltyReward(rewards[0].id);
2947
+ await client.applyCoupon(cartId, couponCode);
2948
+
2949
+ // Self-reported social share — grants the SOCIAL_SHARE bonus if configured
2950
+ // (once per customer).
2951
+ await client.reportSocialShare('instagram');
2952
+ ```
2953
+
2896
2954
  #### Auth Response Type
2897
2955
 
2898
2956
  ```typescript
package/dist/index.d.mts CHANGED
@@ -248,6 +248,79 @@ interface CustomerProfile {
248
248
  createdAt: string;
249
249
  updatedAt: string;
250
250
  }
251
+ /** The membership tier a customer currently holds, or is progressing toward. */
252
+ interface LoyaltyTierSummary {
253
+ id: string;
254
+ name: string;
255
+ /** Ordering; higher = better tier. */
256
+ level: number;
257
+ /** Points-earning multiplier this tier grants (e.g. 1.5 = 50% more points per order). */
258
+ pointsMultiplier: number;
259
+ }
260
+ /** The next tier up, including what it takes to qualify. */
261
+ interface LoyaltyNextTierSummary extends LoyaltyTierSummary {
262
+ qualificationType: 'SPEND' | 'POINTS';
263
+ /** Threshold in store currency (SPEND) or points (POINTS). */
264
+ qualificationThreshold: number;
265
+ }
266
+ /** A store's loyalty program status for a logged-in customer. */
267
+ interface LoyaltyStatus {
268
+ /** Whether the customer has a membership in the program. */
269
+ enrolled: boolean;
270
+ /** Redeemable points balance (pending earns excluded). */
271
+ pointsBalance: number;
272
+ /** Total points ever earned (confirmed). */
273
+ lifetimeEarned: number;
274
+ /** Program display config, or null when the store has no loyalty program. */
275
+ program: {
276
+ /** Display name for points (e.g. "points", "coins"). */
277
+ pointsName: string;
278
+ /** Points needed to redeem one unit of store currency. */
279
+ currencyRatio: number;
280
+ status: 'DRAFT' | 'ACTIVE' | 'PAUSED';
281
+ } | null;
282
+ /** The customer's current tier, or null if untiered / no tiers configured. */
283
+ tier: LoyaltyTierSummary | null;
284
+ /** The next tier up, or null if already at the top tier (or no tiers configured). */
285
+ nextTier: LoyaltyNextTierSummary | null;
286
+ /** 0..1 progress toward nextTier; 1 if no nextTier and a tier is held. */
287
+ progressToNextTier: number;
288
+ /** Remaining spend/points needed to reach nextTier, or null if there's no nextTier. */
289
+ pointsToNextTier: number | null;
290
+ }
291
+ /** A reward a customer can redeem points for. */
292
+ interface LoyaltyReward {
293
+ id: string;
294
+ name: string;
295
+ description: string | null;
296
+ /** Points required to redeem this reward. */
297
+ pointsCost: number;
298
+ /** FIXED_DISCOUNT: discountValue is a store-currency amount off. PERCENT_DISCOUNT: discountValue is a 0-100 percent off. */
299
+ type: 'FIXED_DISCOUNT' | 'PERCENT_DISCOUNT';
300
+ discountValue: number;
301
+ /** Minimum order amount for the coupon to apply, or null. */
302
+ minOrderAmount: number | null;
303
+ /** How many times a single customer may redeem this reward. */
304
+ maxUsesPerUser: number;
305
+ isActive: boolean;
306
+ /** Minimum tier level required to redeem this reward, or null for no restriction. */
307
+ minTierLevel: number | null;
308
+ createdAt: string;
309
+ updatedAt: string;
310
+ }
311
+ /** Result of redeeming a reward — a one-time coupon plus the new balance. */
312
+ interface RedeemRewardResult {
313
+ /** The minted one-time coupon code to apply at checkout. */
314
+ couponCode: string;
315
+ /** Matches the redeemed reward's `type` — tells you how to interpret discountValue. */
316
+ discountType: 'FIXED_DISCOUNT' | 'PERCENT_DISCOUNT';
317
+ /** Currency amount (FIXED_DISCOUNT) or percent 0-100 (PERCENT_DISCOUNT) the coupon is worth. */
318
+ discountValue: number;
319
+ /** Points spent on this redemption. */
320
+ pointsSpent: number;
321
+ /** The customer's remaining points balance after redemption. */
322
+ pointsBalance: number;
323
+ }
251
324
  interface ProductMetafield {
252
325
  id: string;
253
326
  definitionId: string;
@@ -476,6 +549,14 @@ interface WriteProductReviewInput {
476
549
  rating: number;
477
550
  body?: string;
478
551
  }
552
+ /**
553
+ * @deprecated Use `WriteProductReviewInput`. Customers no longer pass author info
554
+ * directly; it's derived from the authenticated customer profile.
555
+ */
556
+ interface SubmitProductReviewInput extends WriteProductReviewInput {
557
+ authorName?: string;
558
+ authorEmail?: string;
559
+ }
479
560
  /**
480
561
  * Returned by `client.getMyProductReview(productId)`. Tells the storefront which
481
562
  * UI to render: sign-in / not-eligible / submit / edit.
@@ -4850,7 +4931,13 @@ interface CheckoutCustomFieldDefinition {
4850
4931
  key: string;
4851
4932
  name: string;
4852
4933
  description?: string | null;
4853
- type: 'TEXT' | 'TEXTAREA' | 'NUMBER' | 'BOOLEAN' | 'SELECT' | 'DATE';
4934
+ /**
4935
+ * `IMAGE` renders a file-upload control; its value is the uploaded file URL
4936
+ * (validated server-side to be a store-hosted upload). `GALLERY` and
4937
+ * `MULTI_SELECT` are NOT supported for checkout fields — those are
4938
+ * product-metafield-only (`ProductCustomizationField` / `MetafieldType`).
4939
+ */
4940
+ type: 'TEXT' | 'TEXTAREA' | 'NUMBER' | 'BOOLEAN' | 'SELECT' | 'DATE' | 'IMAGE';
4854
4941
  required: boolean;
4855
4942
  position: number;
4856
4943
  visibility: CheckoutFieldVisibility;
@@ -8095,6 +8182,16 @@ declare class BrainerceClient {
8095
8182
  * ```
8096
8183
  */
8097
8184
  createPaymentIntent(checkoutId: string, options?: {
8185
+ /**
8186
+ * Route the charge to a specific installed provider — pass the `id` from a
8187
+ * `getPaymentProviders()` entry. This is how you wire an additive express
8188
+ * button (e.g. PayPal as a `WALLET`): when the buyer taps it, call
8189
+ * `createPaymentIntent(checkoutId, { providerId: m.id })`. Omit to settle
8190
+ * through the store's primary card processor (`defaultProvider`). The
8191
+ * platform scopes this to the store, so only that store's own installed
8192
+ * providers are selectable.
8193
+ */
8194
+ providerId?: string;
8098
8195
  successUrl?: string;
8099
8196
  cancelUrl?: string;
8100
8197
  /**
@@ -8545,6 +8642,69 @@ declare class BrainerceClient {
8545
8642
  phone?: string;
8546
8643
  acceptsMarketing?: boolean;
8547
8644
  }): Promise<CustomerProfile>;
8645
+ /**
8646
+ * Get the logged-in customer's loyalty status: enrollment, points balance,
8647
+ * lifetime earned, and the program's display config (requires customerToken).
8648
+ * Only available in storefront mode. `program` is null when the store has no
8649
+ * loyalty program.
8650
+ *
8651
+ * @example
8652
+ * ```typescript
8653
+ * client.setCustomerToken(auth.token);
8654
+ * const status = await client.getLoyaltyStatus();
8655
+ * if (status.enrolled) console.log(`${status.pointsBalance} ${status.program?.pointsName}`);
8656
+ * ```
8657
+ */
8658
+ getLoyaltyStatus(): Promise<LoyaltyStatus>;
8659
+ /**
8660
+ * Enroll the logged-in customer in the store's loyalty program (requires
8661
+ * customerToken). Idempotent — returns the same status shape as
8662
+ * getLoyaltyStatus(). Only available in storefront mode.
8663
+ *
8664
+ * @example
8665
+ * ```typescript
8666
+ * const status = await client.enrollInLoyalty();
8667
+ * ```
8668
+ */
8669
+ enrollInLoyalty(): Promise<LoyaltyStatus>;
8670
+ /**
8671
+ * List the rewards the customer can redeem points for (active rewards, cheapest
8672
+ * first). Requires customerToken. Only available in storefront mode.
8673
+ *
8674
+ * @example
8675
+ * ```typescript
8676
+ * client.setCustomerToken(auth.token);
8677
+ * const rewards = await client.getAvailableRewards();
8678
+ * ```
8679
+ */
8680
+ getAvailableRewards(): Promise<LoyaltyReward[]>;
8681
+ /**
8682
+ * Redeem a reward: spends the customer's points and mints a one-time coupon
8683
+ * that applies at checkout (requires customerToken). Only available in
8684
+ * storefront mode.
8685
+ *
8686
+ * @example
8687
+ * ```typescript
8688
+ * const { couponCode, pointsBalance } = await client.redeemLoyaltyReward('rw_123');
8689
+ * // apply couponCode to the cart at checkout
8690
+ * ```
8691
+ */
8692
+ redeemLoyaltyReward(rewardId: string): Promise<RedeemRewardResult>;
8693
+ /**
8694
+ * Report a social share, granting the SOCIAL_SHARE earning-rule bonus if the
8695
+ * store has one configured (requires customerToken). Self-reported — no
8696
+ * share-tracking infra — and capped at once per customer per program. Only
8697
+ * available in storefront mode.
8698
+ *
8699
+ * @example
8700
+ * ```typescript
8701
+ * await client.reportSocialShare('instagram');
8702
+ * ```
8703
+ */
8704
+ reportSocialShare(platform?: string): Promise<{
8705
+ awarded: boolean;
8706
+ points: number;
8707
+ }>;
8548
8708
  /**
8549
8709
  * Get the current customer's orders (requires customerToken)
8550
8710
  * Works in vibe-coded and storefront modes
@@ -9709,7 +9869,7 @@ declare class BrainerceError extends Error {
9709
9869
  constructor(message: string, statusCode: number, details?: unknown);
9710
9870
  }
9711
9871
 
9712
- declare const SDK_VERSION = "1.41.0";
9872
+ declare const SDK_VERSION = "1.42.0";
9713
9873
 
9714
9874
  /**
9715
9875
  * Verify a webhook signature from Brainerce
@@ -9849,4 +10009,4 @@ declare function formatVariantPrice(variant: Pick<ProductVariant, 'price' | 'sal
9849
10009
  /** Format any numeric amount as currency. Useful for cart totals, fees, etc. */
9850
10010
  declare function formatMoney(amount: number, currency: string, locale?: string): string;
9851
10011
 
9852
- export { type AddToCartDto, type AnnouncementContent, type AnnouncementSeverity, type AppliedDiscount, type ApplyCouponDto, type AttachModifierGroupInput, 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 CartIncludeOption, type CartIncludeOptions, type CartItem, type CartItemModifierLine, type CartNudge, type CartRecommendationsResponse, type CartStatus, type CartUpgradeSuggestion, type CartUpgradesResponse, type CartWithIncludes, 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 ContactFormFieldType, type ContactFormFieldValidation, type ContactFormPublic, type ContactFormPublicField, type ContactFormSummary, type Content, type ContentDataMap, type ContentStatus, type ContentSummary, type ContentType, 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 CreateContentInput, type CreateCouponDto, type CreateCustomApiDto, type CreateCustomerDto, type CreateEmailTemplateDto as CreateEmailTemplateInput, type CreateGuestOrderDto, type CreateInquiryInput, type CreateInquiryResponse, type CreateMetafieldDefinitionDto as CreateMetafieldDefinitionInput, type CreateModifierGroupInput, type CreateModifierInput, 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 FaqContent, type FaqItem, type FooterColumn, type FooterContent, type FooterLink, type FooterSocialLink, type FormatPriceOptions, type FormatProductPriceOptions, type FreeAllocationPolicy, type FulfillOrderDto, type GuestCheckoutStartResponse, type GuestOrderResponse, type HeaderContent, type HeaderCta, type HeaderLogo, type HeaderNavItem, type InsufficientStockError, type InventoryInfo, type InventoryReservationStrategy, type InventorySyncStatus, type InventoryTrackingMode, type InvitationStatus, type InviteMemberDto as InviteMemberInput, type InviteStoreMemberDto as InviteStoreMemberInput, type ListModifierGroupsParams, type LocalCart, type LocalCartItem, type LockedVariant, type MergeCartsDto, type MetafieldConflict, type MetafieldConflictResolution, type MetafieldDefinition, type MetafieldType, type Modifier, type ModifierGroup, type ModifierSelection, type ModifierSelectionType, type ModifierValidationCode, type ModifierValidationError, 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 OrderStatusChange, type PageContent, type PageSeo, type PaginatedResponse, type PaymentClientSdk, type PaymentConfig, type PaymentIntent, type PaymentProvider, type PaymentProviderConfig, type PaymentProvidersConfig, type PaymentStatus, type PaymentUrlOptions, type PickupLocation, type PlatformCouponCapabilities, type PlatformMetafieldMetadata, type PreviewEmailTemplateDto as PreviewEmailTemplateInput, type Product, type ProductAttributeInput, type ProductAvailability, type ProductCustomizationField, type ProductDiscount, type ProductDiscountBadge, type ProductImage, type ProductMetafield, type ProductMetafieldValue, type ProductModifierGroupAttachment, type ProductQueryParams, type ProductRecommendation, type ProductRecommendationsResponse, type ProductRelationType, type ProductSuggestion, type ProductVariant, type PublicMetafieldDefinition, type PublishProductResponse, RTL_LOCALES, type RecommendationVariant, type ReconcileInventoryResponse, type Refund, type RefundLineItem, type RefundLineItemResponse, type RefundType, type RegisterCustomerDto, type ReservationInfo, type ResolveMetafieldConflictDto as ResolveMetafieldConflictInput, type ResolveSyncConflictDto as ResolveSyncConflictInput, type RichTextContent, SDK_VERSION, type SearchSuggestions, type SelectPickupLocationDto, type SelectShippingMethodDto, type SendInvoiceDto, type SessionCartRef, type SetBillingAddressDto, type SetCheckoutCustomFieldsDto, type SetCheckoutCustomerDto, type SetDefinitionProductsDto as SetDefinitionProductsInput, type SetMetafieldPlatformsDto as SetMetafieldPlatformsInput, 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 SupportedLocaleObject, 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 UpdateAttachmentInput, type UpdateAttributeDto as UpdateAttributeInput, type UpdateAttributeOptionDto as UpdateAttributeOptionInput, type UpdateBrandDto as UpdateBrandInput, type UpdateCartItemDto, type UpdateCategoryDto as UpdateCategoryInput, type UpdateContentInput, 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 UpdateModifierGroupInput, type UpdateModifierInput, 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, deriveSeoDescription, enableDevGuards, formatMoney, formatPrice, formatProductPrice, formatVariantPrice, getCartItemImage, getCartItemName, getCartTotals, getDescriptionContent, getDirectionForLocale, formatPrice as getPriceDisplay, getProductCustomizationFields, getProductMetafield, getProductMetafieldValue, getProductMetafieldsByType, getProductPrice, getProductPriceInfo, getProductSwatches, getStockStatus, getVariantOptions, getVariantPrice, isAllowedPaymentUrl, isCouponApplicableToProduct, isHtmlDescription, isWebhookEventType, parseWebhookEvent, safePaymentRedirect, stripHtml, verifyWebhook };
10012
+ export { type AddToCartDto, type AnnouncementContent, type AnnouncementSeverity, type AppliedDiscount, type ApplyCouponDto, type AttachModifierGroupInput, 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 CartIncludeOption, type CartIncludeOptions, type CartItem, type CartItemModifierLine, type CartNudge, type CartRecommendationsResponse, type CartStatus, type CartUpgradeSuggestion, type CartUpgradesResponse, type CartWithIncludes, 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 ContactFormFieldType, type ContactFormFieldValidation, type ContactFormPublic, type ContactFormPublicField, type ContactFormSummary, type Content, type ContentDataMap, type ContentStatus, type ContentSummary, type ContentType, 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 CreateContentInput, type CreateCouponDto, type CreateCustomApiDto, type CreateCustomerDto, type CreateEmailTemplateDto as CreateEmailTemplateInput, type CreateGuestOrderDto, type CreateInquiryInput, type CreateInquiryResponse, type CreateMetafieldDefinitionDto as CreateMetafieldDefinitionInput, type CreateModifierGroupInput, type CreateModifierInput, 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 FaqContent, type FaqItem, type FooterColumn, type FooterContent, type FooterLink, type FooterSocialLink, type FormatPriceOptions, type FormatProductPriceOptions, type FreeAllocationPolicy, type FulfillOrderDto, type GuestCheckoutStartResponse, type GuestOrderResponse, type HeaderContent, type HeaderCta, type HeaderLogo, type HeaderNavItem, type InsufficientStockError, type InventoryInfo, type InventoryReservationStrategy, type InventorySyncStatus, type InventoryTrackingMode, type InvitationStatus, type InviteMemberDto as InviteMemberInput, type InviteStoreMemberDto as InviteStoreMemberInput, type ListModifierGroupsParams, type LocalCart, type LocalCartItem, type LockedVariant, type MergeCartsDto, type MetafieldConflict, type MetafieldConflictResolution, type MetafieldDefinition, type MetafieldType, type Modifier, type ModifierGroup, type ModifierSelection, type ModifierSelectionType, type ModifierValidationCode, type ModifierValidationError, type MyProductReview, 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 OrderStatusChange, type PageContent, type PageSeo, type PaginatedResponse, type PaymentClientSdk, type PaymentConfig, type PaymentIntent, type PaymentProvider, type PaymentProviderConfig, type PaymentProvidersConfig, type PaymentStatus, type PaymentUrlOptions, type PickupLocation, type PlatformCouponCapabilities, type PlatformMetafieldMetadata, type PreviewEmailTemplateDto as PreviewEmailTemplateInput, type Product, type ProductAttributeInput, type ProductAvailability, type ProductCustomizationField, type ProductDiscount, type ProductDiscountBadge, type ProductImage, type ProductMetafield, type ProductMetafieldValue, type ProductModifierGroupAttachment, type ProductQueryParams, type ProductRecommendation, type ProductRecommendationsResponse, type ProductRelationType, type ProductReview, type ProductReviewAdmin, type ProductSuggestion, type ProductVariant, type PublicMetafieldDefinition, type PublishProductResponse, RTL_LOCALES, type RecommendationVariant, type ReconcileInventoryResponse, type Refund, type RefundLineItem, type RefundLineItemResponse, type RefundType, type RegisterCustomerDto, type ReservationInfo, type ResolveMetafieldConflictDto as ResolveMetafieldConflictInput, type ResolveSyncConflictDto as ResolveSyncConflictInput, type RichTextContent, SDK_VERSION, type SearchSuggestions, type SelectPickupLocationDto, type SelectShippingMethodDto, type SendInvoiceDto, type SessionCartRef, type SetBillingAddressDto, type SetCheckoutCustomFieldsDto, type SetCheckoutCustomerDto, type SetDefinitionProductsDto as SetDefinitionProductsInput, type SetMetafieldPlatformsDto as SetMetafieldPlatformsInput, 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 SubmitProductReviewInput, type SupportedLocaleObject, 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 UpdateAttachmentInput, type UpdateAttributeDto as UpdateAttributeInput, type UpdateAttributeOptionDto as UpdateAttributeOptionInput, type UpdateBrandDto as UpdateBrandInput, type UpdateCartItemDto, type UpdateCategoryDto as UpdateCategoryInput, type UpdateContentInput, 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 UpdateModifierGroupInput, type UpdateModifierInput, 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, type WriteProductReviewInput, createWebhookHandler, deriveSeoDescription, enableDevGuards, formatMoney, formatPrice, formatProductPrice, formatVariantPrice, getCartItemImage, getCartItemName, getCartTotals, getDescriptionContent, getDirectionForLocale, formatPrice as getPriceDisplay, getProductCustomizationFields, getProductMetafield, getProductMetafieldValue, getProductMetafieldsByType, getProductPrice, getProductPriceInfo, getProductSwatches, getStockStatus, getVariantOptions, getVariantPrice, isAllowedPaymentUrl, isCouponApplicableToProduct, isHtmlDescription, isWebhookEventType, parseWebhookEvent, safePaymentRedirect, stripHtml, verifyWebhook };
package/dist/index.d.ts CHANGED
@@ -248,6 +248,79 @@ interface CustomerProfile {
248
248
  createdAt: string;
249
249
  updatedAt: string;
250
250
  }
251
+ /** The membership tier a customer currently holds, or is progressing toward. */
252
+ interface LoyaltyTierSummary {
253
+ id: string;
254
+ name: string;
255
+ /** Ordering; higher = better tier. */
256
+ level: number;
257
+ /** Points-earning multiplier this tier grants (e.g. 1.5 = 50% more points per order). */
258
+ pointsMultiplier: number;
259
+ }
260
+ /** The next tier up, including what it takes to qualify. */
261
+ interface LoyaltyNextTierSummary extends LoyaltyTierSummary {
262
+ qualificationType: 'SPEND' | 'POINTS';
263
+ /** Threshold in store currency (SPEND) or points (POINTS). */
264
+ qualificationThreshold: number;
265
+ }
266
+ /** A store's loyalty program status for a logged-in customer. */
267
+ interface LoyaltyStatus {
268
+ /** Whether the customer has a membership in the program. */
269
+ enrolled: boolean;
270
+ /** Redeemable points balance (pending earns excluded). */
271
+ pointsBalance: number;
272
+ /** Total points ever earned (confirmed). */
273
+ lifetimeEarned: number;
274
+ /** Program display config, or null when the store has no loyalty program. */
275
+ program: {
276
+ /** Display name for points (e.g. "points", "coins"). */
277
+ pointsName: string;
278
+ /** Points needed to redeem one unit of store currency. */
279
+ currencyRatio: number;
280
+ status: 'DRAFT' | 'ACTIVE' | 'PAUSED';
281
+ } | null;
282
+ /** The customer's current tier, or null if untiered / no tiers configured. */
283
+ tier: LoyaltyTierSummary | null;
284
+ /** The next tier up, or null if already at the top tier (or no tiers configured). */
285
+ nextTier: LoyaltyNextTierSummary | null;
286
+ /** 0..1 progress toward nextTier; 1 if no nextTier and a tier is held. */
287
+ progressToNextTier: number;
288
+ /** Remaining spend/points needed to reach nextTier, or null if there's no nextTier. */
289
+ pointsToNextTier: number | null;
290
+ }
291
+ /** A reward a customer can redeem points for. */
292
+ interface LoyaltyReward {
293
+ id: string;
294
+ name: string;
295
+ description: string | null;
296
+ /** Points required to redeem this reward. */
297
+ pointsCost: number;
298
+ /** FIXED_DISCOUNT: discountValue is a store-currency amount off. PERCENT_DISCOUNT: discountValue is a 0-100 percent off. */
299
+ type: 'FIXED_DISCOUNT' | 'PERCENT_DISCOUNT';
300
+ discountValue: number;
301
+ /** Minimum order amount for the coupon to apply, or null. */
302
+ minOrderAmount: number | null;
303
+ /** How many times a single customer may redeem this reward. */
304
+ maxUsesPerUser: number;
305
+ isActive: boolean;
306
+ /** Minimum tier level required to redeem this reward, or null for no restriction. */
307
+ minTierLevel: number | null;
308
+ createdAt: string;
309
+ updatedAt: string;
310
+ }
311
+ /** Result of redeeming a reward — a one-time coupon plus the new balance. */
312
+ interface RedeemRewardResult {
313
+ /** The minted one-time coupon code to apply at checkout. */
314
+ couponCode: string;
315
+ /** Matches the redeemed reward's `type` — tells you how to interpret discountValue. */
316
+ discountType: 'FIXED_DISCOUNT' | 'PERCENT_DISCOUNT';
317
+ /** Currency amount (FIXED_DISCOUNT) or percent 0-100 (PERCENT_DISCOUNT) the coupon is worth. */
318
+ discountValue: number;
319
+ /** Points spent on this redemption. */
320
+ pointsSpent: number;
321
+ /** The customer's remaining points balance after redemption. */
322
+ pointsBalance: number;
323
+ }
251
324
  interface ProductMetafield {
252
325
  id: string;
253
326
  definitionId: string;
@@ -476,6 +549,14 @@ interface WriteProductReviewInput {
476
549
  rating: number;
477
550
  body?: string;
478
551
  }
552
+ /**
553
+ * @deprecated Use `WriteProductReviewInput`. Customers no longer pass author info
554
+ * directly; it's derived from the authenticated customer profile.
555
+ */
556
+ interface SubmitProductReviewInput extends WriteProductReviewInput {
557
+ authorName?: string;
558
+ authorEmail?: string;
559
+ }
479
560
  /**
480
561
  * Returned by `client.getMyProductReview(productId)`. Tells the storefront which
481
562
  * UI to render: sign-in / not-eligible / submit / edit.
@@ -4850,7 +4931,13 @@ interface CheckoutCustomFieldDefinition {
4850
4931
  key: string;
4851
4932
  name: string;
4852
4933
  description?: string | null;
4853
- type: 'TEXT' | 'TEXTAREA' | 'NUMBER' | 'BOOLEAN' | 'SELECT' | 'DATE';
4934
+ /**
4935
+ * `IMAGE` renders a file-upload control; its value is the uploaded file URL
4936
+ * (validated server-side to be a store-hosted upload). `GALLERY` and
4937
+ * `MULTI_SELECT` are NOT supported for checkout fields — those are
4938
+ * product-metafield-only (`ProductCustomizationField` / `MetafieldType`).
4939
+ */
4940
+ type: 'TEXT' | 'TEXTAREA' | 'NUMBER' | 'BOOLEAN' | 'SELECT' | 'DATE' | 'IMAGE';
4854
4941
  required: boolean;
4855
4942
  position: number;
4856
4943
  visibility: CheckoutFieldVisibility;
@@ -8095,6 +8182,16 @@ declare class BrainerceClient {
8095
8182
  * ```
8096
8183
  */
8097
8184
  createPaymentIntent(checkoutId: string, options?: {
8185
+ /**
8186
+ * Route the charge to a specific installed provider — pass the `id` from a
8187
+ * `getPaymentProviders()` entry. This is how you wire an additive express
8188
+ * button (e.g. PayPal as a `WALLET`): when the buyer taps it, call
8189
+ * `createPaymentIntent(checkoutId, { providerId: m.id })`. Omit to settle
8190
+ * through the store's primary card processor (`defaultProvider`). The
8191
+ * platform scopes this to the store, so only that store's own installed
8192
+ * providers are selectable.
8193
+ */
8194
+ providerId?: string;
8098
8195
  successUrl?: string;
8099
8196
  cancelUrl?: string;
8100
8197
  /**
@@ -8545,6 +8642,69 @@ declare class BrainerceClient {
8545
8642
  phone?: string;
8546
8643
  acceptsMarketing?: boolean;
8547
8644
  }): Promise<CustomerProfile>;
8645
+ /**
8646
+ * Get the logged-in customer's loyalty status: enrollment, points balance,
8647
+ * lifetime earned, and the program's display config (requires customerToken).
8648
+ * Only available in storefront mode. `program` is null when the store has no
8649
+ * loyalty program.
8650
+ *
8651
+ * @example
8652
+ * ```typescript
8653
+ * client.setCustomerToken(auth.token);
8654
+ * const status = await client.getLoyaltyStatus();
8655
+ * if (status.enrolled) console.log(`${status.pointsBalance} ${status.program?.pointsName}`);
8656
+ * ```
8657
+ */
8658
+ getLoyaltyStatus(): Promise<LoyaltyStatus>;
8659
+ /**
8660
+ * Enroll the logged-in customer in the store's loyalty program (requires
8661
+ * customerToken). Idempotent — returns the same status shape as
8662
+ * getLoyaltyStatus(). Only available in storefront mode.
8663
+ *
8664
+ * @example
8665
+ * ```typescript
8666
+ * const status = await client.enrollInLoyalty();
8667
+ * ```
8668
+ */
8669
+ enrollInLoyalty(): Promise<LoyaltyStatus>;
8670
+ /**
8671
+ * List the rewards the customer can redeem points for (active rewards, cheapest
8672
+ * first). Requires customerToken. Only available in storefront mode.
8673
+ *
8674
+ * @example
8675
+ * ```typescript
8676
+ * client.setCustomerToken(auth.token);
8677
+ * const rewards = await client.getAvailableRewards();
8678
+ * ```
8679
+ */
8680
+ getAvailableRewards(): Promise<LoyaltyReward[]>;
8681
+ /**
8682
+ * Redeem a reward: spends the customer's points and mints a one-time coupon
8683
+ * that applies at checkout (requires customerToken). Only available in
8684
+ * storefront mode.
8685
+ *
8686
+ * @example
8687
+ * ```typescript
8688
+ * const { couponCode, pointsBalance } = await client.redeemLoyaltyReward('rw_123');
8689
+ * // apply couponCode to the cart at checkout
8690
+ * ```
8691
+ */
8692
+ redeemLoyaltyReward(rewardId: string): Promise<RedeemRewardResult>;
8693
+ /**
8694
+ * Report a social share, granting the SOCIAL_SHARE earning-rule bonus if the
8695
+ * store has one configured (requires customerToken). Self-reported — no
8696
+ * share-tracking infra — and capped at once per customer per program. Only
8697
+ * available in storefront mode.
8698
+ *
8699
+ * @example
8700
+ * ```typescript
8701
+ * await client.reportSocialShare('instagram');
8702
+ * ```
8703
+ */
8704
+ reportSocialShare(platform?: string): Promise<{
8705
+ awarded: boolean;
8706
+ points: number;
8707
+ }>;
8548
8708
  /**
8549
8709
  * Get the current customer's orders (requires customerToken)
8550
8710
  * Works in vibe-coded and storefront modes
@@ -9709,7 +9869,7 @@ declare class BrainerceError extends Error {
9709
9869
  constructor(message: string, statusCode: number, details?: unknown);
9710
9870
  }
9711
9871
 
9712
- declare const SDK_VERSION = "1.41.0";
9872
+ declare const SDK_VERSION = "1.42.0";
9713
9873
 
9714
9874
  /**
9715
9875
  * Verify a webhook signature from Brainerce
@@ -9849,4 +10009,4 @@ declare function formatVariantPrice(variant: Pick<ProductVariant, 'price' | 'sal
9849
10009
  /** Format any numeric amount as currency. Useful for cart totals, fees, etc. */
9850
10010
  declare function formatMoney(amount: number, currency: string, locale?: string): string;
9851
10011
 
9852
- export { type AddToCartDto, type AnnouncementContent, type AnnouncementSeverity, type AppliedDiscount, type ApplyCouponDto, type AttachModifierGroupInput, 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 CartIncludeOption, type CartIncludeOptions, type CartItem, type CartItemModifierLine, type CartNudge, type CartRecommendationsResponse, type CartStatus, type CartUpgradeSuggestion, type CartUpgradesResponse, type CartWithIncludes, 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 ContactFormFieldType, type ContactFormFieldValidation, type ContactFormPublic, type ContactFormPublicField, type ContactFormSummary, type Content, type ContentDataMap, type ContentStatus, type ContentSummary, type ContentType, 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 CreateContentInput, type CreateCouponDto, type CreateCustomApiDto, type CreateCustomerDto, type CreateEmailTemplateDto as CreateEmailTemplateInput, type CreateGuestOrderDto, type CreateInquiryInput, type CreateInquiryResponse, type CreateMetafieldDefinitionDto as CreateMetafieldDefinitionInput, type CreateModifierGroupInput, type CreateModifierInput, 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 FaqContent, type FaqItem, type FooterColumn, type FooterContent, type FooterLink, type FooterSocialLink, type FormatPriceOptions, type FormatProductPriceOptions, type FreeAllocationPolicy, type FulfillOrderDto, type GuestCheckoutStartResponse, type GuestOrderResponse, type HeaderContent, type HeaderCta, type HeaderLogo, type HeaderNavItem, type InsufficientStockError, type InventoryInfo, type InventoryReservationStrategy, type InventorySyncStatus, type InventoryTrackingMode, type InvitationStatus, type InviteMemberDto as InviteMemberInput, type InviteStoreMemberDto as InviteStoreMemberInput, type ListModifierGroupsParams, type LocalCart, type LocalCartItem, type LockedVariant, type MergeCartsDto, type MetafieldConflict, type MetafieldConflictResolution, type MetafieldDefinition, type MetafieldType, type Modifier, type ModifierGroup, type ModifierSelection, type ModifierSelectionType, type ModifierValidationCode, type ModifierValidationError, 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 OrderStatusChange, type PageContent, type PageSeo, type PaginatedResponse, type PaymentClientSdk, type PaymentConfig, type PaymentIntent, type PaymentProvider, type PaymentProviderConfig, type PaymentProvidersConfig, type PaymentStatus, type PaymentUrlOptions, type PickupLocation, type PlatformCouponCapabilities, type PlatformMetafieldMetadata, type PreviewEmailTemplateDto as PreviewEmailTemplateInput, type Product, type ProductAttributeInput, type ProductAvailability, type ProductCustomizationField, type ProductDiscount, type ProductDiscountBadge, type ProductImage, type ProductMetafield, type ProductMetafieldValue, type ProductModifierGroupAttachment, type ProductQueryParams, type ProductRecommendation, type ProductRecommendationsResponse, type ProductRelationType, type ProductSuggestion, type ProductVariant, type PublicMetafieldDefinition, type PublishProductResponse, RTL_LOCALES, type RecommendationVariant, type ReconcileInventoryResponse, type Refund, type RefundLineItem, type RefundLineItemResponse, type RefundType, type RegisterCustomerDto, type ReservationInfo, type ResolveMetafieldConflictDto as ResolveMetafieldConflictInput, type ResolveSyncConflictDto as ResolveSyncConflictInput, type RichTextContent, SDK_VERSION, type SearchSuggestions, type SelectPickupLocationDto, type SelectShippingMethodDto, type SendInvoiceDto, type SessionCartRef, type SetBillingAddressDto, type SetCheckoutCustomFieldsDto, type SetCheckoutCustomerDto, type SetDefinitionProductsDto as SetDefinitionProductsInput, type SetMetafieldPlatformsDto as SetMetafieldPlatformsInput, 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 SupportedLocaleObject, 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 UpdateAttachmentInput, type UpdateAttributeDto as UpdateAttributeInput, type UpdateAttributeOptionDto as UpdateAttributeOptionInput, type UpdateBrandDto as UpdateBrandInput, type UpdateCartItemDto, type UpdateCategoryDto as UpdateCategoryInput, type UpdateContentInput, 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 UpdateModifierGroupInput, type UpdateModifierInput, 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, deriveSeoDescription, enableDevGuards, formatMoney, formatPrice, formatProductPrice, formatVariantPrice, getCartItemImage, getCartItemName, getCartTotals, getDescriptionContent, getDirectionForLocale, formatPrice as getPriceDisplay, getProductCustomizationFields, getProductMetafield, getProductMetafieldValue, getProductMetafieldsByType, getProductPrice, getProductPriceInfo, getProductSwatches, getStockStatus, getVariantOptions, getVariantPrice, isAllowedPaymentUrl, isCouponApplicableToProduct, isHtmlDescription, isWebhookEventType, parseWebhookEvent, safePaymentRedirect, stripHtml, verifyWebhook };
10012
+ export { type AddToCartDto, type AnnouncementContent, type AnnouncementSeverity, type AppliedDiscount, type ApplyCouponDto, type AttachModifierGroupInput, 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 CartIncludeOption, type CartIncludeOptions, type CartItem, type CartItemModifierLine, type CartNudge, type CartRecommendationsResponse, type CartStatus, type CartUpgradeSuggestion, type CartUpgradesResponse, type CartWithIncludes, 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 ContactFormFieldType, type ContactFormFieldValidation, type ContactFormPublic, type ContactFormPublicField, type ContactFormSummary, type Content, type ContentDataMap, type ContentStatus, type ContentSummary, type ContentType, 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 CreateContentInput, type CreateCouponDto, type CreateCustomApiDto, type CreateCustomerDto, type CreateEmailTemplateDto as CreateEmailTemplateInput, type CreateGuestOrderDto, type CreateInquiryInput, type CreateInquiryResponse, type CreateMetafieldDefinitionDto as CreateMetafieldDefinitionInput, type CreateModifierGroupInput, type CreateModifierInput, 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 FaqContent, type FaqItem, type FooterColumn, type FooterContent, type FooterLink, type FooterSocialLink, type FormatPriceOptions, type FormatProductPriceOptions, type FreeAllocationPolicy, type FulfillOrderDto, type GuestCheckoutStartResponse, type GuestOrderResponse, type HeaderContent, type HeaderCta, type HeaderLogo, type HeaderNavItem, type InsufficientStockError, type InventoryInfo, type InventoryReservationStrategy, type InventorySyncStatus, type InventoryTrackingMode, type InvitationStatus, type InviteMemberDto as InviteMemberInput, type InviteStoreMemberDto as InviteStoreMemberInput, type ListModifierGroupsParams, type LocalCart, type LocalCartItem, type LockedVariant, type MergeCartsDto, type MetafieldConflict, type MetafieldConflictResolution, type MetafieldDefinition, type MetafieldType, type Modifier, type ModifierGroup, type ModifierSelection, type ModifierSelectionType, type ModifierValidationCode, type ModifierValidationError, type MyProductReview, 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 OrderStatusChange, type PageContent, type PageSeo, type PaginatedResponse, type PaymentClientSdk, type PaymentConfig, type PaymentIntent, type PaymentProvider, type PaymentProviderConfig, type PaymentProvidersConfig, type PaymentStatus, type PaymentUrlOptions, type PickupLocation, type PlatformCouponCapabilities, type PlatformMetafieldMetadata, type PreviewEmailTemplateDto as PreviewEmailTemplateInput, type Product, type ProductAttributeInput, type ProductAvailability, type ProductCustomizationField, type ProductDiscount, type ProductDiscountBadge, type ProductImage, type ProductMetafield, type ProductMetafieldValue, type ProductModifierGroupAttachment, type ProductQueryParams, type ProductRecommendation, type ProductRecommendationsResponse, type ProductRelationType, type ProductReview, type ProductReviewAdmin, type ProductSuggestion, type ProductVariant, type PublicMetafieldDefinition, type PublishProductResponse, RTL_LOCALES, type RecommendationVariant, type ReconcileInventoryResponse, type Refund, type RefundLineItem, type RefundLineItemResponse, type RefundType, type RegisterCustomerDto, type ReservationInfo, type ResolveMetafieldConflictDto as ResolveMetafieldConflictInput, type ResolveSyncConflictDto as ResolveSyncConflictInput, type RichTextContent, SDK_VERSION, type SearchSuggestions, type SelectPickupLocationDto, type SelectShippingMethodDto, type SendInvoiceDto, type SessionCartRef, type SetBillingAddressDto, type SetCheckoutCustomFieldsDto, type SetCheckoutCustomerDto, type SetDefinitionProductsDto as SetDefinitionProductsInput, type SetMetafieldPlatformsDto as SetMetafieldPlatformsInput, 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 SubmitProductReviewInput, type SupportedLocaleObject, 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 UpdateAttachmentInput, type UpdateAttributeDto as UpdateAttributeInput, type UpdateAttributeOptionDto as UpdateAttributeOptionInput, type UpdateBrandDto as UpdateBrandInput, type UpdateCartItemDto, type UpdateCategoryDto as UpdateCategoryInput, type UpdateContentInput, 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 UpdateModifierGroupInput, type UpdateModifierInput, 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, type WriteProductReviewInput, createWebhookHandler, deriveSeoDescription, enableDevGuards, formatMoney, formatPrice, formatProductPrice, formatVariantPrice, getCartItemImage, getCartItemName, getCartTotals, getDescriptionContent, getDirectionForLocale, formatPrice as getPriceDisplay, getProductCustomizationFields, getProductMetafield, getProductMetafieldValue, getProductMetafieldsByType, getProductPrice, getProductPriceInfo, getProductSwatches, getStockStatus, getVariantOptions, getVariantPrice, isAllowedPaymentUrl, isCouponApplicableToProduct, isHtmlDescription, isWebhookEventType, parseWebhookEvent, safePaymentRedirect, stripHtml, verifyWebhook };
package/dist/index.js CHANGED
@@ -185,7 +185,7 @@ function isDevGuardsEnabled() {
185
185
  }
186
186
 
187
187
  // src/version.ts
188
- var SDK_VERSION = "1.41.0";
188
+ var SDK_VERSION = "1.42.0";
189
189
 
190
190
  // src/client.ts
191
191
  var DEFAULT_BASE_URL = "https://api.brainerce.com";
@@ -6315,6 +6315,129 @@ var BrainerceClient = class {
6315
6315
  400
6316
6316
  );
6317
6317
  }
6318
+ // -------------------- Loyalty --------------------
6319
+ // Storefront-mode only (storeId + customerToken). The backend exposes loyalty
6320
+ // solely under /api/stores/:storeId/loyalty — there is no vibe-coded route, so
6321
+ // these do NOT branch on isVibeCodedMode() (that would 404 silently).
6322
+ /**
6323
+ * Get the logged-in customer's loyalty status: enrollment, points balance,
6324
+ * lifetime earned, and the program's display config (requires customerToken).
6325
+ * Only available in storefront mode. `program` is null when the store has no
6326
+ * loyalty program.
6327
+ *
6328
+ * @example
6329
+ * ```typescript
6330
+ * client.setCustomerToken(auth.token);
6331
+ * const status = await client.getLoyaltyStatus();
6332
+ * if (status.enrolled) console.log(`${status.pointsBalance} ${status.program?.pointsName}`);
6333
+ * ```
6334
+ */
6335
+ async getLoyaltyStatus() {
6336
+ if (!this.customerToken && !this.proxyMode) {
6337
+ throw new BrainerceError(
6338
+ "Customer token required. Call setCustomerToken() after login.",
6339
+ 401
6340
+ );
6341
+ }
6342
+ if (this.storeId && !this.apiKey) {
6343
+ return this.storefrontRequest("GET", "/loyalty/me");
6344
+ }
6345
+ throw new BrainerceError("getLoyaltyStatus is only available in storefront mode", 400);
6346
+ }
6347
+ /**
6348
+ * Enroll the logged-in customer in the store's loyalty program (requires
6349
+ * customerToken). Idempotent — returns the same status shape as
6350
+ * getLoyaltyStatus(). Only available in storefront mode.
6351
+ *
6352
+ * @example
6353
+ * ```typescript
6354
+ * const status = await client.enrollInLoyalty();
6355
+ * ```
6356
+ */
6357
+ async enrollInLoyalty() {
6358
+ if (!this.customerToken && !this.proxyMode) {
6359
+ throw new BrainerceError(
6360
+ "Customer token required. Call setCustomerToken() after login.",
6361
+ 401
6362
+ );
6363
+ }
6364
+ if (this.storeId && !this.apiKey) {
6365
+ return this.storefrontRequest("POST", "/loyalty/enroll");
6366
+ }
6367
+ throw new BrainerceError("enrollInLoyalty is only available in storefront mode", 400);
6368
+ }
6369
+ /**
6370
+ * List the rewards the customer can redeem points for (active rewards, cheapest
6371
+ * first). Requires customerToken. Only available in storefront mode.
6372
+ *
6373
+ * @example
6374
+ * ```typescript
6375
+ * client.setCustomerToken(auth.token);
6376
+ * const rewards = await client.getAvailableRewards();
6377
+ * ```
6378
+ */
6379
+ async getAvailableRewards() {
6380
+ if (!this.customerToken && !this.proxyMode) {
6381
+ throw new BrainerceError(
6382
+ "Customer token required. Call setCustomerToken() after login.",
6383
+ 401
6384
+ );
6385
+ }
6386
+ if (this.storeId && !this.apiKey) {
6387
+ return this.storefrontRequest("GET", "/loyalty/rewards/available");
6388
+ }
6389
+ throw new BrainerceError("getAvailableRewards is only available in storefront mode", 400);
6390
+ }
6391
+ /**
6392
+ * Redeem a reward: spends the customer's points and mints a one-time coupon
6393
+ * that applies at checkout (requires customerToken). Only available in
6394
+ * storefront mode.
6395
+ *
6396
+ * @example
6397
+ * ```typescript
6398
+ * const { couponCode, pointsBalance } = await client.redeemLoyaltyReward('rw_123');
6399
+ * // apply couponCode to the cart at checkout
6400
+ * ```
6401
+ */
6402
+ async redeemLoyaltyReward(rewardId) {
6403
+ if (!this.customerToken && !this.proxyMode) {
6404
+ throw new BrainerceError(
6405
+ "Customer token required. Call setCustomerToken() after login.",
6406
+ 401
6407
+ );
6408
+ }
6409
+ if (this.storeId && !this.apiKey) {
6410
+ return this.storefrontRequest("POST", "/loyalty/redeem", { rewardId });
6411
+ }
6412
+ throw new BrainerceError("redeemLoyaltyReward is only available in storefront mode", 400);
6413
+ }
6414
+ /**
6415
+ * Report a social share, granting the SOCIAL_SHARE earning-rule bonus if the
6416
+ * store has one configured (requires customerToken). Self-reported — no
6417
+ * share-tracking infra — and capped at once per customer per program. Only
6418
+ * available in storefront mode.
6419
+ *
6420
+ * @example
6421
+ * ```typescript
6422
+ * await client.reportSocialShare('instagram');
6423
+ * ```
6424
+ */
6425
+ async reportSocialShare(platform) {
6426
+ if (!this.customerToken && !this.proxyMode) {
6427
+ throw new BrainerceError(
6428
+ "Customer token required. Call setCustomerToken() after login.",
6429
+ 401
6430
+ );
6431
+ }
6432
+ if (this.storeId && !this.apiKey) {
6433
+ return this.storefrontRequest(
6434
+ "POST",
6435
+ "/loyalty/social-share",
6436
+ platform ? { platform } : {}
6437
+ );
6438
+ }
6439
+ throw new BrainerceError("reportSocialShare is only available in storefront mode", 400);
6440
+ }
6318
6441
  /**
6319
6442
  * Get the current customer's orders (requires customerToken)
6320
6443
  * Works in vibe-coded and storefront modes
package/dist/index.mjs CHANGED
@@ -115,7 +115,7 @@ function isDevGuardsEnabled() {
115
115
  }
116
116
 
117
117
  // src/version.ts
118
- var SDK_VERSION = "1.41.0";
118
+ var SDK_VERSION = "1.42.0";
119
119
 
120
120
  // src/client.ts
121
121
  var DEFAULT_BASE_URL = "https://api.brainerce.com";
@@ -6245,6 +6245,129 @@ var BrainerceClient = class {
6245
6245
  400
6246
6246
  );
6247
6247
  }
6248
+ // -------------------- Loyalty --------------------
6249
+ // Storefront-mode only (storeId + customerToken). The backend exposes loyalty
6250
+ // solely under /api/stores/:storeId/loyalty — there is no vibe-coded route, so
6251
+ // these do NOT branch on isVibeCodedMode() (that would 404 silently).
6252
+ /**
6253
+ * Get the logged-in customer's loyalty status: enrollment, points balance,
6254
+ * lifetime earned, and the program's display config (requires customerToken).
6255
+ * Only available in storefront mode. `program` is null when the store has no
6256
+ * loyalty program.
6257
+ *
6258
+ * @example
6259
+ * ```typescript
6260
+ * client.setCustomerToken(auth.token);
6261
+ * const status = await client.getLoyaltyStatus();
6262
+ * if (status.enrolled) console.log(`${status.pointsBalance} ${status.program?.pointsName}`);
6263
+ * ```
6264
+ */
6265
+ async getLoyaltyStatus() {
6266
+ if (!this.customerToken && !this.proxyMode) {
6267
+ throw new BrainerceError(
6268
+ "Customer token required. Call setCustomerToken() after login.",
6269
+ 401
6270
+ );
6271
+ }
6272
+ if (this.storeId && !this.apiKey) {
6273
+ return this.storefrontRequest("GET", "/loyalty/me");
6274
+ }
6275
+ throw new BrainerceError("getLoyaltyStatus is only available in storefront mode", 400);
6276
+ }
6277
+ /**
6278
+ * Enroll the logged-in customer in the store's loyalty program (requires
6279
+ * customerToken). Idempotent — returns the same status shape as
6280
+ * getLoyaltyStatus(). Only available in storefront mode.
6281
+ *
6282
+ * @example
6283
+ * ```typescript
6284
+ * const status = await client.enrollInLoyalty();
6285
+ * ```
6286
+ */
6287
+ async enrollInLoyalty() {
6288
+ if (!this.customerToken && !this.proxyMode) {
6289
+ throw new BrainerceError(
6290
+ "Customer token required. Call setCustomerToken() after login.",
6291
+ 401
6292
+ );
6293
+ }
6294
+ if (this.storeId && !this.apiKey) {
6295
+ return this.storefrontRequest("POST", "/loyalty/enroll");
6296
+ }
6297
+ throw new BrainerceError("enrollInLoyalty is only available in storefront mode", 400);
6298
+ }
6299
+ /**
6300
+ * List the rewards the customer can redeem points for (active rewards, cheapest
6301
+ * first). Requires customerToken. Only available in storefront mode.
6302
+ *
6303
+ * @example
6304
+ * ```typescript
6305
+ * client.setCustomerToken(auth.token);
6306
+ * const rewards = await client.getAvailableRewards();
6307
+ * ```
6308
+ */
6309
+ async getAvailableRewards() {
6310
+ if (!this.customerToken && !this.proxyMode) {
6311
+ throw new BrainerceError(
6312
+ "Customer token required. Call setCustomerToken() after login.",
6313
+ 401
6314
+ );
6315
+ }
6316
+ if (this.storeId && !this.apiKey) {
6317
+ return this.storefrontRequest("GET", "/loyalty/rewards/available");
6318
+ }
6319
+ throw new BrainerceError("getAvailableRewards is only available in storefront mode", 400);
6320
+ }
6321
+ /**
6322
+ * Redeem a reward: spends the customer's points and mints a one-time coupon
6323
+ * that applies at checkout (requires customerToken). Only available in
6324
+ * storefront mode.
6325
+ *
6326
+ * @example
6327
+ * ```typescript
6328
+ * const { couponCode, pointsBalance } = await client.redeemLoyaltyReward('rw_123');
6329
+ * // apply couponCode to the cart at checkout
6330
+ * ```
6331
+ */
6332
+ async redeemLoyaltyReward(rewardId) {
6333
+ if (!this.customerToken && !this.proxyMode) {
6334
+ throw new BrainerceError(
6335
+ "Customer token required. Call setCustomerToken() after login.",
6336
+ 401
6337
+ );
6338
+ }
6339
+ if (this.storeId && !this.apiKey) {
6340
+ return this.storefrontRequest("POST", "/loyalty/redeem", { rewardId });
6341
+ }
6342
+ throw new BrainerceError("redeemLoyaltyReward is only available in storefront mode", 400);
6343
+ }
6344
+ /**
6345
+ * Report a social share, granting the SOCIAL_SHARE earning-rule bonus if the
6346
+ * store has one configured (requires customerToken). Self-reported — no
6347
+ * share-tracking infra — and capped at once per customer per program. Only
6348
+ * available in storefront mode.
6349
+ *
6350
+ * @example
6351
+ * ```typescript
6352
+ * await client.reportSocialShare('instagram');
6353
+ * ```
6354
+ */
6355
+ async reportSocialShare(platform) {
6356
+ if (!this.customerToken && !this.proxyMode) {
6357
+ throw new BrainerceError(
6358
+ "Customer token required. Call setCustomerToken() after login.",
6359
+ 401
6360
+ );
6361
+ }
6362
+ if (this.storeId && !this.apiKey) {
6363
+ return this.storefrontRequest(
6364
+ "POST",
6365
+ "/loyalty/social-share",
6366
+ platform ? { platform } : {}
6367
+ );
6368
+ }
6369
+ throw new BrainerceError("reportSocialShare is only available in storefront mode", 400);
6370
+ }
6248
6371
  /**
6249
6372
  * Get the current customer's orders (requires customerToken)
6250
6373
  * Works in vibe-coded and storefront modes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "brainerce",
3
- "version": "1.41.0",
3
+ "version": "1.43.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",