brainerce 1.47.1 → 1.47.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -32,29 +32,30 @@ yarn add brainerce
32
32
 
33
33
  Every Brainerce storefront must include **all mandatory features** below. Features auto-hide when the underlying capability is disabled, so build them all anyway — they'll appear the moment the store owner enables them.
34
34
 
35
- | Feature | SDK entry point | Mandatory |
36
- | ------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------- | ----------- |
37
- | Product list with search, filter, pagination | `client.getProducts()`, `client.getSearchSuggestions(query)` | ✅ |
38
- | Product detail with variant picker, stock, price | `client.getProductBySlug()` + helpers | ✅ |
39
- | Buyer customization fields (engraving, uploads, select) | `product.customizationFields`, `client.uploadCustomizationFile()` | ✅ |
40
- | Cart (add, update, remove, coupon, totals) | `client.addToCart()`, `getCartTotals(cart)` | ✅ |
41
- | Inventory reservation countdown | Cart expiry timestamp from `client.getCart()` | ✅ |
42
- | Full checkout end-to-end with payment | `setShippingAddress → selectShippingMethod → getPaymentProviders → pay → handlePaymentSuccess → waitForOrder` | ✅ |
43
- | Order confirmation (clear cart + wait for real order) | `client.handlePaymentSuccess()`, `client.waitForOrder()` | ✅ |
44
- | Register + email verification flow | `client.registerCustomer()`, `client.verifyEmail()` | ✅ |
45
- | Login + verification branch | `client.loginCustomer()` | ✅ |
46
- | Forgot / reset password | `client.forgotPassword()`, `client.resetPassword()` | ✅ |
47
- | OAuth sign-in buttons + callback handler | `client.getAvailableOAuthProviders()` | ✅ |
48
- | Account area (profile + order history) | `client.getMyProfile()`, `client.getMyOrders()` | ✅ |
49
- | Loyalty & rewards (points balance + tiers + redeem) | `client.getLoyaltyStatus()`, `client.getAvailableRewards()`, `client.getRecommendedReward()`, `client.redeemLoyaltyReward(id)`, `client.reportSocialShare()` | conditional |
50
- | Loyalty paid membership (premium subscription) | `client.getMembershipPlans()`, `client.getMySavedPaymentMethods()`, `client.subscribeToMembership(params)`, `client.cancelMembership()` | conditional |
51
- | Global header: cart count + search autocomplete | `client.getCart()`, `client.getSearchSuggestions(query)` | |
52
- | Discount banners + product badges | `client.getDiscountBanners()`, `client.getProductDiscountBadge(productId)` | ✅ |
53
- | Product reviews on PDP + JSON-LD aggregateRating | `client.listProductReviews(id)`, `client.submitProductReview(id, …)` | ✅ |
54
- | Site chrome (header + footer + announcement bar) | `client.content.header.get()`, `client.content.footer.get()`, `client.content.announcement.list()` | ✅ |
55
- | FAQ page | `client.content.faq.get('main', locale)` | conditional |
56
- | Static pages catch-all (`/pages/[slug]`) | `client.content.page.getBySlug(slug, locale)` | conditional |
57
- | Multi-language + RTL (when i18n enabled) | `client.setLocale()`, `client.getStoreDirection(locale)` | conditional |
35
+ | Feature | SDK entry point | Mandatory |
36
+ | -------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------- |
37
+ | Product list with search, filter, pagination | `client.getProducts()`, `client.getSearchSuggestions(query)` | ✅ |
38
+ | Product detail with variant picker, stock, price | `client.getProductBySlug()` + helpers | ✅ |
39
+ | Buyer customization fields (engraving, uploads, select) | `product.customizationFields`, `client.uploadCustomizationFile()` | ✅ |
40
+ | Cart (add, update, remove, coupon, totals) | `client.addToCart()`, `getCartTotals(cart)` | ✅ |
41
+ | Inventory reservation countdown | Cart expiry timestamp from `client.getCart()` | ✅ |
42
+ | Full checkout end-to-end with payment | `setShippingAddress → selectShippingMethod → getPaymentProviders → pay → handlePaymentSuccess → waitForOrder` | ✅ |
43
+ | Order confirmation (clear cart + wait for real order) | `client.handlePaymentSuccess()`, `client.waitForOrder()` | ✅ |
44
+ | Register + email verification flow | `client.registerCustomer()`, `client.verifyEmail()` | ✅ |
45
+ | Login + verification branch | `client.loginCustomer()` | ✅ |
46
+ | Forgot / reset password | `client.forgotPassword()`, `client.resetPassword()` | ✅ |
47
+ | OAuth sign-in buttons + callback handler | `client.getAvailableOAuthProviders()` | ✅ |
48
+ | Account area (profile + order history) | `client.getMyProfile()`, `client.getMyOrders()` | ✅ |
49
+ | Loyalty & rewards (points balance + tiers + redeem) | `client.getLoyaltyStatus()`, `client.getAvailableRewards()`, `client.getRecommendedReward()`, `client.redeemLoyaltyReward(id)`, `client.reportSocialShare()` | conditional |
50
+ | Loyalty paid membership (premium subscription) | `client.getMembershipPlans()`, `client.getMySavedPaymentMethods()`, `client.subscribeToMembership(params)`, `client.cancelMembership()` | conditional |
51
+ | Embeddable loyalty widget (points + rewards on ANY site) | `client.getLoyaltyWidgetSession()` | conditional |
52
+ | Global header: cart count + search autocomplete | `client.getCart()`, `client.getSearchSuggestions(query)` | ✅ |
53
+ | Discount banners + product badges | `client.getDiscountBanners()`, `client.getProductDiscountBadge(productId)` | ✅ |
54
+ | Product reviews on PDP + JSON-LD aggregateRating | `client.listProductReviews(id)`, `client.submitProductReview(id, )` | ✅ |
55
+ | Site chrome (header + footer + announcement bar) | `client.content.header.get()`, `client.content.footer.get()`, `client.content.announcement.list()` | |
56
+ | FAQ page | `client.content.faq.get('main', locale)` | conditional |
57
+ | Static pages catch-all (`/pages/[slug]`) | `client.content.page.getBySlug(slug, locale)` | conditional |
58
+ | Multi-language + RTL (when i18n enabled) | `client.setLocale()`, `client.getStoreDirection(locale)` | conditional |
58
59
 
59
60
  ---
60
61
 
@@ -271,7 +272,7 @@ The SDK exports these utility functions for common UI tasks:
271
272
  | `buildArticleJsonLd(post, opts)` | schema.org Article JSON-LD for blog posts | See SEO section |
272
273
  | `buildOrganizationJsonLd(store, opts)` | schema.org Organization for the homepage | See SEO section |
273
274
  | `buildBreadcrumbJsonLd(items)` | schema.org BreadcrumbList | See SEO section |
274
- | `jsonLdScriptProps(data)` | XSS-safe `<script type="application/ld+json">` props | `<script {...jsonLdScriptProps(data)} />` |
275
+ | `jsonLdScriptProps(data)` | XSS-safe `<script type="application/ld+json">` props | `<script {...jsonLdScriptProps(data)} />` |
275
276
  | `getBlogSitemapEntries(client, opts)` | Paginate published posts into sitemap entries | See SEO section |
276
277
 
277
278
  ```typescript
@@ -464,15 +465,16 @@ return <div dangerouslySetInnerHTML={{ __html: safeHtml }} className="prose" />;
464
465
 
465
466
  ### SEO — JSON-LD builders, sitemap helper, IndexNow key, llms.txt
466
467
 
467
- The SDK ships schema.org builders that encode Google's structured-data rules (aggregateRating gated on `reviewCount > 0`, AggregateOffer for VARIABLE products, XSS-safe serialization). Prefer them over hand-rolled JSON-LD:
468
+ The SDK ships schema.org builders that encode Google's structured-data rules (aggregateRating gated on `reviewCount > 0`, AggregateOffer for VARIABLE products, XSS-safe serialization). `buildProductJsonLd`'s Offer also always includes `itemCondition` (hardcoded `NewCondition` — first-party new-goods catalog), `priceValidUntil` when the product has an active sale-price window (`salePriceEndsAt`), and `shippingDetails` when you pass `shipping` (real flat-rate/free zones from `storeInfo.shipping` — omitted entirely, never fabricated, if you don't pass it). Prefer these builders over hand-rolled JSON-LD:
468
469
 
469
470
  ```tsx
470
471
  import {
471
- buildProductJsonLd, // single-product pages ONLY (never listing pages)
472
- buildArticleJsonLd, // blog post pages
473
- buildOrganizationJsonLd, // homepage
472
+ buildProductJsonLd, // single-product pages ONLY (never listing pages)
473
+ buildArticleJsonLd, // blog post pages
474
+ buildOrganizationJsonLd, // homepage
475
+ buildCollectionPageJsonLd, // category landing pages
474
476
  buildBreadcrumbJsonLd,
475
- jsonLdScriptProps, // XSS-safe <script> props
477
+ jsonLdScriptProps, // XSS-safe <script> props
476
478
  } from 'brainerce';
477
479
 
478
480
  // Blog article page
@@ -487,6 +489,7 @@ import {
487
489
  siteUrl: process.env.NEXT_PUBLIC_SITE_URL!,
488
490
  path: `/products/${product.slug}`,
489
491
  currency: storeInfo.currency,
492
+ shipping: storeInfo.shipping, // optional — adds shippingDetails when present
490
493
  }))} />
491
494
  ```
492
495
 
@@ -862,6 +865,26 @@ import { getCartTotals } from 'brainerce';
862
865
  const totals = getCartTotals(cart); // { subtotal, discount, shipping, total }
863
866
  ```
864
867
 
868
+ ### Detecting a Silent Session Cart Reset
869
+
870
+ If a guest's stored session cart can no longer be resolved as-is — the fetch
871
+ fails, or the cart was found but is no longer `ACTIVE` (e.g. a prior checkout
872
+ on it already completed) — `smartAddToCart()` / `smartGetCart()` /
873
+ `smartUpdateCartItem()` transparently start a fresh empty cart so the call
874
+ still succeeds. Pass `onCartReset` to the constructor to find out when this
875
+ happens, so you can tell the shopper their cart expired instead of them just
876
+ seeing it empty out:
877
+
878
+ ```typescript
879
+ const client = new BrainerceClient({
880
+ salesChannelId: 'vc_abc123...',
881
+ onCartReset: ({ previousCartId, reason }) => {
882
+ // reason: 'not_found' (fetch failed) | 'not_active' (cart no longer ACTIVE)
883
+ toast.warn('Your cart session expired — please re-add your items.');
884
+ },
885
+ });
886
+ ```
887
+
865
888
  ### On Login — Merge Guest Cart
866
889
 
867
890
  ```typescript
@@ -1536,17 +1559,19 @@ interface Product {
1536
1559
  description?: string | null;
1537
1560
  descriptionFormat?: 'text' | 'html' | 'markdown'; // Format of description content
1538
1561
  sku: string;
1539
- basePrice: number;
1540
- salePrice?: number | null;
1562
+ basePrice: string; // Decimal as string — use parseFloat() for calculations
1563
+ salePrice?: string | null;
1564
+ salePriceStartsAt?: string | null; // ISO 8601 — sale-price effective window start
1565
+ salePriceEndsAt?: string | null; // ISO 8601 — sale-price window end; feeds buildProductJsonLd's priceValidUntil
1541
1566
  priceMin?: string | null; // Lowest variant price (VARIABLE products only)
1542
1567
  priceMax?: string | null; // Highest variant price (VARIABLE products only)
1543
1568
  priceVaries?: boolean; // true when range should be shown ("₪49 – ₪199")
1544
- status: 'active' | 'draft';
1569
+ status: string; // e.g. "active" | "draft"
1545
1570
  type: 'SIMPLE' | 'VARIABLE';
1546
1571
  images?: ProductImage[];
1547
1572
  inventory?: InventoryInfo | null;
1548
1573
  variants?: ProductVariant[];
1549
- categories?: string[];
1574
+ categories?: Array<{ id: string; name: string; slug?: string | null }>; // NOT string[] — use slug to link to /category/{slug}
1550
1575
  tags?: string[];
1551
1576
  createdAt: string;
1552
1577
  updatedAt: string;
@@ -3070,9 +3095,9 @@ const { data: orders, meta } = await client.getMyOrders({
3070
3095
 
3071
3096
  #### Loyalty & Rewards
3072
3097
 
3073
- Storefront-mode only (requires `storeId` + `customerToken`). Let logged-in
3074
- customers check their points balance, enroll, and redeem rewards for one-time
3075
- coupons that apply at checkout.
3098
+ Storefront or vibe-coded mode (requires `storeId` or `salesChannelId` +
3099
+ `customerToken`). Let logged-in customers check their points balance, enroll,
3100
+ and redeem rewards for one-time coupons that apply at checkout.
3076
3101
 
3077
3102
  ```typescript
3078
3103
  // Current status — points balance + program display config + tier progress +
@@ -3149,8 +3174,9 @@ platform emails a one-time gift coupon ahead of their birthday automatically
3149
3174
 
3150
3175
  Stores can offer a paid "premium membership" inside the loyalty program — a
3151
3176
  recurring charge (default every 30 days) that grants a points multiplier and
3152
- other perks. Storefront-mode only, requires `customerToken`. The customer must
3153
- first have a saved card (vault one by checking out with `saveCard: true`).
3177
+ other perks. Storefront or vibe-coded mode, requires `customerToken`. The
3178
+ customer must first have a saved card (vault one by checking out with
3179
+ `saveCard: true`).
3154
3180
 
3155
3181
  ```typescript
3156
3182
  // 1. Plans the store offers (empty if none / program not active).
@@ -3182,6 +3208,26 @@ const cancelled = await client.cancelMembership();
3182
3208
  // pauses the multiplier until the charge clears.
3183
3209
  ```
3184
3210
 
3211
+ #### Embeddable Loyalty Widget
3212
+
3213
+ Drop the loyalty program into ANY website — not just your SDK-connected
3214
+ storefront. Mint a short-lived widget session (never exposes the real
3215
+ `customerToken` to the embedding page) and point an `<iframe>` at it. The
3216
+ merchant enables this per-domain in the dashboard (Loyalty → Settings →
3217
+ Embeddable widget) before it will render anywhere.
3218
+
3219
+ ```typescript
3220
+ client.setCustomerToken(auth.token);
3221
+
3222
+ const { embedUrl } = await client.getLoyaltyWidgetSession();
3223
+
3224
+ // <iframe src={embedUrl} width="360" height="420" style={{ border: 0 }} />
3225
+ ```
3226
+
3227
+ `embedUrl` expires in ~15 minutes — re-call `getLoyaltyWidgetSession()` before
3228
+ that (e.g. on page load) rather than caching it long-term. Storefront or
3229
+ vibe-coded mode, requires `customerToken`.
3230
+
3185
3231
  #### Auth Response Type
3186
3232
 
3187
3233
  ```typescript
package/dist/index.d.mts CHANGED
@@ -76,6 +76,31 @@ interface BrainerceClientOptions {
76
76
  statusCode: number;
77
77
  path?: string;
78
78
  }) => void;
79
+ /**
80
+ * Callback fired when the SDK silently resets the guest session cart because
81
+ * the previously-stored cart could no longer be resolved as-is — either the
82
+ * fetch failed (network error, 404 — cart deleted/expired) or the cart was
83
+ * found but is no longer `ACTIVE` (e.g. a prior checkout on it already
84
+ * completed or the cart was abandoned/merged). In both cases the SDK
85
+ * transparently creates a fresh empty cart so `smartAddToCart()` /
86
+ * `smartGetCart()` keep working — this callback is your only signal that it
87
+ * happened, so the storefront can tell the shopper their cart expired
88
+ * instead of them just seeing it silently empty out.
89
+ *
90
+ * @example
91
+ * ```typescript
92
+ * const client = new BrainerceClient({
93
+ * salesChannelId: 'vc_abc123...',
94
+ * onCartReset: ({ previousCartId, reason }) => {
95
+ * toast.warn('Your cart session expired — please re-add your items.');
96
+ * },
97
+ * });
98
+ * ```
99
+ */
100
+ onCartReset?: (info: {
101
+ previousCartId: string;
102
+ reason: 'not_found' | 'not_active';
103
+ }) => void;
79
104
  /**
80
105
  * Origin header to send with requests.
81
106
  * Browsers add this automatically, but Node.js environments (SSR, scripts, npx)
@@ -204,6 +229,26 @@ interface StoreInfo {
204
229
  seo?: {
205
230
  indexNowKey: string | null;
206
231
  };
232
+ /**
233
+ * Real merchant-configured shipping rates (sales-channel mode only) —
234
+ * flat-rate/free zones only, each with a single unconditional price.
235
+ * Weight/price-tiered and local-pickup rates are excluded because their
236
+ * cost depends on cart contents, so there's no single number to declare.
237
+ * Feeds Product JSON-LD `shippingDetails` — pass as `buildProductJsonLd(product, { ..., shipping: storeInfo.shipping })`.
238
+ */
239
+ shipping?: ShippingSummaryEntry[];
240
+ }
241
+ /** One flat-rate/free shipping zone, as exposed by `StoreInfo.shipping`. */
242
+ interface ShippingSummaryEntry {
243
+ /** ISO 3166-1 alpha-2 country codes this rate applies to. */
244
+ countries: string[];
245
+ rateType: 'FLAT_RATE' | 'FREE';
246
+ /** Shipping cost in the store's currency. `0` for FREE, `null` if a FLAT_RATE has no configured amount. */
247
+ amount: number | null;
248
+ minDeliveryDays: number | null;
249
+ maxDeliveryDays: number | null;
250
+ /** Order-processing time in business days before the item ships. */
251
+ handlingTime: number | null;
207
252
  }
208
253
  /** Multi-language configuration exposed to the storefront */
209
254
  interface I18nSettings {
@@ -497,6 +542,10 @@ interface Product {
497
542
  * `SIMPLE` products it is the product's own stored sale price.
498
543
  */
499
544
  salePrice?: string | null;
545
+ /** ISO 8601 — start of the sale-price effective window. `null` when unset (sale has no window). */
546
+ salePriceStartsAt?: string | null;
547
+ /** ISO 8601 — end of the sale-price effective window. Feeds Product JSON-LD `priceValidUntil`. `null` when unset. */
548
+ salePriceEndsAt?: string | null;
500
549
  /** Cost price as string. Use parseFloat() for calculations. */
501
550
  costPrice?: string | null;
502
551
  /** Lowest effective variant price (VARIABLE products only). String Decimal, e.g. "19.99". */
@@ -526,13 +575,15 @@ interface Product {
526
575
  inventory?: InventoryInfo | null;
527
576
  variants?: ProductVariant[];
528
577
  /**
529
- * Categories as objects with `id` and `name`.
530
- * NOT string[] - each category is `{ id: string; name: string }`.
531
- * Access: `product.categories?.map(cat => cat.name)`
578
+ * Categories as objects with `id`, `name`, and `slug`.
579
+ * NOT string[] - each category is `{ id: string; name: string; slug?: string | null }`.
580
+ * Access: `product.categories?.map(cat => cat.name)`. Use `slug` to link to
581
+ * that category's `/category/{slug}` landing page.
532
582
  */
533
583
  categories?: Array<{
534
584
  id: string;
535
585
  name: string;
586
+ slug?: string | null;
536
587
  }>;
537
588
  /** Brands as objects with id and name */
538
589
  brands?: Array<{
@@ -704,6 +755,10 @@ interface ProductVariant {
704
755
  price?: string | null;
705
756
  /** Variant sale price as string. Use parseFloat() for calculations. */
706
757
  salePrice?: string | null;
758
+ /** Variant unit cost (COGS) override as string — falls back to the product
759
+ * costPrice in margin analytics. Admin (apiKey) reads only; public
760
+ * storefront responses never include it. */
761
+ costPrice?: string | null;
707
762
  /** PRD §23: variant price converted to the region's currency via the daily
708
763
  * FX snapshot. Present only with `getProducts({ regionId })`. Display-only. */
709
764
  displayPrice?: string;
@@ -3120,6 +3175,8 @@ interface CreateVariantDto {
3120
3175
  attributes?: Record<string, string>;
3121
3176
  price?: number;
3122
3177
  salePrice?: number;
3178
+ /** Variant unit cost (COGS) override — falls back to product costPrice in margin analytics. */
3179
+ costPrice?: number;
3123
3180
  inventory?: number;
3124
3181
  image?: unknown;
3125
3182
  position?: number;
@@ -3131,6 +3188,8 @@ interface UpdateVariantDto {
3131
3188
  attributes?: Record<string, string>;
3132
3189
  price?: number;
3133
3190
  salePrice?: number;
3191
+ /** Variant unit cost (COGS) override. Pass null to clear (falls back to product costPrice). */
3192
+ costPrice?: number | null;
3134
3193
  image?: string | unknown;
3135
3194
  position?: number;
3136
3195
  status?: VariantStatus;
@@ -3149,6 +3208,8 @@ interface BulkVariantInput {
3149
3208
  attributes: Record<string, string>;
3150
3209
  price?: number | null;
3151
3210
  salePrice?: number | null;
3211
+ /** Variant unit cost (COGS) override. null clears (falls back to product costPrice). */
3212
+ costPrice?: number | null;
3152
3213
  stock: number;
3153
3214
  position?: number;
3154
3215
  image?: unknown | null;
@@ -6012,6 +6073,7 @@ declare class BrainerceClient {
6012
6073
  private readonly origin?;
6013
6074
  private readonly proxyMode;
6014
6075
  private readonly onAuthError?;
6076
+ private readonly onCartReset?;
6015
6077
  /** Active locale for content translation. When set, content endpoints return translated data. */
6016
6078
  private locale?;
6017
6079
  constructor(options: BrainerceClientOptions);
@@ -9283,6 +9345,25 @@ declare class BrainerceClient {
9283
9345
  * ```
9284
9346
  */
9285
9347
  cancelMembership(): Promise<PaidMembershipInfo>;
9348
+ /**
9349
+ * Mint a short-lived session for the embeddable loyalty widget (Phase 5) and
9350
+ * return the ready-to-use iframe URL. Requires customerToken. The returned
9351
+ * `embedUrl` is safe to drop straight into an `<iframe src>` — it carries a
9352
+ * scoped ~15-minute session token, never the real customerToken. Re-call this
9353
+ * before the iframe reloads (e.g. on page navigation) to refresh it.
9354
+ *
9355
+ * @example
9356
+ * ```typescript
9357
+ * const { embedUrl } = await client.getLoyaltyWidgetSession();
9358
+ * // <iframe src={embedUrl} width="360" height="420" />
9359
+ * ```
9360
+ */
9361
+ getLoyaltyWidgetSession(): Promise<{
9362
+ sessionId: string;
9363
+ expiresAt: string;
9364
+ storeId: string;
9365
+ embedUrl: string;
9366
+ }>;
9286
9367
  /**
9287
9368
  * Get the current customer's orders (requires customerToken)
9288
9369
  * Works in vibe-coded and storefront modes
@@ -10686,6 +10767,8 @@ declare function buildProductJsonLd(product: Product, opts: JsonLdOptions & {
10686
10767
  currency: string;
10687
10768
  /** Brand display name; falls back to product.brands[0]. */
10688
10769
  brandName?: string;
10770
+ /** Flat-rate/free shipping zones (from `StoreInfo.shipping`). Omitted entirely when not provided — no fabricated shipping cost. */
10771
+ shipping?: ShippingSummaryEntry[];
10689
10772
  }): JsonLd;
10690
10773
  /**
10691
10774
  * schema.org/Organization for the homepage (Knowledge Panel + AI-answer
@@ -10786,4 +10869,4 @@ interface CategorySitemapOptions {
10786
10869
  */
10787
10870
  declare function getCategorySitemapEntries(client: BrainerceClient, opts: CategorySitemapOptions): Promise<SitemapEntry[]>;
10788
10871
 
10789
- export { type AddToCartDto, type AddressDetailsResult, type AddressSuggestion, type AnnouncementContent, type AnnouncementSeverity, type AppliedDiscount, type ApplyCouponDto, type AttachModifierGroupInput, type Attribute, type AttributeOption, type AttributeSource, type BlogSitemapOptions, 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 CategoryDetail, type CategoryNode, type CategorySitemapOptions, 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 JsonLdOptions, 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 SitemapEntry, 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, buildArticleJsonLd, buildBreadcrumbJsonLd, buildCollectionPageJsonLd, buildOrganizationJsonLd, buildProductJsonLd, buildWebsiteJsonLd, createWebhookHandler, deriveSeoDescription, enableDevGuards, formatMoney, formatPrice, formatProductPrice, formatVariantPrice, getBlogSitemapEntries, getCartItemImage, getCartItemName, getCartTotals, getCategorySitemapEntries, getDescriptionContent, getDirectionForLocale, formatPrice as getPriceDisplay, getProductCustomizationFields, getProductMetafield, getProductMetafieldValue, getProductMetafieldsByType, getProductPrice, getProductPriceInfo, getProductSwatches, getStockStatus, getVariantOptions, getVariantPrice, isAllowedPaymentUrl, isCouponApplicableToProduct, isHtmlDescription, isWebhookEventType, jsonLdScriptProps, parseWebhookEvent, safePaymentRedirect, stripHtml, verifyWebhook };
10872
+ export { type AddToCartDto, type AddressDetailsResult, type AddressSuggestion, type AnnouncementContent, type AnnouncementSeverity, type AppliedDiscount, type ApplyCouponDto, type AttachModifierGroupInput, type Attribute, type AttributeOption, type AttributeSource, type BlogSitemapOptions, 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 CategoryDetail, type CategoryNode, type CategorySitemapOptions, 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 JsonLdOptions, 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 ShippingSummaryEntry, type ShippingZone, type ShippingZoneQueryParams, type SitemapEntry, 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, buildArticleJsonLd, buildBreadcrumbJsonLd, buildCollectionPageJsonLd, buildOrganizationJsonLd, buildProductJsonLd, buildWebsiteJsonLd, createWebhookHandler, deriveSeoDescription, enableDevGuards, formatMoney, formatPrice, formatProductPrice, formatVariantPrice, getBlogSitemapEntries, getCartItemImage, getCartItemName, getCartTotals, getCategorySitemapEntries, getDescriptionContent, getDirectionForLocale, formatPrice as getPriceDisplay, getProductCustomizationFields, getProductMetafield, getProductMetafieldValue, getProductMetafieldsByType, getProductPrice, getProductPriceInfo, getProductSwatches, getStockStatus, getVariantOptions, getVariantPrice, isAllowedPaymentUrl, isCouponApplicableToProduct, isHtmlDescription, isWebhookEventType, jsonLdScriptProps, parseWebhookEvent, safePaymentRedirect, stripHtml, verifyWebhook };
package/dist/index.d.ts CHANGED
@@ -76,6 +76,31 @@ interface BrainerceClientOptions {
76
76
  statusCode: number;
77
77
  path?: string;
78
78
  }) => void;
79
+ /**
80
+ * Callback fired when the SDK silently resets the guest session cart because
81
+ * the previously-stored cart could no longer be resolved as-is — either the
82
+ * fetch failed (network error, 404 — cart deleted/expired) or the cart was
83
+ * found but is no longer `ACTIVE` (e.g. a prior checkout on it already
84
+ * completed or the cart was abandoned/merged). In both cases the SDK
85
+ * transparently creates a fresh empty cart so `smartAddToCart()` /
86
+ * `smartGetCart()` keep working — this callback is your only signal that it
87
+ * happened, so the storefront can tell the shopper their cart expired
88
+ * instead of them just seeing it silently empty out.
89
+ *
90
+ * @example
91
+ * ```typescript
92
+ * const client = new BrainerceClient({
93
+ * salesChannelId: 'vc_abc123...',
94
+ * onCartReset: ({ previousCartId, reason }) => {
95
+ * toast.warn('Your cart session expired — please re-add your items.');
96
+ * },
97
+ * });
98
+ * ```
99
+ */
100
+ onCartReset?: (info: {
101
+ previousCartId: string;
102
+ reason: 'not_found' | 'not_active';
103
+ }) => void;
79
104
  /**
80
105
  * Origin header to send with requests.
81
106
  * Browsers add this automatically, but Node.js environments (SSR, scripts, npx)
@@ -204,6 +229,26 @@ interface StoreInfo {
204
229
  seo?: {
205
230
  indexNowKey: string | null;
206
231
  };
232
+ /**
233
+ * Real merchant-configured shipping rates (sales-channel mode only) —
234
+ * flat-rate/free zones only, each with a single unconditional price.
235
+ * Weight/price-tiered and local-pickup rates are excluded because their
236
+ * cost depends on cart contents, so there's no single number to declare.
237
+ * Feeds Product JSON-LD `shippingDetails` — pass as `buildProductJsonLd(product, { ..., shipping: storeInfo.shipping })`.
238
+ */
239
+ shipping?: ShippingSummaryEntry[];
240
+ }
241
+ /** One flat-rate/free shipping zone, as exposed by `StoreInfo.shipping`. */
242
+ interface ShippingSummaryEntry {
243
+ /** ISO 3166-1 alpha-2 country codes this rate applies to. */
244
+ countries: string[];
245
+ rateType: 'FLAT_RATE' | 'FREE';
246
+ /** Shipping cost in the store's currency. `0` for FREE, `null` if a FLAT_RATE has no configured amount. */
247
+ amount: number | null;
248
+ minDeliveryDays: number | null;
249
+ maxDeliveryDays: number | null;
250
+ /** Order-processing time in business days before the item ships. */
251
+ handlingTime: number | null;
207
252
  }
208
253
  /** Multi-language configuration exposed to the storefront */
209
254
  interface I18nSettings {
@@ -497,6 +542,10 @@ interface Product {
497
542
  * `SIMPLE` products it is the product's own stored sale price.
498
543
  */
499
544
  salePrice?: string | null;
545
+ /** ISO 8601 — start of the sale-price effective window. `null` when unset (sale has no window). */
546
+ salePriceStartsAt?: string | null;
547
+ /** ISO 8601 — end of the sale-price effective window. Feeds Product JSON-LD `priceValidUntil`. `null` when unset. */
548
+ salePriceEndsAt?: string | null;
500
549
  /** Cost price as string. Use parseFloat() for calculations. */
501
550
  costPrice?: string | null;
502
551
  /** Lowest effective variant price (VARIABLE products only). String Decimal, e.g. "19.99". */
@@ -526,13 +575,15 @@ interface Product {
526
575
  inventory?: InventoryInfo | null;
527
576
  variants?: ProductVariant[];
528
577
  /**
529
- * Categories as objects with `id` and `name`.
530
- * NOT string[] - each category is `{ id: string; name: string }`.
531
- * Access: `product.categories?.map(cat => cat.name)`
578
+ * Categories as objects with `id`, `name`, and `slug`.
579
+ * NOT string[] - each category is `{ id: string; name: string; slug?: string | null }`.
580
+ * Access: `product.categories?.map(cat => cat.name)`. Use `slug` to link to
581
+ * that category's `/category/{slug}` landing page.
532
582
  */
533
583
  categories?: Array<{
534
584
  id: string;
535
585
  name: string;
586
+ slug?: string | null;
536
587
  }>;
537
588
  /** Brands as objects with id and name */
538
589
  brands?: Array<{
@@ -704,6 +755,10 @@ interface ProductVariant {
704
755
  price?: string | null;
705
756
  /** Variant sale price as string. Use parseFloat() for calculations. */
706
757
  salePrice?: string | null;
758
+ /** Variant unit cost (COGS) override as string — falls back to the product
759
+ * costPrice in margin analytics. Admin (apiKey) reads only; public
760
+ * storefront responses never include it. */
761
+ costPrice?: string | null;
707
762
  /** PRD §23: variant price converted to the region's currency via the daily
708
763
  * FX snapshot. Present only with `getProducts({ regionId })`. Display-only. */
709
764
  displayPrice?: string;
@@ -3120,6 +3175,8 @@ interface CreateVariantDto {
3120
3175
  attributes?: Record<string, string>;
3121
3176
  price?: number;
3122
3177
  salePrice?: number;
3178
+ /** Variant unit cost (COGS) override — falls back to product costPrice in margin analytics. */
3179
+ costPrice?: number;
3123
3180
  inventory?: number;
3124
3181
  image?: unknown;
3125
3182
  position?: number;
@@ -3131,6 +3188,8 @@ interface UpdateVariantDto {
3131
3188
  attributes?: Record<string, string>;
3132
3189
  price?: number;
3133
3190
  salePrice?: number;
3191
+ /** Variant unit cost (COGS) override. Pass null to clear (falls back to product costPrice). */
3192
+ costPrice?: number | null;
3134
3193
  image?: string | unknown;
3135
3194
  position?: number;
3136
3195
  status?: VariantStatus;
@@ -3149,6 +3208,8 @@ interface BulkVariantInput {
3149
3208
  attributes: Record<string, string>;
3150
3209
  price?: number | null;
3151
3210
  salePrice?: number | null;
3211
+ /** Variant unit cost (COGS) override. null clears (falls back to product costPrice). */
3212
+ costPrice?: number | null;
3152
3213
  stock: number;
3153
3214
  position?: number;
3154
3215
  image?: unknown | null;
@@ -6012,6 +6073,7 @@ declare class BrainerceClient {
6012
6073
  private readonly origin?;
6013
6074
  private readonly proxyMode;
6014
6075
  private readonly onAuthError?;
6076
+ private readonly onCartReset?;
6015
6077
  /** Active locale for content translation. When set, content endpoints return translated data. */
6016
6078
  private locale?;
6017
6079
  constructor(options: BrainerceClientOptions);
@@ -9283,6 +9345,25 @@ declare class BrainerceClient {
9283
9345
  * ```
9284
9346
  */
9285
9347
  cancelMembership(): Promise<PaidMembershipInfo>;
9348
+ /**
9349
+ * Mint a short-lived session for the embeddable loyalty widget (Phase 5) and
9350
+ * return the ready-to-use iframe URL. Requires customerToken. The returned
9351
+ * `embedUrl` is safe to drop straight into an `<iframe src>` — it carries a
9352
+ * scoped ~15-minute session token, never the real customerToken. Re-call this
9353
+ * before the iframe reloads (e.g. on page navigation) to refresh it.
9354
+ *
9355
+ * @example
9356
+ * ```typescript
9357
+ * const { embedUrl } = await client.getLoyaltyWidgetSession();
9358
+ * // <iframe src={embedUrl} width="360" height="420" />
9359
+ * ```
9360
+ */
9361
+ getLoyaltyWidgetSession(): Promise<{
9362
+ sessionId: string;
9363
+ expiresAt: string;
9364
+ storeId: string;
9365
+ embedUrl: string;
9366
+ }>;
9286
9367
  /**
9287
9368
  * Get the current customer's orders (requires customerToken)
9288
9369
  * Works in vibe-coded and storefront modes
@@ -10686,6 +10767,8 @@ declare function buildProductJsonLd(product: Product, opts: JsonLdOptions & {
10686
10767
  currency: string;
10687
10768
  /** Brand display name; falls back to product.brands[0]. */
10688
10769
  brandName?: string;
10770
+ /** Flat-rate/free shipping zones (from `StoreInfo.shipping`). Omitted entirely when not provided — no fabricated shipping cost. */
10771
+ shipping?: ShippingSummaryEntry[];
10689
10772
  }): JsonLd;
10690
10773
  /**
10691
10774
  * schema.org/Organization for the homepage (Knowledge Panel + AI-answer
@@ -10786,4 +10869,4 @@ interface CategorySitemapOptions {
10786
10869
  */
10787
10870
  declare function getCategorySitemapEntries(client: BrainerceClient, opts: CategorySitemapOptions): Promise<SitemapEntry[]>;
10788
10871
 
10789
- export { type AddToCartDto, type AddressDetailsResult, type AddressSuggestion, type AnnouncementContent, type AnnouncementSeverity, type AppliedDiscount, type ApplyCouponDto, type AttachModifierGroupInput, type Attribute, type AttributeOption, type AttributeSource, type BlogSitemapOptions, 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 CategoryDetail, type CategoryNode, type CategorySitemapOptions, 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 JsonLdOptions, 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 SitemapEntry, 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, buildArticleJsonLd, buildBreadcrumbJsonLd, buildCollectionPageJsonLd, buildOrganizationJsonLd, buildProductJsonLd, buildWebsiteJsonLd, createWebhookHandler, deriveSeoDescription, enableDevGuards, formatMoney, formatPrice, formatProductPrice, formatVariantPrice, getBlogSitemapEntries, getCartItemImage, getCartItemName, getCartTotals, getCategorySitemapEntries, getDescriptionContent, getDirectionForLocale, formatPrice as getPriceDisplay, getProductCustomizationFields, getProductMetafield, getProductMetafieldValue, getProductMetafieldsByType, getProductPrice, getProductPriceInfo, getProductSwatches, getStockStatus, getVariantOptions, getVariantPrice, isAllowedPaymentUrl, isCouponApplicableToProduct, isHtmlDescription, isWebhookEventType, jsonLdScriptProps, parseWebhookEvent, safePaymentRedirect, stripHtml, verifyWebhook };
10872
+ export { type AddToCartDto, type AddressDetailsResult, type AddressSuggestion, type AnnouncementContent, type AnnouncementSeverity, type AppliedDiscount, type ApplyCouponDto, type AttachModifierGroupInput, type Attribute, type AttributeOption, type AttributeSource, type BlogSitemapOptions, 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 CategoryDetail, type CategoryNode, type CategorySitemapOptions, 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 JsonLdOptions, 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 ShippingSummaryEntry, type ShippingZone, type ShippingZoneQueryParams, type SitemapEntry, 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, buildArticleJsonLd, buildBreadcrumbJsonLd, buildCollectionPageJsonLd, buildOrganizationJsonLd, buildProductJsonLd, buildWebsiteJsonLd, createWebhookHandler, deriveSeoDescription, enableDevGuards, formatMoney, formatPrice, formatProductPrice, formatVariantPrice, getBlogSitemapEntries, getCartItemImage, getCartItemName, getCartTotals, getCategorySitemapEntries, getDescriptionContent, getDirectionForLocale, formatPrice as getPriceDisplay, getProductCustomizationFields, getProductMetafield, getProductMetafieldValue, getProductMetafieldsByType, getProductPrice, getProductPriceInfo, getProductSwatches, getStockStatus, getVariantOptions, getVariantPrice, isAllowedPaymentUrl, isCouponApplicableToProduct, isHtmlDescription, isWebhookEventType, jsonLdScriptProps, parseWebhookEvent, safePaymentRedirect, stripHtml, verifyWebhook };