brainerce 1.42.0 → 1.44.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 +56 -7
- package/dist/index.d.mts +187 -4
- package/dist/index.d.ts +187 -4
- package/dist/index.js +155 -12
- package/dist/index.mjs +155 -12
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -46,7 +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)
|
|
49
|
+
| Loyalty & rewards (points balance + tiers + redeem) | `client.getLoyaltyStatus()`, `client.getAvailableRewards()`, `client.redeemLoyaltyReward(id)`, `client.reportSocialShare()` | conditional |
|
|
50
50
|
| Global header: cart count + search autocomplete | `client.getCart()`, `client.getSearchSuggestions(query)` | ✅ |
|
|
51
51
|
| Discount banners + product badges | `client.getDiscountBanners()`, `client.getProductDiscountBadge(productId)` | ✅ |
|
|
52
52
|
| Product reviews on PDP + JSON-LD aggregateRating | `client.listProductReviews(id)`, `client.submitProductReview(id, …)` | ✅ |
|
|
@@ -120,7 +120,7 @@ These sequences are non-negotiable. The order of SDK calls matters.
|
|
|
120
120
|
|
|
121
121
|
### Checkout flow
|
|
122
122
|
|
|
123
|
-
1. Collect customer email, billing address, shipping address (`line1`, `line2`, `city`, `region`, `postalCode`, `country`). `email` is required.
|
|
123
|
+
1. Collect customer email, billing address, shipping address (`line1`, `line2`, `city`, `region`, `postalCode`, `country`). `email` is required. Include an optional **"Order notes"** textarea by default — its value lands on the order for the merchant.
|
|
124
124
|
2. Submit address to get shipping rates:
|
|
125
125
|
```ts
|
|
126
126
|
const { checkout, rates } = await client.setShippingAddress(checkoutId, {
|
|
@@ -132,6 +132,7 @@ These sequences are non-negotiable. The order of SDK calls matters.
|
|
|
132
132
|
region,
|
|
133
133
|
postalCode,
|
|
134
134
|
country,
|
|
135
|
+
notes: orderNotes, // optional shopper note (max 2000 chars)
|
|
135
136
|
});
|
|
136
137
|
// rates = available shipping rates; checkout = updated checkout object
|
|
137
138
|
```
|
|
@@ -2920,25 +2921,68 @@ customers check their points balance, enroll, and redeem rewards for one-time
|
|
|
2920
2921
|
coupons that apply at checkout.
|
|
2921
2922
|
|
|
2922
2923
|
```typescript
|
|
2923
|
-
// Current status — points balance + program display config.
|
|
2924
|
-
// `program`
|
|
2924
|
+
// Current status — points balance + program display config + tier progress.
|
|
2925
|
+
// `program`/`tier`/`nextTier` are null if the store has no loyalty program
|
|
2926
|
+
// (or no tiers configured / the customer hasn't reached one yet).
|
|
2925
2927
|
const status = await client.getLoyaltyStatus();
|
|
2926
2928
|
if (status.enrolled) {
|
|
2927
2929
|
console.log(`${status.pointsBalance} ${status.program?.pointsName}`);
|
|
2930
|
+
if (status.nextTier) {
|
|
2931
|
+
console.log(`${status.pointsToNextTier} to reach ${status.nextTier.name}`);
|
|
2932
|
+
}
|
|
2928
2933
|
}
|
|
2929
2934
|
|
|
2930
|
-
// Enroll (idempotent) — only if the program is ACTIVE.
|
|
2935
|
+
// Enroll (idempotent) — only if the program is ACTIVE. May grant a one-time
|
|
2936
|
+
// "join the program" bonus if the store has one configured.
|
|
2931
2937
|
await client.enrollInLoyalty();
|
|
2932
2938
|
|
|
2933
|
-
// Rewards the customer can redeem, cheapest first
|
|
2939
|
+
// Rewards the customer can redeem, cheapest first (already filtered to ones
|
|
2940
|
+
// their current tier qualifies for).
|
|
2934
2941
|
const rewards = await client.getAvailableRewards();
|
|
2935
2942
|
|
|
2936
2943
|
// Redeem → spends points, returns a one-time coupon code to apply to the cart.
|
|
2937
|
-
|
|
2944
|
+
// `discountType` tells you how to interpret `discountValue` (currency amount
|
|
2945
|
+
// for FIXED_DISCOUNT, 0-100 percent for PERCENT_DISCOUNT).
|
|
2946
|
+
const { couponCode, discountType, discountValue, pointsBalance } =
|
|
2938
2947
|
await client.redeemLoyaltyReward(rewards[0].id);
|
|
2939
2948
|
await client.applyCoupon(cartId, couponCode);
|
|
2949
|
+
|
|
2950
|
+
// Self-reported social share — grants the SOCIAL_SHARE bonus if configured
|
|
2951
|
+
// (once per customer).
|
|
2952
|
+
await client.reportSocialShare('instagram');
|
|
2940
2953
|
```
|
|
2941
2954
|
|
|
2955
|
+
#### Referrals & Birthday Gifts
|
|
2956
|
+
|
|
2957
|
+
When the store enables referrals, `getLoyaltyStatus()` also returns the
|
|
2958
|
+
member's share code (`referralCode`) and — for customers who signed up via a
|
|
2959
|
+
referral link — their still-unused welcome coupon (`referralWelcomeCoupon`).
|
|
2960
|
+
|
|
2961
|
+
```typescript
|
|
2962
|
+
// 1. The referrer shares a link you build around their code.
|
|
2963
|
+
const { referralCode } = await client.getLoyaltyStatus();
|
|
2964
|
+
const shareUrl = `https://your-store.com/?ref=${referralCode}`;
|
|
2965
|
+
|
|
2966
|
+
// 2. On the landing page — public lookup, NO customerToken needed. Never
|
|
2967
|
+
// returns PII beyond the referrer's first name.
|
|
2968
|
+
const info = await client.getReferralInfo(refFromQuery);
|
|
2969
|
+
if (info.valid) {
|
|
2970
|
+
// e.g. "Jane sent you a gift: 10% off your first order"
|
|
2971
|
+
}
|
|
2972
|
+
|
|
2973
|
+
// 3. Pass the code at registration. Invalid codes never fail registration —
|
|
2974
|
+
// they're validated asynchronously server-side (with fraud checks).
|
|
2975
|
+
await client.registerCustomer({ email, password, referralCode: refFromQuery });
|
|
2976
|
+
|
|
2977
|
+
// 4. After the referee's first qualifying order, the referrer earns a points
|
|
2978
|
+
// bonus (held through the program's pending window, like order points).
|
|
2979
|
+
```
|
|
2980
|
+
|
|
2981
|
+
Birthday gifts need no SDK calls beyond profile data: set the customer's
|
|
2982
|
+
`birthMonth`/`birthDay` (1-12 / 1-31, no year) via `updateMyProfile()` and the
|
|
2983
|
+
platform emails a one-time gift coupon ahead of their birthday automatically
|
|
2984
|
+
(when the store has it enabled).
|
|
2985
|
+
|
|
2942
2986
|
#### Auth Response Type
|
|
2943
2987
|
|
|
2944
2988
|
```typescript
|
|
@@ -3878,6 +3922,11 @@ Merchants publish through the dashboard's per-row Platforms cell or via the
|
|
|
3878
3922
|
admin SDK below.
|
|
3879
3923
|
|
|
3880
3924
|
```typescript
|
|
3925
|
+
// Publish a product to a sales channel (accepts record ID or vc_* connection ID)
|
|
3926
|
+
await client.publishProductToSalesChannel('prod_id', 'vc_conn_id');
|
|
3927
|
+
await client.publishCouponToSalesChannel('coupon_id', 'vc_conn_id');
|
|
3928
|
+
await client.unpublishProductFromSalesChannel('prod_id', 'vc_conn_id');
|
|
3929
|
+
|
|
3881
3930
|
// Publish a category to a specific vibe-coded site
|
|
3882
3931
|
await client.publishCategoryToVibeCodedSite('cat_id', 'conn_id');
|
|
3883
3932
|
// Tag, brand, metafield definition follow the same shape:
|
package/dist/index.d.mts
CHANGED
|
@@ -248,6 +248,21 @@ 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
|
+
}
|
|
251
266
|
/** A store's loyalty program status for a logged-in customer. */
|
|
252
267
|
interface LoyaltyStatus {
|
|
253
268
|
/** Whether the customer has a membership in the program. */
|
|
@@ -264,21 +279,63 @@ interface LoyaltyStatus {
|
|
|
264
279
|
currencyRatio: number;
|
|
265
280
|
status: 'DRAFT' | 'ACTIVE' | 'PAUSED';
|
|
266
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
|
+
* The customer's referral share code — build your referral link around it
|
|
292
|
+
* (e.g. `https://your-store.com/?ref=<code>`). Null when the program has
|
|
293
|
+
* referrals disabled or the customer isn't enrolled. Lazy-created on first
|
|
294
|
+
* read of this endpoint.
|
|
295
|
+
*/
|
|
296
|
+
referralCode?: string | null;
|
|
297
|
+
/**
|
|
298
|
+
* The still-unused welcome coupon this customer received for registering via
|
|
299
|
+
* a referral link, or null (none / already used). `type` is the coupon type
|
|
300
|
+
* ('PERCENTAGE' | 'FIXED_AMOUNT').
|
|
301
|
+
*/
|
|
302
|
+
referralWelcomeCoupon?: {
|
|
303
|
+
code: string;
|
|
304
|
+
type: string;
|
|
305
|
+
value: number;
|
|
306
|
+
} | null;
|
|
307
|
+
}
|
|
308
|
+
/** Public referral-link lookup result (no auth needed) — see getReferralInfo(). */
|
|
309
|
+
interface ReferralInfo {
|
|
310
|
+
/** False for unknown codes, disabled referral programs, or inactive programs. */
|
|
311
|
+
valid: boolean;
|
|
312
|
+
/** Referrer's first name for "Jane sent you a gift" copy — never any other PII. */
|
|
313
|
+
referrerFirstName: string | null;
|
|
314
|
+
/** The welcome reward the referee will receive on signup, or null if none configured. */
|
|
315
|
+
reward: {
|
|
316
|
+
name: string;
|
|
317
|
+
type: 'FIXED_DISCOUNT' | 'PERCENT_DISCOUNT';
|
|
318
|
+
value: number;
|
|
319
|
+
minOrderAmount: number | null;
|
|
320
|
+
} | null;
|
|
267
321
|
}
|
|
268
|
-
/** A reward a customer can redeem points for
|
|
322
|
+
/** A reward a customer can redeem points for. */
|
|
269
323
|
interface LoyaltyReward {
|
|
270
324
|
id: string;
|
|
271
325
|
name: string;
|
|
272
326
|
description: string | null;
|
|
273
327
|
/** Points required to redeem this reward. */
|
|
274
328
|
pointsCost: number;
|
|
275
|
-
/**
|
|
329
|
+
/** FIXED_DISCOUNT: discountValue is a store-currency amount off. PERCENT_DISCOUNT: discountValue is a 0-100 percent off. */
|
|
330
|
+
type: 'FIXED_DISCOUNT' | 'PERCENT_DISCOUNT';
|
|
276
331
|
discountValue: number;
|
|
277
332
|
/** Minimum order amount for the coupon to apply, or null. */
|
|
278
333
|
minOrderAmount: number | null;
|
|
279
334
|
/** How many times a single customer may redeem this reward. */
|
|
280
335
|
maxUsesPerUser: number;
|
|
281
336
|
isActive: boolean;
|
|
337
|
+
/** Minimum tier level required to redeem this reward, or null for no restriction. */
|
|
338
|
+
minTierLevel: number | null;
|
|
282
339
|
createdAt: string;
|
|
283
340
|
updatedAt: string;
|
|
284
341
|
}
|
|
@@ -286,7 +343,9 @@ interface LoyaltyReward {
|
|
|
286
343
|
interface RedeemRewardResult {
|
|
287
344
|
/** The minted one-time coupon code to apply at checkout. */
|
|
288
345
|
couponCode: string;
|
|
289
|
-
/**
|
|
346
|
+
/** Matches the redeemed reward's `type` — tells you how to interpret discountValue. */
|
|
347
|
+
discountType: 'FIXED_DISCOUNT' | 'PERCENT_DISCOUNT';
|
|
348
|
+
/** Currency amount (FIXED_DISCOUNT) or percent 0-100 (PERCENT_DISCOUNT) the coupon is worth. */
|
|
290
349
|
discountValue: number;
|
|
291
350
|
/** Points spent on this redemption. */
|
|
292
351
|
pointsSpent: number;
|
|
@@ -1249,6 +1308,12 @@ interface Order {
|
|
|
1249
1308
|
*/
|
|
1250
1309
|
taxBreakdown?: TaxBreakdown | null;
|
|
1251
1310
|
createdAt: string;
|
|
1311
|
+
/**
|
|
1312
|
+
* The shopper's own order note from checkout, echoed back read-only
|
|
1313
|
+
* (e.g., "Please leave at the door"). Display it in order history /
|
|
1314
|
+
* confirmation views; it cannot be edited after purchase.
|
|
1315
|
+
*/
|
|
1316
|
+
notes?: string | null;
|
|
1252
1317
|
/** Payment method used (e.g., "card", "paypal", "cash_on_delivery"). */
|
|
1253
1318
|
paymentMethod?: string | null;
|
|
1254
1319
|
/** Financial status: "pending", "paid", "refunded", "partially_refunded", "voided". */
|
|
@@ -1823,6 +1888,12 @@ interface RegisterCustomerDto {
|
|
|
1823
1888
|
lastName?: string;
|
|
1824
1889
|
phone?: string;
|
|
1825
1890
|
acceptsMarketing?: boolean;
|
|
1891
|
+
/**
|
|
1892
|
+
* Loyalty referral share code (REF-XXXXXXXX) from a referrer's link.
|
|
1893
|
+
* Validated asynchronously after registration — an invalid code never fails
|
|
1894
|
+
* the registration itself.
|
|
1895
|
+
*/
|
|
1896
|
+
referralCode?: string;
|
|
1826
1897
|
}
|
|
1827
1898
|
type CartStatus = 'ACTIVE' | 'MERGED' | 'CONVERTED' | 'ABANDONED';
|
|
1828
1899
|
/**
|
|
@@ -2673,6 +2744,11 @@ interface Checkout {
|
|
|
2673
2744
|
customFieldValues?: Record<string, unknown> | null;
|
|
2674
2745
|
/** Applied coupon code */
|
|
2675
2746
|
couponCode?: string | null;
|
|
2747
|
+
/**
|
|
2748
|
+
* Order-level note from the shopper (set via setCheckoutCustomer).
|
|
2749
|
+
* Copied onto the order at completion and shown to the merchant.
|
|
2750
|
+
*/
|
|
2751
|
+
notes?: string | null;
|
|
2676
2752
|
/** Line items with nested product/variant data */
|
|
2677
2753
|
lineItems: CheckoutLineItem[];
|
|
2678
2754
|
/** Total item count */
|
|
@@ -2771,6 +2847,13 @@ interface SetCheckoutCustomerDto {
|
|
|
2771
2847
|
lastName?: string;
|
|
2772
2848
|
phone?: string;
|
|
2773
2849
|
acceptsMarketing?: boolean;
|
|
2850
|
+
/**
|
|
2851
|
+
* Order-level note from the shopper ("Please leave at the door").
|
|
2852
|
+
* Copied onto the order at completion — visible to the merchant in the
|
|
2853
|
+
* dashboard and included in the confirmation email. Max 2000 chars.
|
|
2854
|
+
* Send an empty string to clear a previously-set note.
|
|
2855
|
+
*/
|
|
2856
|
+
notes?: string;
|
|
2774
2857
|
}
|
|
2775
2858
|
/**
|
|
2776
2859
|
* Shipping address with customer email (required for checkout).
|
|
@@ -2791,6 +2874,13 @@ interface SetShippingAddressDto {
|
|
|
2791
2874
|
phone?: string;
|
|
2792
2875
|
/** Whether customer accepts marketing emails */
|
|
2793
2876
|
acceptsMarketing?: boolean;
|
|
2877
|
+
/**
|
|
2878
|
+
* Order-level note from the shopper ("Please leave at the door").
|
|
2879
|
+
* Rides along with the address step so single-page checkouts need no extra
|
|
2880
|
+
* call. Copied onto the order at completion — visible to the merchant in
|
|
2881
|
+
* the dashboard and included in the confirmation email. Max 2000 chars.
|
|
2882
|
+
*/
|
|
2883
|
+
notes?: string;
|
|
2794
2884
|
}
|
|
2795
2885
|
/**
|
|
2796
2886
|
* Billing address (email not required - already set in shipping address)
|
|
@@ -7862,12 +7952,18 @@ declare class BrainerceClient {
|
|
|
7862
7952
|
/**
|
|
7863
7953
|
* Set customer information on checkout
|
|
7864
7954
|
*
|
|
7955
|
+
* Also accepts an optional order-level `notes` field — every checkout page
|
|
7956
|
+
* should include an optional "Order notes" textarea by default and send its
|
|
7957
|
+
* value here. The note is copied onto the order at completion, shown to the
|
|
7958
|
+
* merchant in the dashboard, and included in the confirmation email.
|
|
7959
|
+
*
|
|
7865
7960
|
* @example
|
|
7866
7961
|
* ```typescript
|
|
7867
7962
|
* const checkout = await client.setCheckoutCustomer('checkout_123', {
|
|
7868
7963
|
* email: 'customer@example.com',
|
|
7869
7964
|
* firstName: 'John',
|
|
7870
7965
|
* lastName: 'Doe',
|
|
7966
|
+
* notes: 'Please leave the package at the door', // optional order notes
|
|
7871
7967
|
* });
|
|
7872
7968
|
* ```
|
|
7873
7969
|
*/
|
|
@@ -7905,6 +8001,10 @@ declare class BrainerceClient {
|
|
|
7905
8001
|
* **This is the first step of the simplified checkout flow.**
|
|
7906
8002
|
* Email is required and will be used for order confirmation.
|
|
7907
8003
|
*
|
|
8004
|
+
* Also accepts an optional order-level `notes` field — every checkout page
|
|
8005
|
+
* should include an optional "Order notes" textarea by default and send its
|
|
8006
|
+
* value here (or via `setCheckoutCustomer`). The note lands on the order.
|
|
8007
|
+
*
|
|
7908
8008
|
* @example
|
|
7909
8009
|
* ```typescript
|
|
7910
8010
|
* const { checkout, rates } = await client.setShippingAddress('checkout_123', {
|
|
@@ -7916,6 +8016,7 @@ declare class BrainerceClient {
|
|
|
7916
8016
|
* region: 'NY',
|
|
7917
8017
|
* postalCode: '10001',
|
|
7918
8018
|
* country: 'US',
|
|
8019
|
+
* notes: 'Please leave the package at the door', // optional order notes
|
|
7919
8020
|
* });
|
|
7920
8021
|
* console.log('Available rates:', rates);
|
|
7921
8022
|
* ```
|
|
@@ -8280,6 +8381,27 @@ declare class BrainerceClient {
|
|
|
8280
8381
|
* ```
|
|
8281
8382
|
*/
|
|
8282
8383
|
waitForOrder(checkoutId: string, options?: WaitForOrderOptions): Promise<WaitForOrderResult>;
|
|
8384
|
+
/**
|
|
8385
|
+
* Get the full order created by a completed checkout.
|
|
8386
|
+
*
|
|
8387
|
+
* Use this on the order-confirmation page (after `waitForOrder` succeeds)
|
|
8388
|
+
* when you want to render more than the order number — line items, shipping
|
|
8389
|
+
* address, financial breakdown, and the shopper's order note are all
|
|
8390
|
+
* included (the buyer-safe order shape, same as `getMyOrders`).
|
|
8391
|
+
*
|
|
8392
|
+
* Works for guests too: possession of the checkout id is the credential —
|
|
8393
|
+
* no customer token needed.
|
|
8394
|
+
*
|
|
8395
|
+
* @example
|
|
8396
|
+
* ```typescript
|
|
8397
|
+
* const result = await client.waitForOrder(checkoutId);
|
|
8398
|
+
* if (result.success) {
|
|
8399
|
+
* const order = await client.getOrderByCheckout(checkoutId);
|
|
8400
|
+
* // order.items, order.shippingAddress, order.notes, order.totalAmount, ...
|
|
8401
|
+
* }
|
|
8402
|
+
* ```
|
|
8403
|
+
*/
|
|
8404
|
+
getOrderByCheckout(checkoutId: string): Promise<Order>;
|
|
8283
8405
|
private readonly LOCAL_CART_KEY;
|
|
8284
8406
|
/**
|
|
8285
8407
|
* Check if localStorage is available (browser environment)
|
|
@@ -8607,12 +8729,17 @@ declare class BrainerceClient {
|
|
|
8607
8729
|
/**
|
|
8608
8730
|
* Update the current customer's profile (requires customerToken)
|
|
8609
8731
|
* Only available in storefront mode
|
|
8732
|
+
*
|
|
8733
|
+
* `birthMonth`/`birthDay` (1-12 / 1-31, no year — privacy) power the loyalty
|
|
8734
|
+
* birthday gift; they must be provided together.
|
|
8610
8735
|
*/
|
|
8611
8736
|
updateMyProfile(data: {
|
|
8612
8737
|
firstName?: string;
|
|
8613
8738
|
lastName?: string;
|
|
8614
8739
|
phone?: string;
|
|
8615
8740
|
acceptsMarketing?: boolean;
|
|
8741
|
+
birthMonth?: number;
|
|
8742
|
+
birthDay?: number;
|
|
8616
8743
|
}): Promise<CustomerProfile>;
|
|
8617
8744
|
/**
|
|
8618
8745
|
* Get the logged-in customer's loyalty status: enrollment, points balance,
|
|
@@ -8662,6 +8789,38 @@ declare class BrainerceClient {
|
|
|
8662
8789
|
* ```
|
|
8663
8790
|
*/
|
|
8664
8791
|
redeemLoyaltyReward(rewardId: string): Promise<RedeemRewardResult>;
|
|
8792
|
+
/**
|
|
8793
|
+
* Report a social share, granting the SOCIAL_SHARE earning-rule bonus if the
|
|
8794
|
+
* store has one configured (requires customerToken). Self-reported — no
|
|
8795
|
+
* share-tracking infra — and capped at once per customer per program. Only
|
|
8796
|
+
* available in storefront mode.
|
|
8797
|
+
*
|
|
8798
|
+
* @example
|
|
8799
|
+
* ```typescript
|
|
8800
|
+
* await client.reportSocialShare('instagram');
|
|
8801
|
+
* ```
|
|
8802
|
+
*/
|
|
8803
|
+
reportSocialShare(platform?: string): Promise<{
|
|
8804
|
+
awarded: boolean;
|
|
8805
|
+
points: number;
|
|
8806
|
+
}>;
|
|
8807
|
+
/**
|
|
8808
|
+
* Public referral-link lookup: who referred the visitor and what welcome
|
|
8809
|
+
* reward awaits them. No customerToken needed (like getStoreInfo/trackEvent)
|
|
8810
|
+
* — safe to call on a referral landing page before signup. Returns
|
|
8811
|
+
* `{ valid: false }` for unknown codes or stores with referrals disabled.
|
|
8812
|
+
* Only available in storefront mode.
|
|
8813
|
+
*
|
|
8814
|
+
* @example
|
|
8815
|
+
* ```typescript
|
|
8816
|
+
* const info = await client.getReferralInfo(searchParams.get('ref')!);
|
|
8817
|
+
* if (info.valid) {
|
|
8818
|
+
* showBanner(`${info.referrerFirstName ?? 'A friend'} sent you a gift!`);
|
|
8819
|
+
* // later: client.registerCustomer({ ...form, referralCode })
|
|
8820
|
+
* }
|
|
8821
|
+
* ```
|
|
8822
|
+
*/
|
|
8823
|
+
getReferralInfo(code: string): Promise<ReferralInfo>;
|
|
8665
8824
|
/**
|
|
8666
8825
|
* Get the current customer's orders (requires customerToken)
|
|
8667
8826
|
* Works in vibe-coded and storefront modes
|
|
@@ -9444,6 +9603,30 @@ declare class BrainerceClient {
|
|
|
9444
9603
|
unpublishMetafieldDefinitionFromVibeCodedSite(definitionId: string, vibeCodedConnectionId: string): Promise<{
|
|
9445
9604
|
success: boolean;
|
|
9446
9605
|
}>;
|
|
9606
|
+
/**
|
|
9607
|
+
* Publish a product to a sales channel (admin mode) — makes it visible on
|
|
9608
|
+
* that vibe-coded storefront. Accepts the sales-channel record ID or its
|
|
9609
|
+
* public `vc_*` connection ID.
|
|
9610
|
+
*/
|
|
9611
|
+
publishProductToSalesChannel(productId: string, salesChannelId: string): Promise<{
|
|
9612
|
+
success: boolean;
|
|
9613
|
+
}>;
|
|
9614
|
+
/** Unpublish a product from a sales channel (admin mode). */
|
|
9615
|
+
unpublishProductFromSalesChannel(productId: string, salesChannelId: string): Promise<{
|
|
9616
|
+
success: boolean;
|
|
9617
|
+
}>;
|
|
9618
|
+
/**
|
|
9619
|
+
* Publish a coupon to a sales channel (admin mode) — makes it redeemable on
|
|
9620
|
+
* that vibe-coded storefront. Accepts the sales-channel record ID or its
|
|
9621
|
+
* public `vc_*` connection ID.
|
|
9622
|
+
*/
|
|
9623
|
+
publishCouponToSalesChannel(couponId: string, salesChannelId: string): Promise<{
|
|
9624
|
+
success: boolean;
|
|
9625
|
+
}>;
|
|
9626
|
+
/** Unpublish a coupon from a sales channel (admin mode). */
|
|
9627
|
+
unpublishCouponFromSalesChannel(couponId: string, salesChannelId: string): Promise<{
|
|
9628
|
+
success: boolean;
|
|
9629
|
+
}>;
|
|
9447
9630
|
/** Publish a category to a vibe-coded site (admin mode). */
|
|
9448
9631
|
publishCategoryToVibeCodedSite(categoryId: string, vibeCodedConnectionId: string): Promise<{
|
|
9449
9632
|
success: boolean;
|
|
@@ -9966,4 +10149,4 @@ declare function formatVariantPrice(variant: Pick<ProductVariant, 'price' | 'sal
|
|
|
9966
10149
|
/** Format any numeric amount as currency. Useful for cart totals, fees, etc. */
|
|
9967
10150
|
declare function formatMoney(amount: number, currency: string, locale?: string): string;
|
|
9968
10151
|
|
|
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 };
|
|
10152
|
+
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 LoyaltyNextTierSummary, type LoyaltyReward, type LoyaltyStatus, type LoyaltyTierSummary, 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 RedeemRewardResult, type ReferralInfo, 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,21 @@ 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
|
+
}
|
|
251
266
|
/** A store's loyalty program status for a logged-in customer. */
|
|
252
267
|
interface LoyaltyStatus {
|
|
253
268
|
/** Whether the customer has a membership in the program. */
|
|
@@ -264,21 +279,63 @@ interface LoyaltyStatus {
|
|
|
264
279
|
currencyRatio: number;
|
|
265
280
|
status: 'DRAFT' | 'ACTIVE' | 'PAUSED';
|
|
266
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
|
+
* The customer's referral share code — build your referral link around it
|
|
292
|
+
* (e.g. `https://your-store.com/?ref=<code>`). Null when the program has
|
|
293
|
+
* referrals disabled or the customer isn't enrolled. Lazy-created on first
|
|
294
|
+
* read of this endpoint.
|
|
295
|
+
*/
|
|
296
|
+
referralCode?: string | null;
|
|
297
|
+
/**
|
|
298
|
+
* The still-unused welcome coupon this customer received for registering via
|
|
299
|
+
* a referral link, or null (none / already used). `type` is the coupon type
|
|
300
|
+
* ('PERCENTAGE' | 'FIXED_AMOUNT').
|
|
301
|
+
*/
|
|
302
|
+
referralWelcomeCoupon?: {
|
|
303
|
+
code: string;
|
|
304
|
+
type: string;
|
|
305
|
+
value: number;
|
|
306
|
+
} | null;
|
|
307
|
+
}
|
|
308
|
+
/** Public referral-link lookup result (no auth needed) — see getReferralInfo(). */
|
|
309
|
+
interface ReferralInfo {
|
|
310
|
+
/** False for unknown codes, disabled referral programs, or inactive programs. */
|
|
311
|
+
valid: boolean;
|
|
312
|
+
/** Referrer's first name for "Jane sent you a gift" copy — never any other PII. */
|
|
313
|
+
referrerFirstName: string | null;
|
|
314
|
+
/** The welcome reward the referee will receive on signup, or null if none configured. */
|
|
315
|
+
reward: {
|
|
316
|
+
name: string;
|
|
317
|
+
type: 'FIXED_DISCOUNT' | 'PERCENT_DISCOUNT';
|
|
318
|
+
value: number;
|
|
319
|
+
minOrderAmount: number | null;
|
|
320
|
+
} | null;
|
|
267
321
|
}
|
|
268
|
-
/** A reward a customer can redeem points for
|
|
322
|
+
/** A reward a customer can redeem points for. */
|
|
269
323
|
interface LoyaltyReward {
|
|
270
324
|
id: string;
|
|
271
325
|
name: string;
|
|
272
326
|
description: string | null;
|
|
273
327
|
/** Points required to redeem this reward. */
|
|
274
328
|
pointsCost: number;
|
|
275
|
-
/**
|
|
329
|
+
/** FIXED_DISCOUNT: discountValue is a store-currency amount off. PERCENT_DISCOUNT: discountValue is a 0-100 percent off. */
|
|
330
|
+
type: 'FIXED_DISCOUNT' | 'PERCENT_DISCOUNT';
|
|
276
331
|
discountValue: number;
|
|
277
332
|
/** Minimum order amount for the coupon to apply, or null. */
|
|
278
333
|
minOrderAmount: number | null;
|
|
279
334
|
/** How many times a single customer may redeem this reward. */
|
|
280
335
|
maxUsesPerUser: number;
|
|
281
336
|
isActive: boolean;
|
|
337
|
+
/** Minimum tier level required to redeem this reward, or null for no restriction. */
|
|
338
|
+
minTierLevel: number | null;
|
|
282
339
|
createdAt: string;
|
|
283
340
|
updatedAt: string;
|
|
284
341
|
}
|
|
@@ -286,7 +343,9 @@ interface LoyaltyReward {
|
|
|
286
343
|
interface RedeemRewardResult {
|
|
287
344
|
/** The minted one-time coupon code to apply at checkout. */
|
|
288
345
|
couponCode: string;
|
|
289
|
-
/**
|
|
346
|
+
/** Matches the redeemed reward's `type` — tells you how to interpret discountValue. */
|
|
347
|
+
discountType: 'FIXED_DISCOUNT' | 'PERCENT_DISCOUNT';
|
|
348
|
+
/** Currency amount (FIXED_DISCOUNT) or percent 0-100 (PERCENT_DISCOUNT) the coupon is worth. */
|
|
290
349
|
discountValue: number;
|
|
291
350
|
/** Points spent on this redemption. */
|
|
292
351
|
pointsSpent: number;
|
|
@@ -1249,6 +1308,12 @@ interface Order {
|
|
|
1249
1308
|
*/
|
|
1250
1309
|
taxBreakdown?: TaxBreakdown | null;
|
|
1251
1310
|
createdAt: string;
|
|
1311
|
+
/**
|
|
1312
|
+
* The shopper's own order note from checkout, echoed back read-only
|
|
1313
|
+
* (e.g., "Please leave at the door"). Display it in order history /
|
|
1314
|
+
* confirmation views; it cannot be edited after purchase.
|
|
1315
|
+
*/
|
|
1316
|
+
notes?: string | null;
|
|
1252
1317
|
/** Payment method used (e.g., "card", "paypal", "cash_on_delivery"). */
|
|
1253
1318
|
paymentMethod?: string | null;
|
|
1254
1319
|
/** Financial status: "pending", "paid", "refunded", "partially_refunded", "voided". */
|
|
@@ -1823,6 +1888,12 @@ interface RegisterCustomerDto {
|
|
|
1823
1888
|
lastName?: string;
|
|
1824
1889
|
phone?: string;
|
|
1825
1890
|
acceptsMarketing?: boolean;
|
|
1891
|
+
/**
|
|
1892
|
+
* Loyalty referral share code (REF-XXXXXXXX) from a referrer's link.
|
|
1893
|
+
* Validated asynchronously after registration — an invalid code never fails
|
|
1894
|
+
* the registration itself.
|
|
1895
|
+
*/
|
|
1896
|
+
referralCode?: string;
|
|
1826
1897
|
}
|
|
1827
1898
|
type CartStatus = 'ACTIVE' | 'MERGED' | 'CONVERTED' | 'ABANDONED';
|
|
1828
1899
|
/**
|
|
@@ -2673,6 +2744,11 @@ interface Checkout {
|
|
|
2673
2744
|
customFieldValues?: Record<string, unknown> | null;
|
|
2674
2745
|
/** Applied coupon code */
|
|
2675
2746
|
couponCode?: string | null;
|
|
2747
|
+
/**
|
|
2748
|
+
* Order-level note from the shopper (set via setCheckoutCustomer).
|
|
2749
|
+
* Copied onto the order at completion and shown to the merchant.
|
|
2750
|
+
*/
|
|
2751
|
+
notes?: string | null;
|
|
2676
2752
|
/** Line items with nested product/variant data */
|
|
2677
2753
|
lineItems: CheckoutLineItem[];
|
|
2678
2754
|
/** Total item count */
|
|
@@ -2771,6 +2847,13 @@ interface SetCheckoutCustomerDto {
|
|
|
2771
2847
|
lastName?: string;
|
|
2772
2848
|
phone?: string;
|
|
2773
2849
|
acceptsMarketing?: boolean;
|
|
2850
|
+
/**
|
|
2851
|
+
* Order-level note from the shopper ("Please leave at the door").
|
|
2852
|
+
* Copied onto the order at completion — visible to the merchant in the
|
|
2853
|
+
* dashboard and included in the confirmation email. Max 2000 chars.
|
|
2854
|
+
* Send an empty string to clear a previously-set note.
|
|
2855
|
+
*/
|
|
2856
|
+
notes?: string;
|
|
2774
2857
|
}
|
|
2775
2858
|
/**
|
|
2776
2859
|
* Shipping address with customer email (required for checkout).
|
|
@@ -2791,6 +2874,13 @@ interface SetShippingAddressDto {
|
|
|
2791
2874
|
phone?: string;
|
|
2792
2875
|
/** Whether customer accepts marketing emails */
|
|
2793
2876
|
acceptsMarketing?: boolean;
|
|
2877
|
+
/**
|
|
2878
|
+
* Order-level note from the shopper ("Please leave at the door").
|
|
2879
|
+
* Rides along with the address step so single-page checkouts need no extra
|
|
2880
|
+
* call. Copied onto the order at completion — visible to the merchant in
|
|
2881
|
+
* the dashboard and included in the confirmation email. Max 2000 chars.
|
|
2882
|
+
*/
|
|
2883
|
+
notes?: string;
|
|
2794
2884
|
}
|
|
2795
2885
|
/**
|
|
2796
2886
|
* Billing address (email not required - already set in shipping address)
|
|
@@ -7862,12 +7952,18 @@ declare class BrainerceClient {
|
|
|
7862
7952
|
/**
|
|
7863
7953
|
* Set customer information on checkout
|
|
7864
7954
|
*
|
|
7955
|
+
* Also accepts an optional order-level `notes` field — every checkout page
|
|
7956
|
+
* should include an optional "Order notes" textarea by default and send its
|
|
7957
|
+
* value here. The note is copied onto the order at completion, shown to the
|
|
7958
|
+
* merchant in the dashboard, and included in the confirmation email.
|
|
7959
|
+
*
|
|
7865
7960
|
* @example
|
|
7866
7961
|
* ```typescript
|
|
7867
7962
|
* const checkout = await client.setCheckoutCustomer('checkout_123', {
|
|
7868
7963
|
* email: 'customer@example.com',
|
|
7869
7964
|
* firstName: 'John',
|
|
7870
7965
|
* lastName: 'Doe',
|
|
7966
|
+
* notes: 'Please leave the package at the door', // optional order notes
|
|
7871
7967
|
* });
|
|
7872
7968
|
* ```
|
|
7873
7969
|
*/
|
|
@@ -7905,6 +8001,10 @@ declare class BrainerceClient {
|
|
|
7905
8001
|
* **This is the first step of the simplified checkout flow.**
|
|
7906
8002
|
* Email is required and will be used for order confirmation.
|
|
7907
8003
|
*
|
|
8004
|
+
* Also accepts an optional order-level `notes` field — every checkout page
|
|
8005
|
+
* should include an optional "Order notes" textarea by default and send its
|
|
8006
|
+
* value here (or via `setCheckoutCustomer`). The note lands on the order.
|
|
8007
|
+
*
|
|
7908
8008
|
* @example
|
|
7909
8009
|
* ```typescript
|
|
7910
8010
|
* const { checkout, rates } = await client.setShippingAddress('checkout_123', {
|
|
@@ -7916,6 +8016,7 @@ declare class BrainerceClient {
|
|
|
7916
8016
|
* region: 'NY',
|
|
7917
8017
|
* postalCode: '10001',
|
|
7918
8018
|
* country: 'US',
|
|
8019
|
+
* notes: 'Please leave the package at the door', // optional order notes
|
|
7919
8020
|
* });
|
|
7920
8021
|
* console.log('Available rates:', rates);
|
|
7921
8022
|
* ```
|
|
@@ -8280,6 +8381,27 @@ declare class BrainerceClient {
|
|
|
8280
8381
|
* ```
|
|
8281
8382
|
*/
|
|
8282
8383
|
waitForOrder(checkoutId: string, options?: WaitForOrderOptions): Promise<WaitForOrderResult>;
|
|
8384
|
+
/**
|
|
8385
|
+
* Get the full order created by a completed checkout.
|
|
8386
|
+
*
|
|
8387
|
+
* Use this on the order-confirmation page (after `waitForOrder` succeeds)
|
|
8388
|
+
* when you want to render more than the order number — line items, shipping
|
|
8389
|
+
* address, financial breakdown, and the shopper's order note are all
|
|
8390
|
+
* included (the buyer-safe order shape, same as `getMyOrders`).
|
|
8391
|
+
*
|
|
8392
|
+
* Works for guests too: possession of the checkout id is the credential —
|
|
8393
|
+
* no customer token needed.
|
|
8394
|
+
*
|
|
8395
|
+
* @example
|
|
8396
|
+
* ```typescript
|
|
8397
|
+
* const result = await client.waitForOrder(checkoutId);
|
|
8398
|
+
* if (result.success) {
|
|
8399
|
+
* const order = await client.getOrderByCheckout(checkoutId);
|
|
8400
|
+
* // order.items, order.shippingAddress, order.notes, order.totalAmount, ...
|
|
8401
|
+
* }
|
|
8402
|
+
* ```
|
|
8403
|
+
*/
|
|
8404
|
+
getOrderByCheckout(checkoutId: string): Promise<Order>;
|
|
8283
8405
|
private readonly LOCAL_CART_KEY;
|
|
8284
8406
|
/**
|
|
8285
8407
|
* Check if localStorage is available (browser environment)
|
|
@@ -8607,12 +8729,17 @@ declare class BrainerceClient {
|
|
|
8607
8729
|
/**
|
|
8608
8730
|
* Update the current customer's profile (requires customerToken)
|
|
8609
8731
|
* Only available in storefront mode
|
|
8732
|
+
*
|
|
8733
|
+
* `birthMonth`/`birthDay` (1-12 / 1-31, no year — privacy) power the loyalty
|
|
8734
|
+
* birthday gift; they must be provided together.
|
|
8610
8735
|
*/
|
|
8611
8736
|
updateMyProfile(data: {
|
|
8612
8737
|
firstName?: string;
|
|
8613
8738
|
lastName?: string;
|
|
8614
8739
|
phone?: string;
|
|
8615
8740
|
acceptsMarketing?: boolean;
|
|
8741
|
+
birthMonth?: number;
|
|
8742
|
+
birthDay?: number;
|
|
8616
8743
|
}): Promise<CustomerProfile>;
|
|
8617
8744
|
/**
|
|
8618
8745
|
* Get the logged-in customer's loyalty status: enrollment, points balance,
|
|
@@ -8662,6 +8789,38 @@ declare class BrainerceClient {
|
|
|
8662
8789
|
* ```
|
|
8663
8790
|
*/
|
|
8664
8791
|
redeemLoyaltyReward(rewardId: string): Promise<RedeemRewardResult>;
|
|
8792
|
+
/**
|
|
8793
|
+
* Report a social share, granting the SOCIAL_SHARE earning-rule bonus if the
|
|
8794
|
+
* store has one configured (requires customerToken). Self-reported — no
|
|
8795
|
+
* share-tracking infra — and capped at once per customer per program. Only
|
|
8796
|
+
* available in storefront mode.
|
|
8797
|
+
*
|
|
8798
|
+
* @example
|
|
8799
|
+
* ```typescript
|
|
8800
|
+
* await client.reportSocialShare('instagram');
|
|
8801
|
+
* ```
|
|
8802
|
+
*/
|
|
8803
|
+
reportSocialShare(platform?: string): Promise<{
|
|
8804
|
+
awarded: boolean;
|
|
8805
|
+
points: number;
|
|
8806
|
+
}>;
|
|
8807
|
+
/**
|
|
8808
|
+
* Public referral-link lookup: who referred the visitor and what welcome
|
|
8809
|
+
* reward awaits them. No customerToken needed (like getStoreInfo/trackEvent)
|
|
8810
|
+
* — safe to call on a referral landing page before signup. Returns
|
|
8811
|
+
* `{ valid: false }` for unknown codes or stores with referrals disabled.
|
|
8812
|
+
* Only available in storefront mode.
|
|
8813
|
+
*
|
|
8814
|
+
* @example
|
|
8815
|
+
* ```typescript
|
|
8816
|
+
* const info = await client.getReferralInfo(searchParams.get('ref')!);
|
|
8817
|
+
* if (info.valid) {
|
|
8818
|
+
* showBanner(`${info.referrerFirstName ?? 'A friend'} sent you a gift!`);
|
|
8819
|
+
* // later: client.registerCustomer({ ...form, referralCode })
|
|
8820
|
+
* }
|
|
8821
|
+
* ```
|
|
8822
|
+
*/
|
|
8823
|
+
getReferralInfo(code: string): Promise<ReferralInfo>;
|
|
8665
8824
|
/**
|
|
8666
8825
|
* Get the current customer's orders (requires customerToken)
|
|
8667
8826
|
* Works in vibe-coded and storefront modes
|
|
@@ -9444,6 +9603,30 @@ declare class BrainerceClient {
|
|
|
9444
9603
|
unpublishMetafieldDefinitionFromVibeCodedSite(definitionId: string, vibeCodedConnectionId: string): Promise<{
|
|
9445
9604
|
success: boolean;
|
|
9446
9605
|
}>;
|
|
9606
|
+
/**
|
|
9607
|
+
* Publish a product to a sales channel (admin mode) — makes it visible on
|
|
9608
|
+
* that vibe-coded storefront. Accepts the sales-channel record ID or its
|
|
9609
|
+
* public `vc_*` connection ID.
|
|
9610
|
+
*/
|
|
9611
|
+
publishProductToSalesChannel(productId: string, salesChannelId: string): Promise<{
|
|
9612
|
+
success: boolean;
|
|
9613
|
+
}>;
|
|
9614
|
+
/** Unpublish a product from a sales channel (admin mode). */
|
|
9615
|
+
unpublishProductFromSalesChannel(productId: string, salesChannelId: string): Promise<{
|
|
9616
|
+
success: boolean;
|
|
9617
|
+
}>;
|
|
9618
|
+
/**
|
|
9619
|
+
* Publish a coupon to a sales channel (admin mode) — makes it redeemable on
|
|
9620
|
+
* that vibe-coded storefront. Accepts the sales-channel record ID or its
|
|
9621
|
+
* public `vc_*` connection ID.
|
|
9622
|
+
*/
|
|
9623
|
+
publishCouponToSalesChannel(couponId: string, salesChannelId: string): Promise<{
|
|
9624
|
+
success: boolean;
|
|
9625
|
+
}>;
|
|
9626
|
+
/** Unpublish a coupon from a sales channel (admin mode). */
|
|
9627
|
+
unpublishCouponFromSalesChannel(couponId: string, salesChannelId: string): Promise<{
|
|
9628
|
+
success: boolean;
|
|
9629
|
+
}>;
|
|
9447
9630
|
/** Publish a category to a vibe-coded site (admin mode). */
|
|
9448
9631
|
publishCategoryToVibeCodedSite(categoryId: string, vibeCodedConnectionId: string): Promise<{
|
|
9449
9632
|
success: boolean;
|
|
@@ -9966,4 +10149,4 @@ declare function formatVariantPrice(variant: Pick<ProductVariant, 'price' | 'sal
|
|
|
9966
10149
|
/** Format any numeric amount as currency. Useful for cart totals, fees, etc. */
|
|
9967
10150
|
declare function formatMoney(amount: number, currency: string, locale?: string): string;
|
|
9968
10151
|
|
|
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 };
|
|
10152
|
+
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 LoyaltyNextTierSummary, type LoyaltyReward, type LoyaltyStatus, type LoyaltyTierSummary, 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 RedeemRewardResult, type ReferralInfo, 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
|
@@ -4771,12 +4771,18 @@ var BrainerceClient = class {
|
|
|
4771
4771
|
/**
|
|
4772
4772
|
* Set customer information on checkout
|
|
4773
4773
|
*
|
|
4774
|
+
* Also accepts an optional order-level `notes` field — every checkout page
|
|
4775
|
+
* should include an optional "Order notes" textarea by default and send its
|
|
4776
|
+
* value here. The note is copied onto the order at completion, shown to the
|
|
4777
|
+
* merchant in the dashboard, and included in the confirmation email.
|
|
4778
|
+
*
|
|
4774
4779
|
* @example
|
|
4775
4780
|
* ```typescript
|
|
4776
4781
|
* const checkout = await client.setCheckoutCustomer('checkout_123', {
|
|
4777
4782
|
* email: 'customer@example.com',
|
|
4778
4783
|
* firstName: 'John',
|
|
4779
4784
|
* lastName: 'Doe',
|
|
4785
|
+
* notes: 'Please leave the package at the door', // optional order notes
|
|
4780
4786
|
* });
|
|
4781
4787
|
* ```
|
|
4782
4788
|
*/
|
|
@@ -4848,6 +4854,10 @@ var BrainerceClient = class {
|
|
|
4848
4854
|
* **This is the first step of the simplified checkout flow.**
|
|
4849
4855
|
* Email is required and will be used for order confirmation.
|
|
4850
4856
|
*
|
|
4857
|
+
* Also accepts an optional order-level `notes` field — every checkout page
|
|
4858
|
+
* should include an optional "Order notes" textarea by default and send its
|
|
4859
|
+
* value here (or via `setCheckoutCustomer`). The note lands on the order.
|
|
4860
|
+
*
|
|
4851
4861
|
* @example
|
|
4852
4862
|
* ```typescript
|
|
4853
4863
|
* const { checkout, rates } = await client.setShippingAddress('checkout_123', {
|
|
@@ -4859,6 +4869,7 @@ var BrainerceClient = class {
|
|
|
4859
4869
|
* region: 'NY',
|
|
4860
4870
|
* postalCode: '10001',
|
|
4861
4871
|
* country: 'US',
|
|
4872
|
+
* notes: 'Please leave the package at the door', // optional order notes
|
|
4862
4873
|
* });
|
|
4863
4874
|
* console.log('Available rates:', rates);
|
|
4864
4875
|
* ```
|
|
@@ -5524,6 +5535,44 @@ var BrainerceClient = class {
|
|
|
5524
5535
|
waitedMs: Date.now() - startTime
|
|
5525
5536
|
};
|
|
5526
5537
|
}
|
|
5538
|
+
/**
|
|
5539
|
+
* Get the full order created by a completed checkout.
|
|
5540
|
+
*
|
|
5541
|
+
* Use this on the order-confirmation page (after `waitForOrder` succeeds)
|
|
5542
|
+
* when you want to render more than the order number — line items, shipping
|
|
5543
|
+
* address, financial breakdown, and the shopper's order note are all
|
|
5544
|
+
* included (the buyer-safe order shape, same as `getMyOrders`).
|
|
5545
|
+
*
|
|
5546
|
+
* Works for guests too: possession of the checkout id is the credential —
|
|
5547
|
+
* no customer token needed.
|
|
5548
|
+
*
|
|
5549
|
+
* @example
|
|
5550
|
+
* ```typescript
|
|
5551
|
+
* const result = await client.waitForOrder(checkoutId);
|
|
5552
|
+
* if (result.success) {
|
|
5553
|
+
* const order = await client.getOrderByCheckout(checkoutId);
|
|
5554
|
+
* // order.items, order.shippingAddress, order.notes, order.totalAmount, ...
|
|
5555
|
+
* }
|
|
5556
|
+
* ```
|
|
5557
|
+
*/
|
|
5558
|
+
async getOrderByCheckout(checkoutId) {
|
|
5559
|
+
if (this.isVibeCodedMode()) {
|
|
5560
|
+
return this.withGuards(
|
|
5561
|
+
this.vibeCodedRequest("GET", `/checkout/${encodePathSegment(checkoutId)}/order`),
|
|
5562
|
+
"order"
|
|
5563
|
+
);
|
|
5564
|
+
}
|
|
5565
|
+
if (this.storeId && !this.apiKey) {
|
|
5566
|
+
return this.withGuards(
|
|
5567
|
+
this.storefrontRequest("GET", `/checkout/${encodePathSegment(checkoutId)}/order`),
|
|
5568
|
+
"order"
|
|
5569
|
+
);
|
|
5570
|
+
}
|
|
5571
|
+
throw new BrainerceError(
|
|
5572
|
+
"getOrderByCheckout() requires vibe-coded or storefront mode",
|
|
5573
|
+
400
|
|
5574
|
+
);
|
|
5575
|
+
}
|
|
5527
5576
|
/**
|
|
5528
5577
|
* Check if localStorage is available (browser environment)
|
|
5529
5578
|
*/
|
|
@@ -6296,6 +6345,9 @@ var BrainerceClient = class {
|
|
|
6296
6345
|
/**
|
|
6297
6346
|
* Update the current customer's profile (requires customerToken)
|
|
6298
6347
|
* Only available in storefront mode
|
|
6348
|
+
*
|
|
6349
|
+
* `birthMonth`/`birthDay` (1-12 / 1-31, no year — privacy) power the loyalty
|
|
6350
|
+
* birthday gift; they must be provided together.
|
|
6299
6351
|
*/
|
|
6300
6352
|
async updateMyProfile(data) {
|
|
6301
6353
|
if (!this.customerToken && !this.proxyMode) {
|
|
@@ -6411,6 +6463,57 @@ var BrainerceClient = class {
|
|
|
6411
6463
|
}
|
|
6412
6464
|
throw new BrainerceError("redeemLoyaltyReward is only available in storefront mode", 400);
|
|
6413
6465
|
}
|
|
6466
|
+
/**
|
|
6467
|
+
* Report a social share, granting the SOCIAL_SHARE earning-rule bonus if the
|
|
6468
|
+
* store has one configured (requires customerToken). Self-reported — no
|
|
6469
|
+
* share-tracking infra — and capped at once per customer per program. Only
|
|
6470
|
+
* available in storefront mode.
|
|
6471
|
+
*
|
|
6472
|
+
* @example
|
|
6473
|
+
* ```typescript
|
|
6474
|
+
* await client.reportSocialShare('instagram');
|
|
6475
|
+
* ```
|
|
6476
|
+
*/
|
|
6477
|
+
async reportSocialShare(platform) {
|
|
6478
|
+
if (!this.customerToken && !this.proxyMode) {
|
|
6479
|
+
throw new BrainerceError(
|
|
6480
|
+
"Customer token required. Call setCustomerToken() after login.",
|
|
6481
|
+
401
|
|
6482
|
+
);
|
|
6483
|
+
}
|
|
6484
|
+
if (this.storeId && !this.apiKey) {
|
|
6485
|
+
return this.storefrontRequest(
|
|
6486
|
+
"POST",
|
|
6487
|
+
"/loyalty/social-share",
|
|
6488
|
+
platform ? { platform } : {}
|
|
6489
|
+
);
|
|
6490
|
+
}
|
|
6491
|
+
throw new BrainerceError("reportSocialShare is only available in storefront mode", 400);
|
|
6492
|
+
}
|
|
6493
|
+
/**
|
|
6494
|
+
* Public referral-link lookup: who referred the visitor and what welcome
|
|
6495
|
+
* reward awaits them. No customerToken needed (like getStoreInfo/trackEvent)
|
|
6496
|
+
* — safe to call on a referral landing page before signup. Returns
|
|
6497
|
+
* `{ valid: false }` for unknown codes or stores with referrals disabled.
|
|
6498
|
+
* Only available in storefront mode.
|
|
6499
|
+
*
|
|
6500
|
+
* @example
|
|
6501
|
+
* ```typescript
|
|
6502
|
+
* const info = await client.getReferralInfo(searchParams.get('ref')!);
|
|
6503
|
+
* if (info.valid) {
|
|
6504
|
+
* showBanner(`${info.referrerFirstName ?? 'A friend'} sent you a gift!`);
|
|
6505
|
+
* // later: client.registerCustomer({ ...form, referralCode })
|
|
6506
|
+
* }
|
|
6507
|
+
* ```
|
|
6508
|
+
*/
|
|
6509
|
+
async getReferralInfo(code) {
|
|
6510
|
+
if (this.storeId && !this.apiKey) {
|
|
6511
|
+
return this.storefrontRequest("GET", "/loyalty/referral-info", void 0, {
|
|
6512
|
+
code
|
|
6513
|
+
});
|
|
6514
|
+
}
|
|
6515
|
+
throw new BrainerceError("getReferralInfo is only available in storefront mode", 400);
|
|
6516
|
+
}
|
|
6414
6517
|
/**
|
|
6415
6518
|
* Get the current customer's orders (requires customerToken)
|
|
6416
6519
|
* Works in vibe-coded and storefront modes
|
|
@@ -7821,52 +7924,92 @@ var BrainerceClient = class {
|
|
|
7821
7924
|
{ vibeCodedConnectionId }
|
|
7822
7925
|
);
|
|
7823
7926
|
}
|
|
7927
|
+
/**
|
|
7928
|
+
* Publish a product to a sales channel (admin mode) — makes it visible on
|
|
7929
|
+
* that vibe-coded storefront. Accepts the sales-channel record ID or its
|
|
7930
|
+
* public `vc_*` connection ID.
|
|
7931
|
+
*/
|
|
7932
|
+
async publishProductToSalesChannel(productId, salesChannelId) {
|
|
7933
|
+
return this.adminRequest(
|
|
7934
|
+
"POST",
|
|
7935
|
+
`/api/v1/products/${encodePathSegment(productId)}/publish-sales-channel`,
|
|
7936
|
+
{ salesChannelId }
|
|
7937
|
+
);
|
|
7938
|
+
}
|
|
7939
|
+
/** Unpublish a product from a sales channel (admin mode). */
|
|
7940
|
+
async unpublishProductFromSalesChannel(productId, salesChannelId) {
|
|
7941
|
+
return this.adminRequest(
|
|
7942
|
+
"POST",
|
|
7943
|
+
`/api/v1/products/${encodePathSegment(productId)}/unpublish-sales-channel`,
|
|
7944
|
+
{ salesChannelId }
|
|
7945
|
+
);
|
|
7946
|
+
}
|
|
7947
|
+
/**
|
|
7948
|
+
* Publish a coupon to a sales channel (admin mode) — makes it redeemable on
|
|
7949
|
+
* that vibe-coded storefront. Accepts the sales-channel record ID or its
|
|
7950
|
+
* public `vc_*` connection ID.
|
|
7951
|
+
*/
|
|
7952
|
+
async publishCouponToSalesChannel(couponId, salesChannelId) {
|
|
7953
|
+
return this.adminRequest(
|
|
7954
|
+
"POST",
|
|
7955
|
+
`/api/v1/coupons/${encodePathSegment(couponId)}/publish-sales-channel`,
|
|
7956
|
+
{ salesChannelId }
|
|
7957
|
+
);
|
|
7958
|
+
}
|
|
7959
|
+
/** Unpublish a coupon from a sales channel (admin mode). */
|
|
7960
|
+
async unpublishCouponFromSalesChannel(couponId, salesChannelId) {
|
|
7961
|
+
return this.adminRequest(
|
|
7962
|
+
"POST",
|
|
7963
|
+
`/api/v1/coupons/${encodePathSegment(couponId)}/unpublish-sales-channel`,
|
|
7964
|
+
{ salesChannelId }
|
|
7965
|
+
);
|
|
7966
|
+
}
|
|
7824
7967
|
/** Publish a category to a vibe-coded site (admin mode). */
|
|
7825
7968
|
async publishCategoryToVibeCodedSite(categoryId, vibeCodedConnectionId) {
|
|
7826
7969
|
return this.adminRequest(
|
|
7827
7970
|
"POST",
|
|
7828
|
-
`/api/v1/categories/${encodePathSegment(categoryId)}/publish-
|
|
7829
|
-
{ vibeCodedConnectionId }
|
|
7971
|
+
`/api/v1/categories/${encodePathSegment(categoryId)}/publish-sales-channel`,
|
|
7972
|
+
{ salesChannelId: vibeCodedConnectionId }
|
|
7830
7973
|
);
|
|
7831
7974
|
}
|
|
7832
7975
|
/** Unpublish a category from a vibe-coded site (admin mode). */
|
|
7833
7976
|
async unpublishCategoryFromVibeCodedSite(categoryId, vibeCodedConnectionId) {
|
|
7834
7977
|
return this.adminRequest(
|
|
7835
7978
|
"POST",
|
|
7836
|
-
`/api/v1/categories/${encodePathSegment(categoryId)}/unpublish-
|
|
7837
|
-
{ vibeCodedConnectionId }
|
|
7979
|
+
`/api/v1/categories/${encodePathSegment(categoryId)}/unpublish-sales-channel`,
|
|
7980
|
+
{ salesChannelId: vibeCodedConnectionId }
|
|
7838
7981
|
);
|
|
7839
7982
|
}
|
|
7840
7983
|
/** Publish a tag to a vibe-coded site (admin mode). */
|
|
7841
7984
|
async publishTagToVibeCodedSite(tagId, vibeCodedConnectionId) {
|
|
7842
7985
|
return this.adminRequest(
|
|
7843
7986
|
"POST",
|
|
7844
|
-
`/api/v1/tags/${encodePathSegment(tagId)}/publish-
|
|
7845
|
-
{ vibeCodedConnectionId }
|
|
7987
|
+
`/api/v1/tags/${encodePathSegment(tagId)}/publish-sales-channel`,
|
|
7988
|
+
{ salesChannelId: vibeCodedConnectionId }
|
|
7846
7989
|
);
|
|
7847
7990
|
}
|
|
7848
7991
|
/** Unpublish a tag from a vibe-coded site (admin mode). */
|
|
7849
7992
|
async unpublishTagFromVibeCodedSite(tagId, vibeCodedConnectionId) {
|
|
7850
7993
|
return this.adminRequest(
|
|
7851
7994
|
"POST",
|
|
7852
|
-
`/api/v1/tags/${encodePathSegment(tagId)}/unpublish-
|
|
7853
|
-
{ vibeCodedConnectionId }
|
|
7995
|
+
`/api/v1/tags/${encodePathSegment(tagId)}/unpublish-sales-channel`,
|
|
7996
|
+
{ salesChannelId: vibeCodedConnectionId }
|
|
7854
7997
|
);
|
|
7855
7998
|
}
|
|
7856
7999
|
/** Publish a brand to a vibe-coded site (admin mode). */
|
|
7857
8000
|
async publishBrandToVibeCodedSite(brandId, vibeCodedConnectionId) {
|
|
7858
8001
|
return this.adminRequest(
|
|
7859
8002
|
"POST",
|
|
7860
|
-
`/api/v1/brands/${encodePathSegment(brandId)}/publish-
|
|
7861
|
-
{ vibeCodedConnectionId }
|
|
8003
|
+
`/api/v1/brands/${encodePathSegment(brandId)}/publish-sales-channel`,
|
|
8004
|
+
{ salesChannelId: vibeCodedConnectionId }
|
|
7862
8005
|
);
|
|
7863
8006
|
}
|
|
7864
8007
|
/** Unpublish a brand from a vibe-coded site (admin mode). */
|
|
7865
8008
|
async unpublishBrandFromVibeCodedSite(brandId, vibeCodedConnectionId) {
|
|
7866
8009
|
return this.adminRequest(
|
|
7867
8010
|
"POST",
|
|
7868
|
-
`/api/v1/brands/${encodePathSegment(brandId)}/unpublish-
|
|
7869
|
-
{ vibeCodedConnectionId }
|
|
8011
|
+
`/api/v1/brands/${encodePathSegment(brandId)}/unpublish-sales-channel`,
|
|
8012
|
+
{ salesChannelId: vibeCodedConnectionId }
|
|
7870
8013
|
);
|
|
7871
8014
|
}
|
|
7872
8015
|
/**
|
package/dist/index.mjs
CHANGED
|
@@ -4701,12 +4701,18 @@ var BrainerceClient = class {
|
|
|
4701
4701
|
/**
|
|
4702
4702
|
* Set customer information on checkout
|
|
4703
4703
|
*
|
|
4704
|
+
* Also accepts an optional order-level `notes` field — every checkout page
|
|
4705
|
+
* should include an optional "Order notes" textarea by default and send its
|
|
4706
|
+
* value here. The note is copied onto the order at completion, shown to the
|
|
4707
|
+
* merchant in the dashboard, and included in the confirmation email.
|
|
4708
|
+
*
|
|
4704
4709
|
* @example
|
|
4705
4710
|
* ```typescript
|
|
4706
4711
|
* const checkout = await client.setCheckoutCustomer('checkout_123', {
|
|
4707
4712
|
* email: 'customer@example.com',
|
|
4708
4713
|
* firstName: 'John',
|
|
4709
4714
|
* lastName: 'Doe',
|
|
4715
|
+
* notes: 'Please leave the package at the door', // optional order notes
|
|
4710
4716
|
* });
|
|
4711
4717
|
* ```
|
|
4712
4718
|
*/
|
|
@@ -4778,6 +4784,10 @@ var BrainerceClient = class {
|
|
|
4778
4784
|
* **This is the first step of the simplified checkout flow.**
|
|
4779
4785
|
* Email is required and will be used for order confirmation.
|
|
4780
4786
|
*
|
|
4787
|
+
* Also accepts an optional order-level `notes` field — every checkout page
|
|
4788
|
+
* should include an optional "Order notes" textarea by default and send its
|
|
4789
|
+
* value here (or via `setCheckoutCustomer`). The note lands on the order.
|
|
4790
|
+
*
|
|
4781
4791
|
* @example
|
|
4782
4792
|
* ```typescript
|
|
4783
4793
|
* const { checkout, rates } = await client.setShippingAddress('checkout_123', {
|
|
@@ -4789,6 +4799,7 @@ var BrainerceClient = class {
|
|
|
4789
4799
|
* region: 'NY',
|
|
4790
4800
|
* postalCode: '10001',
|
|
4791
4801
|
* country: 'US',
|
|
4802
|
+
* notes: 'Please leave the package at the door', // optional order notes
|
|
4792
4803
|
* });
|
|
4793
4804
|
* console.log('Available rates:', rates);
|
|
4794
4805
|
* ```
|
|
@@ -5454,6 +5465,44 @@ var BrainerceClient = class {
|
|
|
5454
5465
|
waitedMs: Date.now() - startTime
|
|
5455
5466
|
};
|
|
5456
5467
|
}
|
|
5468
|
+
/**
|
|
5469
|
+
* Get the full order created by a completed checkout.
|
|
5470
|
+
*
|
|
5471
|
+
* Use this on the order-confirmation page (after `waitForOrder` succeeds)
|
|
5472
|
+
* when you want to render more than the order number — line items, shipping
|
|
5473
|
+
* address, financial breakdown, and the shopper's order note are all
|
|
5474
|
+
* included (the buyer-safe order shape, same as `getMyOrders`).
|
|
5475
|
+
*
|
|
5476
|
+
* Works for guests too: possession of the checkout id is the credential —
|
|
5477
|
+
* no customer token needed.
|
|
5478
|
+
*
|
|
5479
|
+
* @example
|
|
5480
|
+
* ```typescript
|
|
5481
|
+
* const result = await client.waitForOrder(checkoutId);
|
|
5482
|
+
* if (result.success) {
|
|
5483
|
+
* const order = await client.getOrderByCheckout(checkoutId);
|
|
5484
|
+
* // order.items, order.shippingAddress, order.notes, order.totalAmount, ...
|
|
5485
|
+
* }
|
|
5486
|
+
* ```
|
|
5487
|
+
*/
|
|
5488
|
+
async getOrderByCheckout(checkoutId) {
|
|
5489
|
+
if (this.isVibeCodedMode()) {
|
|
5490
|
+
return this.withGuards(
|
|
5491
|
+
this.vibeCodedRequest("GET", `/checkout/${encodePathSegment(checkoutId)}/order`),
|
|
5492
|
+
"order"
|
|
5493
|
+
);
|
|
5494
|
+
}
|
|
5495
|
+
if (this.storeId && !this.apiKey) {
|
|
5496
|
+
return this.withGuards(
|
|
5497
|
+
this.storefrontRequest("GET", `/checkout/${encodePathSegment(checkoutId)}/order`),
|
|
5498
|
+
"order"
|
|
5499
|
+
);
|
|
5500
|
+
}
|
|
5501
|
+
throw new BrainerceError(
|
|
5502
|
+
"getOrderByCheckout() requires vibe-coded or storefront mode",
|
|
5503
|
+
400
|
|
5504
|
+
);
|
|
5505
|
+
}
|
|
5457
5506
|
/**
|
|
5458
5507
|
* Check if localStorage is available (browser environment)
|
|
5459
5508
|
*/
|
|
@@ -6226,6 +6275,9 @@ var BrainerceClient = class {
|
|
|
6226
6275
|
/**
|
|
6227
6276
|
* Update the current customer's profile (requires customerToken)
|
|
6228
6277
|
* Only available in storefront mode
|
|
6278
|
+
*
|
|
6279
|
+
* `birthMonth`/`birthDay` (1-12 / 1-31, no year — privacy) power the loyalty
|
|
6280
|
+
* birthday gift; they must be provided together.
|
|
6229
6281
|
*/
|
|
6230
6282
|
async updateMyProfile(data) {
|
|
6231
6283
|
if (!this.customerToken && !this.proxyMode) {
|
|
@@ -6341,6 +6393,57 @@ var BrainerceClient = class {
|
|
|
6341
6393
|
}
|
|
6342
6394
|
throw new BrainerceError("redeemLoyaltyReward is only available in storefront mode", 400);
|
|
6343
6395
|
}
|
|
6396
|
+
/**
|
|
6397
|
+
* Report a social share, granting the SOCIAL_SHARE earning-rule bonus if the
|
|
6398
|
+
* store has one configured (requires customerToken). Self-reported — no
|
|
6399
|
+
* share-tracking infra — and capped at once per customer per program. Only
|
|
6400
|
+
* available in storefront mode.
|
|
6401
|
+
*
|
|
6402
|
+
* @example
|
|
6403
|
+
* ```typescript
|
|
6404
|
+
* await client.reportSocialShare('instagram');
|
|
6405
|
+
* ```
|
|
6406
|
+
*/
|
|
6407
|
+
async reportSocialShare(platform) {
|
|
6408
|
+
if (!this.customerToken && !this.proxyMode) {
|
|
6409
|
+
throw new BrainerceError(
|
|
6410
|
+
"Customer token required. Call setCustomerToken() after login.",
|
|
6411
|
+
401
|
|
6412
|
+
);
|
|
6413
|
+
}
|
|
6414
|
+
if (this.storeId && !this.apiKey) {
|
|
6415
|
+
return this.storefrontRequest(
|
|
6416
|
+
"POST",
|
|
6417
|
+
"/loyalty/social-share",
|
|
6418
|
+
platform ? { platform } : {}
|
|
6419
|
+
);
|
|
6420
|
+
}
|
|
6421
|
+
throw new BrainerceError("reportSocialShare is only available in storefront mode", 400);
|
|
6422
|
+
}
|
|
6423
|
+
/**
|
|
6424
|
+
* Public referral-link lookup: who referred the visitor and what welcome
|
|
6425
|
+
* reward awaits them. No customerToken needed (like getStoreInfo/trackEvent)
|
|
6426
|
+
* — safe to call on a referral landing page before signup. Returns
|
|
6427
|
+
* `{ valid: false }` for unknown codes or stores with referrals disabled.
|
|
6428
|
+
* Only available in storefront mode.
|
|
6429
|
+
*
|
|
6430
|
+
* @example
|
|
6431
|
+
* ```typescript
|
|
6432
|
+
* const info = await client.getReferralInfo(searchParams.get('ref')!);
|
|
6433
|
+
* if (info.valid) {
|
|
6434
|
+
* showBanner(`${info.referrerFirstName ?? 'A friend'} sent you a gift!`);
|
|
6435
|
+
* // later: client.registerCustomer({ ...form, referralCode })
|
|
6436
|
+
* }
|
|
6437
|
+
* ```
|
|
6438
|
+
*/
|
|
6439
|
+
async getReferralInfo(code) {
|
|
6440
|
+
if (this.storeId && !this.apiKey) {
|
|
6441
|
+
return this.storefrontRequest("GET", "/loyalty/referral-info", void 0, {
|
|
6442
|
+
code
|
|
6443
|
+
});
|
|
6444
|
+
}
|
|
6445
|
+
throw new BrainerceError("getReferralInfo is only available in storefront mode", 400);
|
|
6446
|
+
}
|
|
6344
6447
|
/**
|
|
6345
6448
|
* Get the current customer's orders (requires customerToken)
|
|
6346
6449
|
* Works in vibe-coded and storefront modes
|
|
@@ -7751,52 +7854,92 @@ var BrainerceClient = class {
|
|
|
7751
7854
|
{ vibeCodedConnectionId }
|
|
7752
7855
|
);
|
|
7753
7856
|
}
|
|
7857
|
+
/**
|
|
7858
|
+
* Publish a product to a sales channel (admin mode) — makes it visible on
|
|
7859
|
+
* that vibe-coded storefront. Accepts the sales-channel record ID or its
|
|
7860
|
+
* public `vc_*` connection ID.
|
|
7861
|
+
*/
|
|
7862
|
+
async publishProductToSalesChannel(productId, salesChannelId) {
|
|
7863
|
+
return this.adminRequest(
|
|
7864
|
+
"POST",
|
|
7865
|
+
`/api/v1/products/${encodePathSegment(productId)}/publish-sales-channel`,
|
|
7866
|
+
{ salesChannelId }
|
|
7867
|
+
);
|
|
7868
|
+
}
|
|
7869
|
+
/** Unpublish a product from a sales channel (admin mode). */
|
|
7870
|
+
async unpublishProductFromSalesChannel(productId, salesChannelId) {
|
|
7871
|
+
return this.adminRequest(
|
|
7872
|
+
"POST",
|
|
7873
|
+
`/api/v1/products/${encodePathSegment(productId)}/unpublish-sales-channel`,
|
|
7874
|
+
{ salesChannelId }
|
|
7875
|
+
);
|
|
7876
|
+
}
|
|
7877
|
+
/**
|
|
7878
|
+
* Publish a coupon to a sales channel (admin mode) — makes it redeemable on
|
|
7879
|
+
* that vibe-coded storefront. Accepts the sales-channel record ID or its
|
|
7880
|
+
* public `vc_*` connection ID.
|
|
7881
|
+
*/
|
|
7882
|
+
async publishCouponToSalesChannel(couponId, salesChannelId) {
|
|
7883
|
+
return this.adminRequest(
|
|
7884
|
+
"POST",
|
|
7885
|
+
`/api/v1/coupons/${encodePathSegment(couponId)}/publish-sales-channel`,
|
|
7886
|
+
{ salesChannelId }
|
|
7887
|
+
);
|
|
7888
|
+
}
|
|
7889
|
+
/** Unpublish a coupon from a sales channel (admin mode). */
|
|
7890
|
+
async unpublishCouponFromSalesChannel(couponId, salesChannelId) {
|
|
7891
|
+
return this.adminRequest(
|
|
7892
|
+
"POST",
|
|
7893
|
+
`/api/v1/coupons/${encodePathSegment(couponId)}/unpublish-sales-channel`,
|
|
7894
|
+
{ salesChannelId }
|
|
7895
|
+
);
|
|
7896
|
+
}
|
|
7754
7897
|
/** Publish a category to a vibe-coded site (admin mode). */
|
|
7755
7898
|
async publishCategoryToVibeCodedSite(categoryId, vibeCodedConnectionId) {
|
|
7756
7899
|
return this.adminRequest(
|
|
7757
7900
|
"POST",
|
|
7758
|
-
`/api/v1/categories/${encodePathSegment(categoryId)}/publish-
|
|
7759
|
-
{ vibeCodedConnectionId }
|
|
7901
|
+
`/api/v1/categories/${encodePathSegment(categoryId)}/publish-sales-channel`,
|
|
7902
|
+
{ salesChannelId: vibeCodedConnectionId }
|
|
7760
7903
|
);
|
|
7761
7904
|
}
|
|
7762
7905
|
/** Unpublish a category from a vibe-coded site (admin mode). */
|
|
7763
7906
|
async unpublishCategoryFromVibeCodedSite(categoryId, vibeCodedConnectionId) {
|
|
7764
7907
|
return this.adminRequest(
|
|
7765
7908
|
"POST",
|
|
7766
|
-
`/api/v1/categories/${encodePathSegment(categoryId)}/unpublish-
|
|
7767
|
-
{ vibeCodedConnectionId }
|
|
7909
|
+
`/api/v1/categories/${encodePathSegment(categoryId)}/unpublish-sales-channel`,
|
|
7910
|
+
{ salesChannelId: vibeCodedConnectionId }
|
|
7768
7911
|
);
|
|
7769
7912
|
}
|
|
7770
7913
|
/** Publish a tag to a vibe-coded site (admin mode). */
|
|
7771
7914
|
async publishTagToVibeCodedSite(tagId, vibeCodedConnectionId) {
|
|
7772
7915
|
return this.adminRequest(
|
|
7773
7916
|
"POST",
|
|
7774
|
-
`/api/v1/tags/${encodePathSegment(tagId)}/publish-
|
|
7775
|
-
{ vibeCodedConnectionId }
|
|
7917
|
+
`/api/v1/tags/${encodePathSegment(tagId)}/publish-sales-channel`,
|
|
7918
|
+
{ salesChannelId: vibeCodedConnectionId }
|
|
7776
7919
|
);
|
|
7777
7920
|
}
|
|
7778
7921
|
/** Unpublish a tag from a vibe-coded site (admin mode). */
|
|
7779
7922
|
async unpublishTagFromVibeCodedSite(tagId, vibeCodedConnectionId) {
|
|
7780
7923
|
return this.adminRequest(
|
|
7781
7924
|
"POST",
|
|
7782
|
-
`/api/v1/tags/${encodePathSegment(tagId)}/unpublish-
|
|
7783
|
-
{ vibeCodedConnectionId }
|
|
7925
|
+
`/api/v1/tags/${encodePathSegment(tagId)}/unpublish-sales-channel`,
|
|
7926
|
+
{ salesChannelId: vibeCodedConnectionId }
|
|
7784
7927
|
);
|
|
7785
7928
|
}
|
|
7786
7929
|
/** Publish a brand to a vibe-coded site (admin mode). */
|
|
7787
7930
|
async publishBrandToVibeCodedSite(brandId, vibeCodedConnectionId) {
|
|
7788
7931
|
return this.adminRequest(
|
|
7789
7932
|
"POST",
|
|
7790
|
-
`/api/v1/brands/${encodePathSegment(brandId)}/publish-
|
|
7791
|
-
{ vibeCodedConnectionId }
|
|
7933
|
+
`/api/v1/brands/${encodePathSegment(brandId)}/publish-sales-channel`,
|
|
7934
|
+
{ salesChannelId: vibeCodedConnectionId }
|
|
7792
7935
|
);
|
|
7793
7936
|
}
|
|
7794
7937
|
/** Unpublish a brand from a vibe-coded site (admin mode). */
|
|
7795
7938
|
async unpublishBrandFromVibeCodedSite(brandId, vibeCodedConnectionId) {
|
|
7796
7939
|
return this.adminRequest(
|
|
7797
7940
|
"POST",
|
|
7798
|
-
`/api/v1/brands/${encodePathSegment(brandId)}/unpublish-
|
|
7799
|
-
{ vibeCodedConnectionId }
|
|
7941
|
+
`/api/v1/brands/${encodePathSegment(brandId)}/unpublish-sales-channel`,
|
|
7942
|
+
{ salesChannelId: vibeCodedConnectionId }
|
|
7800
7943
|
);
|
|
7801
7944
|
}
|
|
7802
7945
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "brainerce",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.44.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",
|