brainerce 1.41.0 → 1.42.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 +47 -1
- package/dist/index.d.mts +120 -3
- package/dist/index.d.ts +120 -3
- package/dist/index.js +97 -1
- package/dist/index.mjs +97 -1
- package/package.json +1 -1
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 + redeem) | `client.getLoyaltyStatus()`, `client.getAvailableRewards()`, `client.redeemLoyaltyReward(id)` | 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 (
|
|
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,32 @@ 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.
|
|
2924
|
+
// `program` is null if the store has no loyalty program.
|
|
2925
|
+
const status = await client.getLoyaltyStatus();
|
|
2926
|
+
if (status.enrolled) {
|
|
2927
|
+
console.log(`${status.pointsBalance} ${status.program?.pointsName}`);
|
|
2928
|
+
}
|
|
2929
|
+
|
|
2930
|
+
// Enroll (idempotent) — only if the program is ACTIVE.
|
|
2931
|
+
await client.enrollInLoyalty();
|
|
2932
|
+
|
|
2933
|
+
// Rewards the customer can redeem, cheapest first.
|
|
2934
|
+
const rewards = await client.getAvailableRewards();
|
|
2935
|
+
|
|
2936
|
+
// Redeem → spends points, returns a one-time coupon code to apply to the cart.
|
|
2937
|
+
const { couponCode, discountValue, pointsBalance } =
|
|
2938
|
+
await client.redeemLoyaltyReward(rewards[0].id);
|
|
2939
|
+
await client.applyCoupon(cartId, couponCode);
|
|
2940
|
+
```
|
|
2941
|
+
|
|
2896
2942
|
#### Auth Response Type
|
|
2897
2943
|
|
|
2898
2944
|
```typescript
|
package/dist/index.d.mts
CHANGED
|
@@ -248,6 +248,51 @@ interface CustomerProfile {
|
|
|
248
248
|
createdAt: string;
|
|
249
249
|
updatedAt: string;
|
|
250
250
|
}
|
|
251
|
+
/** A store's loyalty program status for a logged-in customer. */
|
|
252
|
+
interface LoyaltyStatus {
|
|
253
|
+
/** Whether the customer has a membership in the program. */
|
|
254
|
+
enrolled: boolean;
|
|
255
|
+
/** Redeemable points balance (pending earns excluded). */
|
|
256
|
+
pointsBalance: number;
|
|
257
|
+
/** Total points ever earned (confirmed). */
|
|
258
|
+
lifetimeEarned: number;
|
|
259
|
+
/** Program display config, or null when the store has no loyalty program. */
|
|
260
|
+
program: {
|
|
261
|
+
/** Display name for points (e.g. "points", "coins"). */
|
|
262
|
+
pointsName: string;
|
|
263
|
+
/** Points needed to redeem one unit of store currency. */
|
|
264
|
+
currencyRatio: number;
|
|
265
|
+
status: 'DRAFT' | 'ACTIVE' | 'PAUSED';
|
|
266
|
+
} | null;
|
|
267
|
+
}
|
|
268
|
+
/** A reward a customer can redeem points for (fixed-amount discount coupon). */
|
|
269
|
+
interface LoyaltyReward {
|
|
270
|
+
id: string;
|
|
271
|
+
name: string;
|
|
272
|
+
description: string | null;
|
|
273
|
+
/** Points required to redeem this reward. */
|
|
274
|
+
pointsCost: number;
|
|
275
|
+
/** Fixed discount amount the minted coupon is worth, in store currency. */
|
|
276
|
+
discountValue: number;
|
|
277
|
+
/** Minimum order amount for the coupon to apply, or null. */
|
|
278
|
+
minOrderAmount: number | null;
|
|
279
|
+
/** How many times a single customer may redeem this reward. */
|
|
280
|
+
maxUsesPerUser: number;
|
|
281
|
+
isActive: boolean;
|
|
282
|
+
createdAt: string;
|
|
283
|
+
updatedAt: string;
|
|
284
|
+
}
|
|
285
|
+
/** Result of redeeming a reward — a one-time coupon plus the new balance. */
|
|
286
|
+
interface RedeemRewardResult {
|
|
287
|
+
/** The minted one-time coupon code to apply at checkout. */
|
|
288
|
+
couponCode: string;
|
|
289
|
+
/** Fixed discount amount the coupon is worth. */
|
|
290
|
+
discountValue: number;
|
|
291
|
+
/** Points spent on this redemption. */
|
|
292
|
+
pointsSpent: number;
|
|
293
|
+
/** The customer's remaining points balance after redemption. */
|
|
294
|
+
pointsBalance: number;
|
|
295
|
+
}
|
|
251
296
|
interface ProductMetafield {
|
|
252
297
|
id: string;
|
|
253
298
|
definitionId: string;
|
|
@@ -476,6 +521,14 @@ interface WriteProductReviewInput {
|
|
|
476
521
|
rating: number;
|
|
477
522
|
body?: string;
|
|
478
523
|
}
|
|
524
|
+
/**
|
|
525
|
+
* @deprecated Use `WriteProductReviewInput`. Customers no longer pass author info
|
|
526
|
+
* directly; it's derived from the authenticated customer profile.
|
|
527
|
+
*/
|
|
528
|
+
interface SubmitProductReviewInput extends WriteProductReviewInput {
|
|
529
|
+
authorName?: string;
|
|
530
|
+
authorEmail?: string;
|
|
531
|
+
}
|
|
479
532
|
/**
|
|
480
533
|
* Returned by `client.getMyProductReview(productId)`. Tells the storefront which
|
|
481
534
|
* UI to render: sign-in / not-eligible / submit / edit.
|
|
@@ -4850,7 +4903,13 @@ interface CheckoutCustomFieldDefinition {
|
|
|
4850
4903
|
key: string;
|
|
4851
4904
|
name: string;
|
|
4852
4905
|
description?: string | null;
|
|
4853
|
-
|
|
4906
|
+
/**
|
|
4907
|
+
* `IMAGE` renders a file-upload control; its value is the uploaded file URL
|
|
4908
|
+
* (validated server-side to be a store-hosted upload). `GALLERY` and
|
|
4909
|
+
* `MULTI_SELECT` are NOT supported for checkout fields — those are
|
|
4910
|
+
* product-metafield-only (`ProductCustomizationField` / `MetafieldType`).
|
|
4911
|
+
*/
|
|
4912
|
+
type: 'TEXT' | 'TEXTAREA' | 'NUMBER' | 'BOOLEAN' | 'SELECT' | 'DATE' | 'IMAGE';
|
|
4854
4913
|
required: boolean;
|
|
4855
4914
|
position: number;
|
|
4856
4915
|
visibility: CheckoutFieldVisibility;
|
|
@@ -8095,6 +8154,16 @@ declare class BrainerceClient {
|
|
|
8095
8154
|
* ```
|
|
8096
8155
|
*/
|
|
8097
8156
|
createPaymentIntent(checkoutId: string, options?: {
|
|
8157
|
+
/**
|
|
8158
|
+
* Route the charge to a specific installed provider — pass the `id` from a
|
|
8159
|
+
* `getPaymentProviders()` entry. This is how you wire an additive express
|
|
8160
|
+
* button (e.g. PayPal as a `WALLET`): when the buyer taps it, call
|
|
8161
|
+
* `createPaymentIntent(checkoutId, { providerId: m.id })`. Omit to settle
|
|
8162
|
+
* through the store's primary card processor (`defaultProvider`). The
|
|
8163
|
+
* platform scopes this to the store, so only that store's own installed
|
|
8164
|
+
* providers are selectable.
|
|
8165
|
+
*/
|
|
8166
|
+
providerId?: string;
|
|
8098
8167
|
successUrl?: string;
|
|
8099
8168
|
cancelUrl?: string;
|
|
8100
8169
|
/**
|
|
@@ -8545,6 +8614,54 @@ declare class BrainerceClient {
|
|
|
8545
8614
|
phone?: string;
|
|
8546
8615
|
acceptsMarketing?: boolean;
|
|
8547
8616
|
}): Promise<CustomerProfile>;
|
|
8617
|
+
/**
|
|
8618
|
+
* Get the logged-in customer's loyalty status: enrollment, points balance,
|
|
8619
|
+
* lifetime earned, and the program's display config (requires customerToken).
|
|
8620
|
+
* Only available in storefront mode. `program` is null when the store has no
|
|
8621
|
+
* loyalty program.
|
|
8622
|
+
*
|
|
8623
|
+
* @example
|
|
8624
|
+
* ```typescript
|
|
8625
|
+
* client.setCustomerToken(auth.token);
|
|
8626
|
+
* const status = await client.getLoyaltyStatus();
|
|
8627
|
+
* if (status.enrolled) console.log(`${status.pointsBalance} ${status.program?.pointsName}`);
|
|
8628
|
+
* ```
|
|
8629
|
+
*/
|
|
8630
|
+
getLoyaltyStatus(): Promise<LoyaltyStatus>;
|
|
8631
|
+
/**
|
|
8632
|
+
* Enroll the logged-in customer in the store's loyalty program (requires
|
|
8633
|
+
* customerToken). Idempotent — returns the same status shape as
|
|
8634
|
+
* getLoyaltyStatus(). Only available in storefront mode.
|
|
8635
|
+
*
|
|
8636
|
+
* @example
|
|
8637
|
+
* ```typescript
|
|
8638
|
+
* const status = await client.enrollInLoyalty();
|
|
8639
|
+
* ```
|
|
8640
|
+
*/
|
|
8641
|
+
enrollInLoyalty(): Promise<LoyaltyStatus>;
|
|
8642
|
+
/**
|
|
8643
|
+
* List the rewards the customer can redeem points for (active rewards, cheapest
|
|
8644
|
+
* first). Requires customerToken. Only available in storefront mode.
|
|
8645
|
+
*
|
|
8646
|
+
* @example
|
|
8647
|
+
* ```typescript
|
|
8648
|
+
* client.setCustomerToken(auth.token);
|
|
8649
|
+
* const rewards = await client.getAvailableRewards();
|
|
8650
|
+
* ```
|
|
8651
|
+
*/
|
|
8652
|
+
getAvailableRewards(): Promise<LoyaltyReward[]>;
|
|
8653
|
+
/**
|
|
8654
|
+
* Redeem a reward: spends the customer's points and mints a one-time coupon
|
|
8655
|
+
* that applies at checkout (requires customerToken). Only available in
|
|
8656
|
+
* storefront mode.
|
|
8657
|
+
*
|
|
8658
|
+
* @example
|
|
8659
|
+
* ```typescript
|
|
8660
|
+
* const { couponCode, pointsBalance } = await client.redeemLoyaltyReward('rw_123');
|
|
8661
|
+
* // apply couponCode to the cart at checkout
|
|
8662
|
+
* ```
|
|
8663
|
+
*/
|
|
8664
|
+
redeemLoyaltyReward(rewardId: string): Promise<RedeemRewardResult>;
|
|
8548
8665
|
/**
|
|
8549
8666
|
* Get the current customer's orders (requires customerToken)
|
|
8550
8667
|
* Works in vibe-coded and storefront modes
|
|
@@ -9709,7 +9826,7 @@ declare class BrainerceError extends Error {
|
|
|
9709
9826
|
constructor(message: string, statusCode: number, details?: unknown);
|
|
9710
9827
|
}
|
|
9711
9828
|
|
|
9712
|
-
declare const SDK_VERSION = "1.
|
|
9829
|
+
declare const SDK_VERSION = "1.42.0";
|
|
9713
9830
|
|
|
9714
9831
|
/**
|
|
9715
9832
|
* Verify a webhook signature from Brainerce
|
|
@@ -9849,4 +9966,4 @@ declare function formatVariantPrice(variant: Pick<ProductVariant, 'price' | 'sal
|
|
|
9849
9966
|
/** Format any numeric amount as currency. Useful for cart totals, fees, etc. */
|
|
9850
9967
|
declare function formatMoney(amount: number, currency: string, locale?: string): string;
|
|
9851
9968
|
|
|
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 };
|
|
9969
|
+
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,51 @@ interface CustomerProfile {
|
|
|
248
248
|
createdAt: string;
|
|
249
249
|
updatedAt: string;
|
|
250
250
|
}
|
|
251
|
+
/** A store's loyalty program status for a logged-in customer. */
|
|
252
|
+
interface LoyaltyStatus {
|
|
253
|
+
/** Whether the customer has a membership in the program. */
|
|
254
|
+
enrolled: boolean;
|
|
255
|
+
/** Redeemable points balance (pending earns excluded). */
|
|
256
|
+
pointsBalance: number;
|
|
257
|
+
/** Total points ever earned (confirmed). */
|
|
258
|
+
lifetimeEarned: number;
|
|
259
|
+
/** Program display config, or null when the store has no loyalty program. */
|
|
260
|
+
program: {
|
|
261
|
+
/** Display name for points (e.g. "points", "coins"). */
|
|
262
|
+
pointsName: string;
|
|
263
|
+
/** Points needed to redeem one unit of store currency. */
|
|
264
|
+
currencyRatio: number;
|
|
265
|
+
status: 'DRAFT' | 'ACTIVE' | 'PAUSED';
|
|
266
|
+
} | null;
|
|
267
|
+
}
|
|
268
|
+
/** A reward a customer can redeem points for (fixed-amount discount coupon). */
|
|
269
|
+
interface LoyaltyReward {
|
|
270
|
+
id: string;
|
|
271
|
+
name: string;
|
|
272
|
+
description: string | null;
|
|
273
|
+
/** Points required to redeem this reward. */
|
|
274
|
+
pointsCost: number;
|
|
275
|
+
/** Fixed discount amount the minted coupon is worth, in store currency. */
|
|
276
|
+
discountValue: number;
|
|
277
|
+
/** Minimum order amount for the coupon to apply, or null. */
|
|
278
|
+
minOrderAmount: number | null;
|
|
279
|
+
/** How many times a single customer may redeem this reward. */
|
|
280
|
+
maxUsesPerUser: number;
|
|
281
|
+
isActive: boolean;
|
|
282
|
+
createdAt: string;
|
|
283
|
+
updatedAt: string;
|
|
284
|
+
}
|
|
285
|
+
/** Result of redeeming a reward — a one-time coupon plus the new balance. */
|
|
286
|
+
interface RedeemRewardResult {
|
|
287
|
+
/** The minted one-time coupon code to apply at checkout. */
|
|
288
|
+
couponCode: string;
|
|
289
|
+
/** Fixed discount amount the coupon is worth. */
|
|
290
|
+
discountValue: number;
|
|
291
|
+
/** Points spent on this redemption. */
|
|
292
|
+
pointsSpent: number;
|
|
293
|
+
/** The customer's remaining points balance after redemption. */
|
|
294
|
+
pointsBalance: number;
|
|
295
|
+
}
|
|
251
296
|
interface ProductMetafield {
|
|
252
297
|
id: string;
|
|
253
298
|
definitionId: string;
|
|
@@ -476,6 +521,14 @@ interface WriteProductReviewInput {
|
|
|
476
521
|
rating: number;
|
|
477
522
|
body?: string;
|
|
478
523
|
}
|
|
524
|
+
/**
|
|
525
|
+
* @deprecated Use `WriteProductReviewInput`. Customers no longer pass author info
|
|
526
|
+
* directly; it's derived from the authenticated customer profile.
|
|
527
|
+
*/
|
|
528
|
+
interface SubmitProductReviewInput extends WriteProductReviewInput {
|
|
529
|
+
authorName?: string;
|
|
530
|
+
authorEmail?: string;
|
|
531
|
+
}
|
|
479
532
|
/**
|
|
480
533
|
* Returned by `client.getMyProductReview(productId)`. Tells the storefront which
|
|
481
534
|
* UI to render: sign-in / not-eligible / submit / edit.
|
|
@@ -4850,7 +4903,13 @@ interface CheckoutCustomFieldDefinition {
|
|
|
4850
4903
|
key: string;
|
|
4851
4904
|
name: string;
|
|
4852
4905
|
description?: string | null;
|
|
4853
|
-
|
|
4906
|
+
/**
|
|
4907
|
+
* `IMAGE` renders a file-upload control; its value is the uploaded file URL
|
|
4908
|
+
* (validated server-side to be a store-hosted upload). `GALLERY` and
|
|
4909
|
+
* `MULTI_SELECT` are NOT supported for checkout fields — those are
|
|
4910
|
+
* product-metafield-only (`ProductCustomizationField` / `MetafieldType`).
|
|
4911
|
+
*/
|
|
4912
|
+
type: 'TEXT' | 'TEXTAREA' | 'NUMBER' | 'BOOLEAN' | 'SELECT' | 'DATE' | 'IMAGE';
|
|
4854
4913
|
required: boolean;
|
|
4855
4914
|
position: number;
|
|
4856
4915
|
visibility: CheckoutFieldVisibility;
|
|
@@ -8095,6 +8154,16 @@ declare class BrainerceClient {
|
|
|
8095
8154
|
* ```
|
|
8096
8155
|
*/
|
|
8097
8156
|
createPaymentIntent(checkoutId: string, options?: {
|
|
8157
|
+
/**
|
|
8158
|
+
* Route the charge to a specific installed provider — pass the `id` from a
|
|
8159
|
+
* `getPaymentProviders()` entry. This is how you wire an additive express
|
|
8160
|
+
* button (e.g. PayPal as a `WALLET`): when the buyer taps it, call
|
|
8161
|
+
* `createPaymentIntent(checkoutId, { providerId: m.id })`. Omit to settle
|
|
8162
|
+
* through the store's primary card processor (`defaultProvider`). The
|
|
8163
|
+
* platform scopes this to the store, so only that store's own installed
|
|
8164
|
+
* providers are selectable.
|
|
8165
|
+
*/
|
|
8166
|
+
providerId?: string;
|
|
8098
8167
|
successUrl?: string;
|
|
8099
8168
|
cancelUrl?: string;
|
|
8100
8169
|
/**
|
|
@@ -8545,6 +8614,54 @@ declare class BrainerceClient {
|
|
|
8545
8614
|
phone?: string;
|
|
8546
8615
|
acceptsMarketing?: boolean;
|
|
8547
8616
|
}): Promise<CustomerProfile>;
|
|
8617
|
+
/**
|
|
8618
|
+
* Get the logged-in customer's loyalty status: enrollment, points balance,
|
|
8619
|
+
* lifetime earned, and the program's display config (requires customerToken).
|
|
8620
|
+
* Only available in storefront mode. `program` is null when the store has no
|
|
8621
|
+
* loyalty program.
|
|
8622
|
+
*
|
|
8623
|
+
* @example
|
|
8624
|
+
* ```typescript
|
|
8625
|
+
* client.setCustomerToken(auth.token);
|
|
8626
|
+
* const status = await client.getLoyaltyStatus();
|
|
8627
|
+
* if (status.enrolled) console.log(`${status.pointsBalance} ${status.program?.pointsName}`);
|
|
8628
|
+
* ```
|
|
8629
|
+
*/
|
|
8630
|
+
getLoyaltyStatus(): Promise<LoyaltyStatus>;
|
|
8631
|
+
/**
|
|
8632
|
+
* Enroll the logged-in customer in the store's loyalty program (requires
|
|
8633
|
+
* customerToken). Idempotent — returns the same status shape as
|
|
8634
|
+
* getLoyaltyStatus(). Only available in storefront mode.
|
|
8635
|
+
*
|
|
8636
|
+
* @example
|
|
8637
|
+
* ```typescript
|
|
8638
|
+
* const status = await client.enrollInLoyalty();
|
|
8639
|
+
* ```
|
|
8640
|
+
*/
|
|
8641
|
+
enrollInLoyalty(): Promise<LoyaltyStatus>;
|
|
8642
|
+
/**
|
|
8643
|
+
* List the rewards the customer can redeem points for (active rewards, cheapest
|
|
8644
|
+
* first). Requires customerToken. Only available in storefront mode.
|
|
8645
|
+
*
|
|
8646
|
+
* @example
|
|
8647
|
+
* ```typescript
|
|
8648
|
+
* client.setCustomerToken(auth.token);
|
|
8649
|
+
* const rewards = await client.getAvailableRewards();
|
|
8650
|
+
* ```
|
|
8651
|
+
*/
|
|
8652
|
+
getAvailableRewards(): Promise<LoyaltyReward[]>;
|
|
8653
|
+
/**
|
|
8654
|
+
* Redeem a reward: spends the customer's points and mints a one-time coupon
|
|
8655
|
+
* that applies at checkout (requires customerToken). Only available in
|
|
8656
|
+
* storefront mode.
|
|
8657
|
+
*
|
|
8658
|
+
* @example
|
|
8659
|
+
* ```typescript
|
|
8660
|
+
* const { couponCode, pointsBalance } = await client.redeemLoyaltyReward('rw_123');
|
|
8661
|
+
* // apply couponCode to the cart at checkout
|
|
8662
|
+
* ```
|
|
8663
|
+
*/
|
|
8664
|
+
redeemLoyaltyReward(rewardId: string): Promise<RedeemRewardResult>;
|
|
8548
8665
|
/**
|
|
8549
8666
|
* Get the current customer's orders (requires customerToken)
|
|
8550
8667
|
* Works in vibe-coded and storefront modes
|
|
@@ -9709,7 +9826,7 @@ declare class BrainerceError extends Error {
|
|
|
9709
9826
|
constructor(message: string, statusCode: number, details?: unknown);
|
|
9710
9827
|
}
|
|
9711
9828
|
|
|
9712
|
-
declare const SDK_VERSION = "1.
|
|
9829
|
+
declare const SDK_VERSION = "1.42.0";
|
|
9713
9830
|
|
|
9714
9831
|
/**
|
|
9715
9832
|
* Verify a webhook signature from Brainerce
|
|
@@ -9849,4 +9966,4 @@ declare function formatVariantPrice(variant: Pick<ProductVariant, 'price' | 'sal
|
|
|
9849
9966
|
/** Format any numeric amount as currency. Useful for cart totals, fees, etc. */
|
|
9850
9967
|
declare function formatMoney(amount: number, currency: string, locale?: string): string;
|
|
9851
9968
|
|
|
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 };
|
|
9969
|
+
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.
|
|
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,102 @@ 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
|
+
}
|
|
6318
6414
|
/**
|
|
6319
6415
|
* Get the current customer's orders (requires customerToken)
|
|
6320
6416
|
* 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.
|
|
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,102 @@ 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
|
+
}
|
|
6248
6344
|
/**
|
|
6249
6345
|
* Get the current customer's orders (requires customerToken)
|
|
6250
6346
|
* Works in vibe-coded and storefront modes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "brainerce",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.42.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",
|