@behio/storefront-sdk 2.2.0 → 2.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -252,6 +252,26 @@ A failed price entitlement lookup returns HTTP 503 with `be.storefront.pricingUn
252
252
 
253
253
  `catalog.getCategoryProducts(slug, query)` shares the full `ProductsQuery` serializer with `getProducts`. Price bounds retain zero, boolean filters retain false, arrays use repeated parameters and public parameter/facet selections use JSON. Category, main-list and featured availability follow the same published-variant and stock-mode rules in the backend.
254
254
 
255
+ ### Cart links from Behio Chat (2.4)
256
+
257
+ `cart.claimLink(token)` adds the products of a prepared cart link (created by
258
+ the AI in Behio Chat) to the visitor's cart and applies the link's discount
259
+ code. Call it on the server in a `/cart/link/[token]` route handler, then
260
+ redirect to checkout. Items are added, never replacing the cart; a second open
261
+ does not double quantities. Expired links fail with
262
+ `be.storefront.cartLinkExpired`. Answer `GET /cart/link/_probe` with header
263
+ `x-behio-cart-link: 1` so Behio Chat knows the storefront supports links.
264
+
265
+ ### Cart summary for page scripts (2.2, helper 2.3)
266
+
267
+ Browser cart responses dispatch `behio:cart` on `window` with
268
+ `{total, currency, itemCount}` and keep the last value in `window.__behioCart`
269
+ (Behio Chat reads it for cart-value greetings). Carts with
270
+ `totalsAvailable: false` are not announced. Storefronts that mutate the cart on
271
+ the server (Server Actions, snapshot routes) call
272
+ `publishCartSummary({total, currency, itemCount})` on the client after each
273
+ fresh cart; it does nothing during SSR.
274
+
255
275
  ### Bundle offers and galleries (2.0, unreleased)
256
276
 
257
277
  `catalog.getBundles({locale, currency, country})` and `getBundle(slug, options)`
@@ -1301,6 +1301,25 @@ var CartModule = class {
1301
1301
  this.client.emit("cart:updated", res.data);
1302
1302
  return res;
1303
1303
  }
1304
+ /**
1305
+ * Add the products of a prepared cart link to the visitor's cart (SDK 2.4).
1306
+ * Behio Chat creates these links when the AI assembles a cart for the
1307
+ * visitor; the storefront handles `/cart/link/<token>`, calls this on the
1308
+ * server (Server Action or route handler, so the session cookie can be
1309
+ * written) and redirects to checkout. Items are ADDED, never replacing the
1310
+ * cart; opening the link twice does not double quantities. A discount code
1311
+ * carried by the link is applied with the normal validation. An expired or
1312
+ * unknown link fails with `be.storefront.cartLinkExpired` (404).
1313
+ */
1314
+ async claimLink(token) {
1315
+ const res = await this.client.request("POST", `/cart/links/${encodeURIComponent(token)}/claim`, {});
1316
+ if (res.error) return res;
1317
+ if (res.data.newSessionToken) {
1318
+ this.client.setCartSession(res.data.newSessionToken);
1319
+ }
1320
+ this.client.emit("cart:updated", res.data);
1321
+ return res;
1322
+ }
1304
1323
  /** Remove discount code */
1305
1324
  async removeDiscount() {
1306
1325
  const res = await this.client.request("DELETE", "/cart/discount");
@@ -2104,22 +2123,28 @@ var NewsletterModule = class {
2104
2123
  );
2105
2124
  }
2106
2125
  };
2107
- function emitCartEvent(data) {
2126
+ function publishCartSummary(summary) {
2108
2127
  if (typeof window === "undefined" || typeof window.dispatchEvent !== "function") return;
2128
+ if (!Number.isFinite(summary.total) || !Number.isFinite(summary.itemCount)) return;
2129
+ const detail = { total: summary.total, currency: summary.currency ?? null, itemCount: summary.itemCount };
2130
+ try {
2131
+ window.__behioCart = detail;
2132
+ window.dispatchEvent(new CustomEvent("behio:cart", { detail }));
2133
+ } catch {
2134
+ }
2135
+ }
2136
+ function emitCartEvent(data) {
2137
+ if (typeof window === "undefined") return;
2109
2138
  const cart = data;
2110
2139
  if (!cart || typeof cart !== "object" || !Array.isArray(cart.items)) return;
2140
+ if (cart.totalsAvailable === false) return;
2111
2141
  const items = cart.items;
2112
2142
  const total = typeof cart.grandTotal === "number" ? cart.grandTotal : typeof cart.subtotal === "number" ? cart.subtotal : 0;
2113
- const detail = {
2143
+ publishCartSummary({
2114
2144
  total,
2115
2145
  currency: typeof cart.currency === "string" ? cart.currency : null,
2116
2146
  itemCount: items.reduce((n, i) => n + (typeof i?.quantity === "number" ? i.quantity : 1), 0)
2117
- };
2118
- try {
2119
- window.__behioCart = detail;
2120
- window.dispatchEvent(new CustomEvent("behio:cart", { detail }));
2121
- } catch {
2122
- }
2147
+ });
2123
2148
  }
2124
2149
 
2125
2150
  export {
@@ -2133,5 +2158,6 @@ export {
2133
2158
  ok,
2134
2159
  err,
2135
2160
  toSdkError,
2136
- BehioStorefront
2161
+ BehioStorefront,
2162
+ publishCartSummary
2137
2163
  };
@@ -1301,6 +1301,25 @@ var CartModule = class {
1301
1301
  this.client.emit("cart:updated", res.data);
1302
1302
  return res;
1303
1303
  }
1304
+ /**
1305
+ * Add the products of a prepared cart link to the visitor's cart (SDK 2.4).
1306
+ * Behio Chat creates these links when the AI assembles a cart for the
1307
+ * visitor; the storefront handles `/cart/link/<token>`, calls this on the
1308
+ * server (Server Action or route handler, so the session cookie can be
1309
+ * written) and redirects to checkout. Items are ADDED, never replacing the
1310
+ * cart; opening the link twice does not double quantities. A discount code
1311
+ * carried by the link is applied with the normal validation. An expired or
1312
+ * unknown link fails with `be.storefront.cartLinkExpired` (404).
1313
+ */
1314
+ async claimLink(token) {
1315
+ const res = await this.client.request("POST", `/cart/links/${encodeURIComponent(token)}/claim`, {});
1316
+ if (res.error) return res;
1317
+ if (res.data.newSessionToken) {
1318
+ this.client.setCartSession(res.data.newSessionToken);
1319
+ }
1320
+ this.client.emit("cart:updated", res.data);
1321
+ return res;
1322
+ }
1304
1323
  /** Remove discount code */
1305
1324
  async removeDiscount() {
1306
1325
  const res = await this.client.request("DELETE", "/cart/discount");
@@ -2104,22 +2123,28 @@ var NewsletterModule = class {
2104
2123
  );
2105
2124
  }
2106
2125
  };
2107
- function emitCartEvent(data) {
2126
+ function publishCartSummary(summary) {
2108
2127
  if (typeof window === "undefined" || typeof window.dispatchEvent !== "function") return;
2128
+ if (!Number.isFinite(summary.total) || !Number.isFinite(summary.itemCount)) return;
2129
+ const detail = { total: summary.total, currency: _nullishCoalesce(summary.currency, () => ( null)), itemCount: summary.itemCount };
2130
+ try {
2131
+ window.__behioCart = detail;
2132
+ window.dispatchEvent(new CustomEvent("behio:cart", { detail }));
2133
+ } catch (e6) {
2134
+ }
2135
+ }
2136
+ function emitCartEvent(data) {
2137
+ if (typeof window === "undefined") return;
2109
2138
  const cart = data;
2110
2139
  if (!cart || typeof cart !== "object" || !Array.isArray(cart.items)) return;
2140
+ if (cart.totalsAvailable === false) return;
2111
2141
  const items = cart.items;
2112
2142
  const total = typeof cart.grandTotal === "number" ? cart.grandTotal : typeof cart.subtotal === "number" ? cart.subtotal : 0;
2113
- const detail = {
2143
+ publishCartSummary({
2114
2144
  total,
2115
2145
  currency: typeof cart.currency === "string" ? cart.currency : null,
2116
2146
  itemCount: items.reduce((n, i) => n + (typeof _optionalChain([i, 'optionalAccess', _53 => _53.quantity]) === "number" ? i.quantity : 1), 0)
2117
- };
2118
- try {
2119
- window.__behioCart = detail;
2120
- window.dispatchEvent(new CustomEvent("behio:cart", { detail }));
2121
- } catch (e6) {
2122
- }
2147
+ });
2123
2148
  }
2124
2149
 
2125
2150
 
@@ -2134,4 +2159,5 @@ function emitCartEvent(data) {
2134
2159
 
2135
2160
 
2136
2161
 
2137
- exports.ProductSort = ProductSort; exports.OrderStatuses = OrderStatuses; exports.PaymentStatuses = PaymentStatuses; exports.FulfillmentStatuses = FulfillmentStatuses; exports.AddressTypes = AddressTypes; exports.BehioApiError = BehioApiError; exports.BehioNetworkError = BehioNetworkError; exports.ok = ok; exports.err = err; exports.toSdkError = toSdkError; exports.BehioStorefront = BehioStorefront;
2162
+
2163
+ exports.ProductSort = ProductSort; exports.OrderStatuses = OrderStatuses; exports.PaymentStatuses = PaymentStatuses; exports.FulfillmentStatuses = FulfillmentStatuses; exports.AddressTypes = AddressTypes; exports.BehioApiError = BehioApiError; exports.BehioNetworkError = BehioNetworkError; exports.ok = ok; exports.err = err; exports.toSdkError = toSdkError; exports.BehioStorefront = BehioStorefront; exports.publishCartSummary = publishCartSummary;
@@ -2852,6 +2852,16 @@ interface Sitemap {
2852
2852
  categories: SitemapEntry[];
2853
2853
  pages: SitemapEntry[];
2854
2854
  }
2855
+ /** Result of `cart.claimLink(token)`: the updated cart plus what the link did. */
2856
+ interface CartLinkClaimed extends Cart {
2857
+ /** New anonymous cart session (the SDK stores it automatically). */
2858
+ newSessionToken?: string;
2859
+ /** Products from the link that can no longer be bought and were skipped. */
2860
+ linkSkippedItems: number;
2861
+ /** A discount code carried by the link was applied. */
2862
+ linkDiscountApplied: boolean;
2863
+ linkDiscountCode: string | null;
2864
+ }
2855
2865
 
2856
2866
  declare class BehioStorefront {
2857
2867
  private baseUrl;
@@ -3350,6 +3360,17 @@ declare class CartModule {
3350
3360
  merge(): Promise<SdkResult<Cart>>;
3351
3361
  /** Apply discount code */
3352
3362
  applyDiscount(code: string): Promise<SdkResult<Cart>>;
3363
+ /**
3364
+ * Add the products of a prepared cart link to the visitor's cart (SDK 2.4).
3365
+ * Behio Chat creates these links when the AI assembles a cart for the
3366
+ * visitor; the storefront handles `/cart/link/<token>`, calls this on the
3367
+ * server (Server Action or route handler, so the session cookie can be
3368
+ * written) and redirects to checkout. Items are ADDED, never replacing the
3369
+ * cart; opening the link twice does not double quantities. A discount code
3370
+ * carried by the link is applied with the normal validation. An expired or
3371
+ * unknown link fails with `be.storefront.cartLinkExpired` (404).
3372
+ */
3373
+ claimLink(token: string): Promise<SdkResult<CartLinkClaimed>>;
3353
3374
  /** Remove discount code */
3354
3375
  removeDiscount(): Promise<SdkResult<Cart>>;
3355
3376
  }
@@ -3790,5 +3811,19 @@ declare class NewsletterModule {
3790
3811
  subscribe(input: NewsletterSubscribeInput): Promise<SdkResult<NewsletterSubscribeResult>>;
3791
3812
  unsubscribe(email: string): Promise<SdkResult<NewsletterUnsubscribeResult>>;
3792
3813
  }
3814
+ /** Souhrn kosiku pro skripty na strance (Behio Chat, analytika). */
3815
+ interface CartSummaryEvent {
3816
+ total: number;
3817
+ currency: string | null;
3818
+ itemCount: number;
3819
+ }
3820
+ /**
3821
+ * Vysle v prohlizeci udalost `behio:cart` ({total, currency, itemCount})
3822
+ * a ulozi ji do `window.__behioCart`. Posloucha ji Behio Chat (osloveni podle
3823
+ * hodnoty kosiku, promenne {cartTotal}). SDK ji vola samo po kazde odpovedi
3824
+ * kosiku v prohlizeci. Sablona, ktera kosik meni na serveru (Server Actions,
3825
+ * vlastni route), ji zavola sama s aktualnim souhrnem. Na serveru nedela nic.
3826
+ */
3827
+ declare function publishCartSummary(summary: CartSummaryEvent): void;
3793
3828
 
3794
- export { type CourseDetail as $, type ActivePromotion as A, BehioStorefront as B, type CookieConsent as C, type Cart as D, type CartBundleLine as E, type CartBundleLineItem as F, type CartDiscount as G, type CartItem as H, type CartItemProduct as I, type CartPromotion as J, type Category as K, type CategoryDetail as L, type CertificateVerification as M, type CheckoutAddress as N, type CheckoutInput as O, type ProductDetail as P, type CheckoutPaymentMethod as Q, type CheckoutPreview as R, type SdkResult as S, type CheckoutResult as T, type CheckoutSettings as U, type CookieConsentInput as V, type CourseAttachment as W, type CourseCertificate as X, type CourseComment as Y, type CourseCommentReply as Z, type CourseCommentsList as _, type ProductVariant as a, PaymentStatuses as a$, type CourseLesson as a0, type CourseListItem as a1, type CourseModule as a2, type CoursePostedComment as a3, type CourseProgress as a4, type CourseTutorMessage as a5, type CourseTutorThread as a6, type CrossSellItem as a7, type CurrencyDisplayFormat as a8, type CustomerAddress as a9, type LoyaltyTier as aA, type LoyaltyTierPerks as aB, type LoyaltyTransaction as aC, type Menu as aD, type MenuItem as aE, type MenuItemRef as aF, type MenuItemType as aG, type MessageResponse as aH, type NewsletterOptInDefault as aI, type NewsletterSubscribeInput as aJ, type NewsletterSubscribeResult as aK, type NewsletterUnsubscribeResult as aL, type OrderAccessRequestResponse as aM, type OrderAccessVerifyResponse as aN, type OrderDetail as aO, type OrderItem as aP, type OrderListItem as aQ, type OrderStatus as aR, type OrderStatusHistory as aS, OrderStatuses as aT, type OrderTracking as aU, type Page as aV, type PageAttachment as aW, type PageDetail as aX, type PaginatedResponse as aY, type PaymentInstrument as aZ, type PaymentStatus as a_, type CustomerProfile as aa, type DigitalDownload as ab, type DownloadUrl as ac, type Facet as ad, type FacetAvailability as ae, type FacetCategory as af, type FacetLabel as ag, type FacetPriceRange as ah, type FacetRange as ai, type FacetRatingBucket as aj, type FacetValue as ak, type FacetsResponse as al, type FilterField as am, type FulfillmentStatus as an, FulfillmentStatuses as ao, type GiftCardBalance as ap, type GiftCardPurchaseInput as aq, type GiftCardPurchaseResult as ar, type GiftCardSummary as as, type LessonNote as at, type LessonQuiz as au, type LoginInput as av, type LoyaltyBalance as aw, type LoyaltyNextTier as ax, type LoyaltyProgram as ay, type LoyaltySummary as az, type StorefrontFormFieldError as b, type StorefrontForm as b$, type PaymentSwift as b0, type PickupPoint as b1, type PickupPointHours as b2, type PickupPointsInput as b3, type PickupWidgetConfig as b4, type PriceDisplay as b5, type ProductAssetGroup as b6, type ProductAssetItem as b7, type ProductAvailability as b8, type ProductGroup as b9, type ResponseInterceptor as bA, type ResponseInterceptorData as bB, type ReturnRequest as bC, type ReturnRequestItem as bD, type ReturnStatus as bE, type ReturnStatusItem as bF, type ReturnableOrder as bG, type ReturnableOrderItem as bH, type SdkError as bI, type ShippingMethodSummary as bJ, type ShippingQuote as bK, type ShippingQuoteInput as bL, type ShopAppearance as bM, type ShopInfo as bN, type ShopScript as bO, type ShopScriptPlacement as bP, type ShopScriptType as bQ, type ShopScripts as bR, type ShopSeo as bS, type ShopSeoIdentity as bT, type SiteFormField as bU, type SiteFormFieldOption as bV, type SiteFormFieldType as bW, type Sitemap as bX, type SitemapEntry as bY, type StockBehavior as bZ, type StockMode as b_, type ProductLabel as ba, type ProductListItem as bb, type ProductMedia as bc, type ProductMediaVariant as bd, type ProductParameter as be, type ProductParameterGroup as bf, type ProductParametersResponse as bg, type ProductPrice as bh, type ProductPromotionSummary as bi, type ProductReview as bj, type ProductReviewsResponse as bk, type ProductSibling as bl, ProductSort as bm, type ProductSortValue as bn, type ProductVolumePrice as bo, type ProductsQuery as bp, type QuizAnswerInput as bq, type QuizAnswerResult as br, type QuizQuestion as bs, type QuizResult as bt, type QuoteItem as bu, type QuoteRequest as bv, type RegisterInput as bw, type RegisterResult as bx, type RequestInterceptor as by, type RequestInterceptorConfig as bz, type AddToCartInput as c, type StorefrontFormFieldErrorCode as c0, type StorefrontFormFile as c1, type StorefrontFormSettings as c2, type StorefrontFormSubmitInput as c3, type StorefrontFormSubmitResult as c4, type StorefrontFormUpload as c5, type SubmitQuoteInput as c6, type SubmitReturnInput as c7, type SubmitReviewInput as c8, type Subscription as c9, type SubscriptionAction as ca, type SubscriptionFrequency as cb, type SubscriptionItem as cc, type SubscriptionStatus as cd, type TaxBreakdownLine as ce, type VariantAxis as cf, type VariantAxisValue as cg, type WishlistItem as ch, err as ci, ok as cj, toSdkError as ck, type AddressDetail as d, type AddressSuggestion as e, type AddressType as f, AddressTypes as g, type AuthTokens as h, type BackInStockSubscription as i, type BadgeTone as j, BehioApiError as k, type BehioErrorCode as l, type BehioEventHandler as m, type BehioEventType as n, BehioNetworkError as o, type BehioStorefrontConfig as p, type Blog as q, type BlogPostDetail as r, type BlogPostListItem as s, type BlogPostsPage as t, type BlogPostsQuery as u, type BlogSettings as v, type BlogTag as w, type Bundle as x, type BundleCatalogQuery as y, type BundleItem as z };
3829
+ export { type CourseCommentReply as $, type ActivePromotion as A, BehioStorefront as B, type CookieConsent as C, type Cart as D, type CartBundleLine as E, type CartBundleLineItem as F, type CartDiscount as G, type CartItem as H, type CartItemProduct as I, type CartLinkClaimed as J, type CartPromotion as K, type CartSummaryEvent as L, type Category as M, type CategoryDetail as N, type CertificateVerification as O, type ProductDetail as P, type CheckoutAddress as Q, type CheckoutInput as R, type SdkResult as S, type CheckoutPaymentMethod as T, type CheckoutPreview as U, type CheckoutResult as V, type CheckoutSettings as W, type CookieConsentInput as X, type CourseAttachment as Y, type CourseCertificate as Z, type CourseComment as _, type ProductVariant as a, type PaymentInstrument as a$, type CourseCommentsList as a0, type CourseDetail as a1, type CourseLesson as a2, type CourseListItem as a3, type CourseModule as a4, type CoursePostedComment as a5, type CourseProgress as a6, type CourseTutorMessage as a7, type CourseTutorThread as a8, type CrossSellItem as a9, type LoyaltyProgram as aA, type LoyaltySummary as aB, type LoyaltyTier as aC, type LoyaltyTierPerks as aD, type LoyaltyTransaction as aE, type Menu as aF, type MenuItem as aG, type MenuItemRef as aH, type MenuItemType as aI, type MessageResponse as aJ, type NewsletterOptInDefault as aK, type NewsletterSubscribeInput as aL, type NewsletterSubscribeResult as aM, type NewsletterUnsubscribeResult as aN, type OrderAccessRequestResponse as aO, type OrderAccessVerifyResponse as aP, type OrderDetail as aQ, type OrderItem as aR, type OrderListItem as aS, type OrderStatus as aT, type OrderStatusHistory as aU, OrderStatuses as aV, type OrderTracking as aW, type Page as aX, type PageAttachment as aY, type PageDetail as aZ, type PaginatedResponse as a_, type CurrencyDisplayFormat as aa, type CustomerAddress as ab, type CustomerProfile as ac, type DigitalDownload as ad, type DownloadUrl as ae, type Facet as af, type FacetAvailability as ag, type FacetCategory as ah, type FacetLabel as ai, type FacetPriceRange as aj, type FacetRange as ak, type FacetRatingBucket as al, type FacetValue as am, type FacetsResponse as an, type FilterField as ao, type FulfillmentStatus as ap, FulfillmentStatuses as aq, type GiftCardBalance as ar, type GiftCardPurchaseInput as as, type GiftCardPurchaseResult as at, type GiftCardSummary as au, type LessonNote as av, type LessonQuiz as aw, type LoginInput as ax, type LoyaltyBalance as ay, type LoyaltyNextTier as az, type StorefrontFormFieldError as b, type StockBehavior as b$, type PaymentStatus as b0, PaymentStatuses as b1, type PaymentSwift as b2, type PickupPoint as b3, type PickupPointHours as b4, type PickupPointsInput as b5, type PickupWidgetConfig as b6, type PriceDisplay as b7, type ProductAssetGroup as b8, type ProductAssetItem as b9, type RequestInterceptor as bA, type RequestInterceptorConfig as bB, type ResponseInterceptor as bC, type ResponseInterceptorData as bD, type ReturnRequest as bE, type ReturnRequestItem as bF, type ReturnStatus as bG, type ReturnStatusItem as bH, type ReturnableOrder as bI, type ReturnableOrderItem as bJ, type SdkError as bK, type ShippingMethodSummary as bL, type ShippingQuote as bM, type ShippingQuoteInput as bN, type ShopAppearance as bO, type ShopInfo as bP, type ShopScript as bQ, type ShopScriptPlacement as bR, type ShopScriptType as bS, type ShopScripts as bT, type ShopSeo as bU, type ShopSeoIdentity as bV, type SiteFormField as bW, type SiteFormFieldOption as bX, type SiteFormFieldType as bY, type Sitemap as bZ, type SitemapEntry as b_, type ProductAvailability as ba, type ProductGroup as bb, type ProductLabel as bc, type ProductListItem as bd, type ProductMedia as be, type ProductMediaVariant as bf, type ProductParameter as bg, type ProductParameterGroup as bh, type ProductParametersResponse as bi, type ProductPrice as bj, type ProductPromotionSummary as bk, type ProductReview as bl, type ProductReviewsResponse as bm, type ProductSibling as bn, ProductSort as bo, type ProductSortValue as bp, type ProductVolumePrice as bq, type ProductsQuery as br, type QuizAnswerInput as bs, type QuizAnswerResult as bt, type QuizQuestion as bu, type QuizResult as bv, type QuoteItem as bw, type QuoteRequest as bx, type RegisterInput as by, type RegisterResult as bz, type AddToCartInput as c, type StockMode as c0, type StorefrontForm as c1, type StorefrontFormFieldErrorCode as c2, type StorefrontFormFile as c3, type StorefrontFormSettings as c4, type StorefrontFormSubmitInput as c5, type StorefrontFormSubmitResult as c6, type StorefrontFormUpload as c7, type SubmitQuoteInput as c8, type SubmitReturnInput as c9, type SubmitReviewInput as ca, type Subscription as cb, type SubscriptionAction as cc, type SubscriptionFrequency as cd, type SubscriptionItem as ce, type SubscriptionStatus as cf, type TaxBreakdownLine as cg, type VariantAxis as ch, type VariantAxisValue as ci, type WishlistItem as cj, err as ck, ok as cl, publishCartSummary as cm, toSdkError as cn, type AddressDetail as d, type AddressSuggestion as e, type AddressType as f, AddressTypes as g, type AuthTokens as h, type BackInStockSubscription as i, type BadgeTone as j, BehioApiError as k, type BehioErrorCode as l, type BehioEventHandler as m, type BehioEventType as n, BehioNetworkError as o, type BehioStorefrontConfig as p, type Blog as q, type BlogPostDetail as r, type BlogPostListItem as s, type BlogPostsPage as t, type BlogPostsQuery as u, type BlogSettings as v, type BlogTag as w, type Bundle as x, type BundleCatalogQuery as y, type BundleItem as z };
@@ -2852,6 +2852,16 @@ interface Sitemap {
2852
2852
  categories: SitemapEntry[];
2853
2853
  pages: SitemapEntry[];
2854
2854
  }
2855
+ /** Result of `cart.claimLink(token)`: the updated cart plus what the link did. */
2856
+ interface CartLinkClaimed extends Cart {
2857
+ /** New anonymous cart session (the SDK stores it automatically). */
2858
+ newSessionToken?: string;
2859
+ /** Products from the link that can no longer be bought and were skipped. */
2860
+ linkSkippedItems: number;
2861
+ /** A discount code carried by the link was applied. */
2862
+ linkDiscountApplied: boolean;
2863
+ linkDiscountCode: string | null;
2864
+ }
2855
2865
 
2856
2866
  declare class BehioStorefront {
2857
2867
  private baseUrl;
@@ -3350,6 +3360,17 @@ declare class CartModule {
3350
3360
  merge(): Promise<SdkResult<Cart>>;
3351
3361
  /** Apply discount code */
3352
3362
  applyDiscount(code: string): Promise<SdkResult<Cart>>;
3363
+ /**
3364
+ * Add the products of a prepared cart link to the visitor's cart (SDK 2.4).
3365
+ * Behio Chat creates these links when the AI assembles a cart for the
3366
+ * visitor; the storefront handles `/cart/link/<token>`, calls this on the
3367
+ * server (Server Action or route handler, so the session cookie can be
3368
+ * written) and redirects to checkout. Items are ADDED, never replacing the
3369
+ * cart; opening the link twice does not double quantities. A discount code
3370
+ * carried by the link is applied with the normal validation. An expired or
3371
+ * unknown link fails with `be.storefront.cartLinkExpired` (404).
3372
+ */
3373
+ claimLink(token: string): Promise<SdkResult<CartLinkClaimed>>;
3353
3374
  /** Remove discount code */
3354
3375
  removeDiscount(): Promise<SdkResult<Cart>>;
3355
3376
  }
@@ -3790,5 +3811,19 @@ declare class NewsletterModule {
3790
3811
  subscribe(input: NewsletterSubscribeInput): Promise<SdkResult<NewsletterSubscribeResult>>;
3791
3812
  unsubscribe(email: string): Promise<SdkResult<NewsletterUnsubscribeResult>>;
3792
3813
  }
3814
+ /** Souhrn kosiku pro skripty na strance (Behio Chat, analytika). */
3815
+ interface CartSummaryEvent {
3816
+ total: number;
3817
+ currency: string | null;
3818
+ itemCount: number;
3819
+ }
3820
+ /**
3821
+ * Vysle v prohlizeci udalost `behio:cart` ({total, currency, itemCount})
3822
+ * a ulozi ji do `window.__behioCart`. Posloucha ji Behio Chat (osloveni podle
3823
+ * hodnoty kosiku, promenne {cartTotal}). SDK ji vola samo po kazde odpovedi
3824
+ * kosiku v prohlizeci. Sablona, ktera kosik meni na serveru (Server Actions,
3825
+ * vlastni route), ji zavola sama s aktualnim souhrnem. Na serveru nedela nic.
3826
+ */
3827
+ declare function publishCartSummary(summary: CartSummaryEvent): void;
3793
3828
 
3794
- export { type CourseDetail as $, type ActivePromotion as A, BehioStorefront as B, type CookieConsent as C, type Cart as D, type CartBundleLine as E, type CartBundleLineItem as F, type CartDiscount as G, type CartItem as H, type CartItemProduct as I, type CartPromotion as J, type Category as K, type CategoryDetail as L, type CertificateVerification as M, type CheckoutAddress as N, type CheckoutInput as O, type ProductDetail as P, type CheckoutPaymentMethod as Q, type CheckoutPreview as R, type SdkResult as S, type CheckoutResult as T, type CheckoutSettings as U, type CookieConsentInput as V, type CourseAttachment as W, type CourseCertificate as X, type CourseComment as Y, type CourseCommentReply as Z, type CourseCommentsList as _, type ProductVariant as a, PaymentStatuses as a$, type CourseLesson as a0, type CourseListItem as a1, type CourseModule as a2, type CoursePostedComment as a3, type CourseProgress as a4, type CourseTutorMessage as a5, type CourseTutorThread as a6, type CrossSellItem as a7, type CurrencyDisplayFormat as a8, type CustomerAddress as a9, type LoyaltyTier as aA, type LoyaltyTierPerks as aB, type LoyaltyTransaction as aC, type Menu as aD, type MenuItem as aE, type MenuItemRef as aF, type MenuItemType as aG, type MessageResponse as aH, type NewsletterOptInDefault as aI, type NewsletterSubscribeInput as aJ, type NewsletterSubscribeResult as aK, type NewsletterUnsubscribeResult as aL, type OrderAccessRequestResponse as aM, type OrderAccessVerifyResponse as aN, type OrderDetail as aO, type OrderItem as aP, type OrderListItem as aQ, type OrderStatus as aR, type OrderStatusHistory as aS, OrderStatuses as aT, type OrderTracking as aU, type Page as aV, type PageAttachment as aW, type PageDetail as aX, type PaginatedResponse as aY, type PaymentInstrument as aZ, type PaymentStatus as a_, type CustomerProfile as aa, type DigitalDownload as ab, type DownloadUrl as ac, type Facet as ad, type FacetAvailability as ae, type FacetCategory as af, type FacetLabel as ag, type FacetPriceRange as ah, type FacetRange as ai, type FacetRatingBucket as aj, type FacetValue as ak, type FacetsResponse as al, type FilterField as am, type FulfillmentStatus as an, FulfillmentStatuses as ao, type GiftCardBalance as ap, type GiftCardPurchaseInput as aq, type GiftCardPurchaseResult as ar, type GiftCardSummary as as, type LessonNote as at, type LessonQuiz as au, type LoginInput as av, type LoyaltyBalance as aw, type LoyaltyNextTier as ax, type LoyaltyProgram as ay, type LoyaltySummary as az, type StorefrontFormFieldError as b, type StorefrontForm as b$, type PaymentSwift as b0, type PickupPoint as b1, type PickupPointHours as b2, type PickupPointsInput as b3, type PickupWidgetConfig as b4, type PriceDisplay as b5, type ProductAssetGroup as b6, type ProductAssetItem as b7, type ProductAvailability as b8, type ProductGroup as b9, type ResponseInterceptor as bA, type ResponseInterceptorData as bB, type ReturnRequest as bC, type ReturnRequestItem as bD, type ReturnStatus as bE, type ReturnStatusItem as bF, type ReturnableOrder as bG, type ReturnableOrderItem as bH, type SdkError as bI, type ShippingMethodSummary as bJ, type ShippingQuote as bK, type ShippingQuoteInput as bL, type ShopAppearance as bM, type ShopInfo as bN, type ShopScript as bO, type ShopScriptPlacement as bP, type ShopScriptType as bQ, type ShopScripts as bR, type ShopSeo as bS, type ShopSeoIdentity as bT, type SiteFormField as bU, type SiteFormFieldOption as bV, type SiteFormFieldType as bW, type Sitemap as bX, type SitemapEntry as bY, type StockBehavior as bZ, type StockMode as b_, type ProductLabel as ba, type ProductListItem as bb, type ProductMedia as bc, type ProductMediaVariant as bd, type ProductParameter as be, type ProductParameterGroup as bf, type ProductParametersResponse as bg, type ProductPrice as bh, type ProductPromotionSummary as bi, type ProductReview as bj, type ProductReviewsResponse as bk, type ProductSibling as bl, ProductSort as bm, type ProductSortValue as bn, type ProductVolumePrice as bo, type ProductsQuery as bp, type QuizAnswerInput as bq, type QuizAnswerResult as br, type QuizQuestion as bs, type QuizResult as bt, type QuoteItem as bu, type QuoteRequest as bv, type RegisterInput as bw, type RegisterResult as bx, type RequestInterceptor as by, type RequestInterceptorConfig as bz, type AddToCartInput as c, type StorefrontFormFieldErrorCode as c0, type StorefrontFormFile as c1, type StorefrontFormSettings as c2, type StorefrontFormSubmitInput as c3, type StorefrontFormSubmitResult as c4, type StorefrontFormUpload as c5, type SubmitQuoteInput as c6, type SubmitReturnInput as c7, type SubmitReviewInput as c8, type Subscription as c9, type SubscriptionAction as ca, type SubscriptionFrequency as cb, type SubscriptionItem as cc, type SubscriptionStatus as cd, type TaxBreakdownLine as ce, type VariantAxis as cf, type VariantAxisValue as cg, type WishlistItem as ch, err as ci, ok as cj, toSdkError as ck, type AddressDetail as d, type AddressSuggestion as e, type AddressType as f, AddressTypes as g, type AuthTokens as h, type BackInStockSubscription as i, type BadgeTone as j, BehioApiError as k, type BehioErrorCode as l, type BehioEventHandler as m, type BehioEventType as n, BehioNetworkError as o, type BehioStorefrontConfig as p, type Blog as q, type BlogPostDetail as r, type BlogPostListItem as s, type BlogPostsPage as t, type BlogPostsQuery as u, type BlogSettings as v, type BlogTag as w, type Bundle as x, type BundleCatalogQuery as y, type BundleItem as z };
3829
+ export { type CourseCommentReply as $, type ActivePromotion as A, BehioStorefront as B, type CookieConsent as C, type Cart as D, type CartBundleLine as E, type CartBundleLineItem as F, type CartDiscount as G, type CartItem as H, type CartItemProduct as I, type CartLinkClaimed as J, type CartPromotion as K, type CartSummaryEvent as L, type Category as M, type CategoryDetail as N, type CertificateVerification as O, type ProductDetail as P, type CheckoutAddress as Q, type CheckoutInput as R, type SdkResult as S, type CheckoutPaymentMethod as T, type CheckoutPreview as U, type CheckoutResult as V, type CheckoutSettings as W, type CookieConsentInput as X, type CourseAttachment as Y, type CourseCertificate as Z, type CourseComment as _, type ProductVariant as a, type PaymentInstrument as a$, type CourseCommentsList as a0, type CourseDetail as a1, type CourseLesson as a2, type CourseListItem as a3, type CourseModule as a4, type CoursePostedComment as a5, type CourseProgress as a6, type CourseTutorMessage as a7, type CourseTutorThread as a8, type CrossSellItem as a9, type LoyaltyProgram as aA, type LoyaltySummary as aB, type LoyaltyTier as aC, type LoyaltyTierPerks as aD, type LoyaltyTransaction as aE, type Menu as aF, type MenuItem as aG, type MenuItemRef as aH, type MenuItemType as aI, type MessageResponse as aJ, type NewsletterOptInDefault as aK, type NewsletterSubscribeInput as aL, type NewsletterSubscribeResult as aM, type NewsletterUnsubscribeResult as aN, type OrderAccessRequestResponse as aO, type OrderAccessVerifyResponse as aP, type OrderDetail as aQ, type OrderItem as aR, type OrderListItem as aS, type OrderStatus as aT, type OrderStatusHistory as aU, OrderStatuses as aV, type OrderTracking as aW, type Page as aX, type PageAttachment as aY, type PageDetail as aZ, type PaginatedResponse as a_, type CurrencyDisplayFormat as aa, type CustomerAddress as ab, type CustomerProfile as ac, type DigitalDownload as ad, type DownloadUrl as ae, type Facet as af, type FacetAvailability as ag, type FacetCategory as ah, type FacetLabel as ai, type FacetPriceRange as aj, type FacetRange as ak, type FacetRatingBucket as al, type FacetValue as am, type FacetsResponse as an, type FilterField as ao, type FulfillmentStatus as ap, FulfillmentStatuses as aq, type GiftCardBalance as ar, type GiftCardPurchaseInput as as, type GiftCardPurchaseResult as at, type GiftCardSummary as au, type LessonNote as av, type LessonQuiz as aw, type LoginInput as ax, type LoyaltyBalance as ay, type LoyaltyNextTier as az, type StorefrontFormFieldError as b, type StockBehavior as b$, type PaymentStatus as b0, PaymentStatuses as b1, type PaymentSwift as b2, type PickupPoint as b3, type PickupPointHours as b4, type PickupPointsInput as b5, type PickupWidgetConfig as b6, type PriceDisplay as b7, type ProductAssetGroup as b8, type ProductAssetItem as b9, type RequestInterceptor as bA, type RequestInterceptorConfig as bB, type ResponseInterceptor as bC, type ResponseInterceptorData as bD, type ReturnRequest as bE, type ReturnRequestItem as bF, type ReturnStatus as bG, type ReturnStatusItem as bH, type ReturnableOrder as bI, type ReturnableOrderItem as bJ, type SdkError as bK, type ShippingMethodSummary as bL, type ShippingQuote as bM, type ShippingQuoteInput as bN, type ShopAppearance as bO, type ShopInfo as bP, type ShopScript as bQ, type ShopScriptPlacement as bR, type ShopScriptType as bS, type ShopScripts as bT, type ShopSeo as bU, type ShopSeoIdentity as bV, type SiteFormField as bW, type SiteFormFieldOption as bX, type SiteFormFieldType as bY, type Sitemap as bZ, type SitemapEntry as b_, type ProductAvailability as ba, type ProductGroup as bb, type ProductLabel as bc, type ProductListItem as bd, type ProductMedia as be, type ProductMediaVariant as bf, type ProductParameter as bg, type ProductParameterGroup as bh, type ProductParametersResponse as bi, type ProductPrice as bj, type ProductPromotionSummary as bk, type ProductReview as bl, type ProductReviewsResponse as bm, type ProductSibling as bn, ProductSort as bo, type ProductSortValue as bp, type ProductVolumePrice as bq, type ProductsQuery as br, type QuizAnswerInput as bs, type QuizAnswerResult as bt, type QuizQuestion as bu, type QuizResult as bv, type QuoteItem as bw, type QuoteRequest as bx, type RegisterInput as by, type RegisterResult as bz, type AddToCartInput as c, type StockMode as c0, type StorefrontForm as c1, type StorefrontFormFieldErrorCode as c2, type StorefrontFormFile as c3, type StorefrontFormSettings as c4, type StorefrontFormSubmitInput as c5, type StorefrontFormSubmitResult as c6, type StorefrontFormUpload as c7, type SubmitQuoteInput as c8, type SubmitReturnInput as c9, type SubmitReviewInput as ca, type Subscription as cb, type SubscriptionAction as cc, type SubscriptionFrequency as cd, type SubscriptionItem as ce, type SubscriptionStatus as cf, type TaxBreakdownLine as cg, type VariantAxis as ch, type VariantAxisValue as ci, type WishlistItem as cj, err as ck, ok as cl, publishCartSummary as cm, toSdkError as cn, type AddressDetail as d, type AddressSuggestion as e, type AddressType as f, AddressTypes as g, type AuthTokens as h, type BackInStockSubscription as i, type BadgeTone as j, BehioApiError as k, type BehioErrorCode as l, type BehioEventHandler as m, type BehioEventType as n, BehioNetworkError as o, type BehioStorefrontConfig as p, type Blog as q, type BlogPostDetail as r, type BlogPostListItem as s, type BlogPostsPage as t, type BlogPostsQuery as u, type BlogSettings as v, type BlogTag as w, type Bundle as x, type BundleCatalogQuery as y, type BundleItem as z };
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { P as ProductDetail, a as ProductVariant, B as BehioStorefront, S as SdkResult, C as CookieConsent, b as StorefrontFormFieldError } from './client-BhdlZIGe.mjs';
2
- export { A as ActivePromotion, c as AddToCartInput, d as AddressDetail, e as AddressSuggestion, f as AddressType, g as AddressTypes, h as AuthTokens, i as BackInStockSubscription, j as BadgeTone, k as BehioApiError, l as BehioErrorCode, m as BehioEventHandler, n as BehioEventType, o as BehioNetworkError, p as BehioStorefrontConfig, q as Blog, r as BlogPostDetail, s as BlogPostListItem, t as BlogPostsPage, u as BlogPostsQuery, v as BlogSettings, w as BlogTag, x as Bundle, y as BundleCatalogQuery, z as BundleItem, D as Cart, E as CartBundleLine, F as CartBundleLineItem, G as CartDiscount, H as CartItem, I as CartItemProduct, J as CartPromotion, K as Category, L as CategoryDetail, M as CertificateVerification, N as CheckoutAddress, O as CheckoutInput, Q as CheckoutPaymentMethod, R as CheckoutPreview, T as CheckoutResult, U as CheckoutSettings, V as CookieConsentInput, W as CourseAttachment, X as CourseCertificate, Y as CourseComment, Z as CourseCommentReply, _ as CourseCommentsList, $ as CourseDetail, a0 as CourseLesson, a1 as CourseListItem, a2 as CourseModule, a3 as CoursePostedComment, a4 as CourseProgress, a5 as CourseTutorMessage, a6 as CourseTutorThread, a7 as CrossSellItem, a8 as CurrencyDisplayFormat, a9 as CustomerAddress, aa as CustomerProfile, ab as DigitalDownload, ac as DownloadUrl, ad as Facet, ae as FacetAvailability, af as FacetCategory, ag as FacetLabel, ah as FacetPriceRange, ai as FacetRange, aj as FacetRatingBucket, ak as FacetValue, al as FacetsResponse, am as FilterField, an as FulfillmentStatus, ao as FulfillmentStatuses, ap as GiftCardBalance, aq as GiftCardPurchaseInput, ar as GiftCardPurchaseResult, as as GiftCardSummary, at as LessonNote, au as LessonQuiz, av as LoginInput, aw as LoyaltyBalance, ax as LoyaltyNextTier, ay as LoyaltyProgram, az as LoyaltySummary, aA as LoyaltyTier, aB as LoyaltyTierPerks, aC as LoyaltyTransaction, aD as Menu, aE as MenuItem, aF as MenuItemRef, aG as MenuItemType, aH as MessageResponse, aI as NewsletterOptInDefault, aJ as NewsletterSubscribeInput, aK as NewsletterSubscribeResult, aL as NewsletterUnsubscribeResult, aM as OrderAccessRequestResponse, aN as OrderAccessVerifyResponse, aO as OrderDetail, aP as OrderItem, aQ as OrderListItem, aR as OrderStatus, aS as OrderStatusHistory, aT as OrderStatuses, aU as OrderTracking, aV as Page, aW as PageAttachment, aX as PageDetail, aY as PaginatedResponse, aZ as PaymentInstrument, a_ as PaymentStatus, a$ as PaymentStatuses, b0 as PaymentSwift, b1 as PickupPoint, b2 as PickupPointHours, b3 as PickupPointsInput, b4 as PickupWidgetConfig, b5 as PriceDisplay, b6 as ProductAssetGroup, b7 as ProductAssetItem, b8 as ProductAvailability, b9 as ProductGroup, ba as ProductLabel, bb as ProductListItem, bc as ProductMedia, bd as ProductMediaVariant, be as ProductParameter, bf as ProductParameterGroup, bg as ProductParametersResponse, bh as ProductPrice, bi as ProductPromotionSummary, bj as ProductReview, bk as ProductReviewsResponse, bl as ProductSibling, bm as ProductSort, bn as ProductSortValue, bo as ProductVolumePrice, bp as ProductsQuery, bq as QuizAnswerInput, br as QuizAnswerResult, bs as QuizQuestion, bt as QuizResult, bu as QuoteItem, bv as QuoteRequest, bw as RegisterInput, bx as RegisterResult, by as RequestInterceptor, bz as RequestInterceptorConfig, bA as ResponseInterceptor, bB as ResponseInterceptorData, bC as ReturnRequest, bD as ReturnRequestItem, bE as ReturnStatus, bF as ReturnStatusItem, bG as ReturnableOrder, bH as ReturnableOrderItem, bI as SdkError, bJ as ShippingMethodSummary, bK as ShippingQuote, bL as ShippingQuoteInput, bM as ShopAppearance, bN as ShopInfo, bO as ShopScript, bP as ShopScriptPlacement, bQ as ShopScriptType, bR as ShopScripts, bS as ShopSeo, bT as ShopSeoIdentity, bU as SiteFormField, bV as SiteFormFieldOption, bW as SiteFormFieldType, bX as Sitemap, bY as SitemapEntry, bZ as StockBehavior, b_ as StockMode, b$ as StorefrontForm, c0 as StorefrontFormFieldErrorCode, c1 as StorefrontFormFile, c2 as StorefrontFormSettings, c3 as StorefrontFormSubmitInput, c4 as StorefrontFormSubmitResult, c5 as StorefrontFormUpload, c6 as SubmitQuoteInput, c7 as SubmitReturnInput, c8 as SubmitReviewInput, c9 as Subscription, ca as SubscriptionAction, cb as SubscriptionFrequency, cc as SubscriptionItem, cd as SubscriptionStatus, ce as TaxBreakdownLine, cf as VariantAxis, cg as VariantAxisValue, ch as WishlistItem, ci as err, cj as ok, ck as toSdkError } from './client-BhdlZIGe.mjs';
1
+ import { P as ProductDetail, a as ProductVariant, B as BehioStorefront, S as SdkResult, C as CookieConsent, b as StorefrontFormFieldError } from './client-udU7tGhi.mjs';
2
+ export { A as ActivePromotion, c as AddToCartInput, d as AddressDetail, e as AddressSuggestion, f as AddressType, g as AddressTypes, h as AuthTokens, i as BackInStockSubscription, j as BadgeTone, k as BehioApiError, l as BehioErrorCode, m as BehioEventHandler, n as BehioEventType, o as BehioNetworkError, p as BehioStorefrontConfig, q as Blog, r as BlogPostDetail, s as BlogPostListItem, t as BlogPostsPage, u as BlogPostsQuery, v as BlogSettings, w as BlogTag, x as Bundle, y as BundleCatalogQuery, z as BundleItem, D as Cart, E as CartBundleLine, F as CartBundleLineItem, G as CartDiscount, H as CartItem, I as CartItemProduct, J as CartLinkClaimed, K as CartPromotion, L as CartSummaryEvent, M as Category, N as CategoryDetail, O as CertificateVerification, Q as CheckoutAddress, R as CheckoutInput, T as CheckoutPaymentMethod, U as CheckoutPreview, V as CheckoutResult, W as CheckoutSettings, X as CookieConsentInput, Y as CourseAttachment, Z as CourseCertificate, _ as CourseComment, $ as CourseCommentReply, a0 as CourseCommentsList, a1 as CourseDetail, a2 as CourseLesson, a3 as CourseListItem, a4 as CourseModule, a5 as CoursePostedComment, a6 as CourseProgress, a7 as CourseTutorMessage, a8 as CourseTutorThread, a9 as CrossSellItem, aa as CurrencyDisplayFormat, ab as CustomerAddress, ac as CustomerProfile, ad as DigitalDownload, ae as DownloadUrl, af as Facet, ag as FacetAvailability, ah as FacetCategory, ai as FacetLabel, aj as FacetPriceRange, ak as FacetRange, al as FacetRatingBucket, am as FacetValue, an as FacetsResponse, ao as FilterField, ap as FulfillmentStatus, aq as FulfillmentStatuses, ar as GiftCardBalance, as as GiftCardPurchaseInput, at as GiftCardPurchaseResult, au as GiftCardSummary, av as LessonNote, aw as LessonQuiz, ax as LoginInput, ay as LoyaltyBalance, az as LoyaltyNextTier, aA as LoyaltyProgram, aB as LoyaltySummary, aC as LoyaltyTier, aD as LoyaltyTierPerks, aE as LoyaltyTransaction, aF as Menu, aG as MenuItem, aH as MenuItemRef, aI as MenuItemType, aJ as MessageResponse, aK as NewsletterOptInDefault, aL as NewsletterSubscribeInput, aM as NewsletterSubscribeResult, aN as NewsletterUnsubscribeResult, aO as OrderAccessRequestResponse, aP as OrderAccessVerifyResponse, aQ as OrderDetail, aR as OrderItem, aS as OrderListItem, aT as OrderStatus, aU as OrderStatusHistory, aV as OrderStatuses, aW as OrderTracking, aX as Page, aY as PageAttachment, aZ as PageDetail, a_ as PaginatedResponse, a$ as PaymentInstrument, b0 as PaymentStatus, b1 as PaymentStatuses, b2 as PaymentSwift, b3 as PickupPoint, b4 as PickupPointHours, b5 as PickupPointsInput, b6 as PickupWidgetConfig, b7 as PriceDisplay, b8 as ProductAssetGroup, b9 as ProductAssetItem, ba as ProductAvailability, bb as ProductGroup, bc as ProductLabel, bd as ProductListItem, be as ProductMedia, bf as ProductMediaVariant, bg as ProductParameter, bh as ProductParameterGroup, bi as ProductParametersResponse, bj as ProductPrice, bk as ProductPromotionSummary, bl as ProductReview, bm as ProductReviewsResponse, bn as ProductSibling, bo as ProductSort, bp as ProductSortValue, bq as ProductVolumePrice, br as ProductsQuery, bs as QuizAnswerInput, bt as QuizAnswerResult, bu as QuizQuestion, bv as QuizResult, bw as QuoteItem, bx as QuoteRequest, by as RegisterInput, bz as RegisterResult, bA as RequestInterceptor, bB as RequestInterceptorConfig, bC as ResponseInterceptor, bD as ResponseInterceptorData, bE as ReturnRequest, bF as ReturnRequestItem, bG as ReturnStatus, bH as ReturnStatusItem, bI as ReturnableOrder, bJ as ReturnableOrderItem, bK as SdkError, bL as ShippingMethodSummary, bM as ShippingQuote, bN as ShippingQuoteInput, bO as ShopAppearance, bP as ShopInfo, bQ as ShopScript, bR as ShopScriptPlacement, bS as ShopScriptType, bT as ShopScripts, bU as ShopSeo, bV as ShopSeoIdentity, bW as SiteFormField, bX as SiteFormFieldOption, bY as SiteFormFieldType, bZ as Sitemap, b_ as SitemapEntry, b$ as StockBehavior, c0 as StockMode, c1 as StorefrontForm, c2 as StorefrontFormFieldErrorCode, c3 as StorefrontFormFile, c4 as StorefrontFormSettings, c5 as StorefrontFormSubmitInput, c6 as StorefrontFormSubmitResult, c7 as StorefrontFormUpload, c8 as SubmitQuoteInput, c9 as SubmitReturnInput, ca as SubmitReviewInput, cb as Subscription, cc as SubscriptionAction, cd as SubscriptionFrequency, ce as SubscriptionItem, cf as SubscriptionStatus, cg as TaxBreakdownLine, ch as VariantAxis, ci as VariantAxisValue, cj as WishlistItem, ck as err, cl as ok, cm as publishCartSummary, cn as toSdkError } from './client-udU7tGhi.mjs';
3
3
 
4
4
  /**
5
5
  * Format a price amount with currency using Intl.NumberFormat.
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { P as ProductDetail, a as ProductVariant, B as BehioStorefront, S as SdkResult, C as CookieConsent, b as StorefrontFormFieldError } from './client-BhdlZIGe.js';
2
- export { A as ActivePromotion, c as AddToCartInput, d as AddressDetail, e as AddressSuggestion, f as AddressType, g as AddressTypes, h as AuthTokens, i as BackInStockSubscription, j as BadgeTone, k as BehioApiError, l as BehioErrorCode, m as BehioEventHandler, n as BehioEventType, o as BehioNetworkError, p as BehioStorefrontConfig, q as Blog, r as BlogPostDetail, s as BlogPostListItem, t as BlogPostsPage, u as BlogPostsQuery, v as BlogSettings, w as BlogTag, x as Bundle, y as BundleCatalogQuery, z as BundleItem, D as Cart, E as CartBundleLine, F as CartBundleLineItem, G as CartDiscount, H as CartItem, I as CartItemProduct, J as CartPromotion, K as Category, L as CategoryDetail, M as CertificateVerification, N as CheckoutAddress, O as CheckoutInput, Q as CheckoutPaymentMethod, R as CheckoutPreview, T as CheckoutResult, U as CheckoutSettings, V as CookieConsentInput, W as CourseAttachment, X as CourseCertificate, Y as CourseComment, Z as CourseCommentReply, _ as CourseCommentsList, $ as CourseDetail, a0 as CourseLesson, a1 as CourseListItem, a2 as CourseModule, a3 as CoursePostedComment, a4 as CourseProgress, a5 as CourseTutorMessage, a6 as CourseTutorThread, a7 as CrossSellItem, a8 as CurrencyDisplayFormat, a9 as CustomerAddress, aa as CustomerProfile, ab as DigitalDownload, ac as DownloadUrl, ad as Facet, ae as FacetAvailability, af as FacetCategory, ag as FacetLabel, ah as FacetPriceRange, ai as FacetRange, aj as FacetRatingBucket, ak as FacetValue, al as FacetsResponse, am as FilterField, an as FulfillmentStatus, ao as FulfillmentStatuses, ap as GiftCardBalance, aq as GiftCardPurchaseInput, ar as GiftCardPurchaseResult, as as GiftCardSummary, at as LessonNote, au as LessonQuiz, av as LoginInput, aw as LoyaltyBalance, ax as LoyaltyNextTier, ay as LoyaltyProgram, az as LoyaltySummary, aA as LoyaltyTier, aB as LoyaltyTierPerks, aC as LoyaltyTransaction, aD as Menu, aE as MenuItem, aF as MenuItemRef, aG as MenuItemType, aH as MessageResponse, aI as NewsletterOptInDefault, aJ as NewsletterSubscribeInput, aK as NewsletterSubscribeResult, aL as NewsletterUnsubscribeResult, aM as OrderAccessRequestResponse, aN as OrderAccessVerifyResponse, aO as OrderDetail, aP as OrderItem, aQ as OrderListItem, aR as OrderStatus, aS as OrderStatusHistory, aT as OrderStatuses, aU as OrderTracking, aV as Page, aW as PageAttachment, aX as PageDetail, aY as PaginatedResponse, aZ as PaymentInstrument, a_ as PaymentStatus, a$ as PaymentStatuses, b0 as PaymentSwift, b1 as PickupPoint, b2 as PickupPointHours, b3 as PickupPointsInput, b4 as PickupWidgetConfig, b5 as PriceDisplay, b6 as ProductAssetGroup, b7 as ProductAssetItem, b8 as ProductAvailability, b9 as ProductGroup, ba as ProductLabel, bb as ProductListItem, bc as ProductMedia, bd as ProductMediaVariant, be as ProductParameter, bf as ProductParameterGroup, bg as ProductParametersResponse, bh as ProductPrice, bi as ProductPromotionSummary, bj as ProductReview, bk as ProductReviewsResponse, bl as ProductSibling, bm as ProductSort, bn as ProductSortValue, bo as ProductVolumePrice, bp as ProductsQuery, bq as QuizAnswerInput, br as QuizAnswerResult, bs as QuizQuestion, bt as QuizResult, bu as QuoteItem, bv as QuoteRequest, bw as RegisterInput, bx as RegisterResult, by as RequestInterceptor, bz as RequestInterceptorConfig, bA as ResponseInterceptor, bB as ResponseInterceptorData, bC as ReturnRequest, bD as ReturnRequestItem, bE as ReturnStatus, bF as ReturnStatusItem, bG as ReturnableOrder, bH as ReturnableOrderItem, bI as SdkError, bJ as ShippingMethodSummary, bK as ShippingQuote, bL as ShippingQuoteInput, bM as ShopAppearance, bN as ShopInfo, bO as ShopScript, bP as ShopScriptPlacement, bQ as ShopScriptType, bR as ShopScripts, bS as ShopSeo, bT as ShopSeoIdentity, bU as SiteFormField, bV as SiteFormFieldOption, bW as SiteFormFieldType, bX as Sitemap, bY as SitemapEntry, bZ as StockBehavior, b_ as StockMode, b$ as StorefrontForm, c0 as StorefrontFormFieldErrorCode, c1 as StorefrontFormFile, c2 as StorefrontFormSettings, c3 as StorefrontFormSubmitInput, c4 as StorefrontFormSubmitResult, c5 as StorefrontFormUpload, c6 as SubmitQuoteInput, c7 as SubmitReturnInput, c8 as SubmitReviewInput, c9 as Subscription, ca as SubscriptionAction, cb as SubscriptionFrequency, cc as SubscriptionItem, cd as SubscriptionStatus, ce as TaxBreakdownLine, cf as VariantAxis, cg as VariantAxisValue, ch as WishlistItem, ci as err, cj as ok, ck as toSdkError } from './client-BhdlZIGe.js';
1
+ import { P as ProductDetail, a as ProductVariant, B as BehioStorefront, S as SdkResult, C as CookieConsent, b as StorefrontFormFieldError } from './client-udU7tGhi.js';
2
+ export { A as ActivePromotion, c as AddToCartInput, d as AddressDetail, e as AddressSuggestion, f as AddressType, g as AddressTypes, h as AuthTokens, i as BackInStockSubscription, j as BadgeTone, k as BehioApiError, l as BehioErrorCode, m as BehioEventHandler, n as BehioEventType, o as BehioNetworkError, p as BehioStorefrontConfig, q as Blog, r as BlogPostDetail, s as BlogPostListItem, t as BlogPostsPage, u as BlogPostsQuery, v as BlogSettings, w as BlogTag, x as Bundle, y as BundleCatalogQuery, z as BundleItem, D as Cart, E as CartBundleLine, F as CartBundleLineItem, G as CartDiscount, H as CartItem, I as CartItemProduct, J as CartLinkClaimed, K as CartPromotion, L as CartSummaryEvent, M as Category, N as CategoryDetail, O as CertificateVerification, Q as CheckoutAddress, R as CheckoutInput, T as CheckoutPaymentMethod, U as CheckoutPreview, V as CheckoutResult, W as CheckoutSettings, X as CookieConsentInput, Y as CourseAttachment, Z as CourseCertificate, _ as CourseComment, $ as CourseCommentReply, a0 as CourseCommentsList, a1 as CourseDetail, a2 as CourseLesson, a3 as CourseListItem, a4 as CourseModule, a5 as CoursePostedComment, a6 as CourseProgress, a7 as CourseTutorMessage, a8 as CourseTutorThread, a9 as CrossSellItem, aa as CurrencyDisplayFormat, ab as CustomerAddress, ac as CustomerProfile, ad as DigitalDownload, ae as DownloadUrl, af as Facet, ag as FacetAvailability, ah as FacetCategory, ai as FacetLabel, aj as FacetPriceRange, ak as FacetRange, al as FacetRatingBucket, am as FacetValue, an as FacetsResponse, ao as FilterField, ap as FulfillmentStatus, aq as FulfillmentStatuses, ar as GiftCardBalance, as as GiftCardPurchaseInput, at as GiftCardPurchaseResult, au as GiftCardSummary, av as LessonNote, aw as LessonQuiz, ax as LoginInput, ay as LoyaltyBalance, az as LoyaltyNextTier, aA as LoyaltyProgram, aB as LoyaltySummary, aC as LoyaltyTier, aD as LoyaltyTierPerks, aE as LoyaltyTransaction, aF as Menu, aG as MenuItem, aH as MenuItemRef, aI as MenuItemType, aJ as MessageResponse, aK as NewsletterOptInDefault, aL as NewsletterSubscribeInput, aM as NewsletterSubscribeResult, aN as NewsletterUnsubscribeResult, aO as OrderAccessRequestResponse, aP as OrderAccessVerifyResponse, aQ as OrderDetail, aR as OrderItem, aS as OrderListItem, aT as OrderStatus, aU as OrderStatusHistory, aV as OrderStatuses, aW as OrderTracking, aX as Page, aY as PageAttachment, aZ as PageDetail, a_ as PaginatedResponse, a$ as PaymentInstrument, b0 as PaymentStatus, b1 as PaymentStatuses, b2 as PaymentSwift, b3 as PickupPoint, b4 as PickupPointHours, b5 as PickupPointsInput, b6 as PickupWidgetConfig, b7 as PriceDisplay, b8 as ProductAssetGroup, b9 as ProductAssetItem, ba as ProductAvailability, bb as ProductGroup, bc as ProductLabel, bd as ProductListItem, be as ProductMedia, bf as ProductMediaVariant, bg as ProductParameter, bh as ProductParameterGroup, bi as ProductParametersResponse, bj as ProductPrice, bk as ProductPromotionSummary, bl as ProductReview, bm as ProductReviewsResponse, bn as ProductSibling, bo as ProductSort, bp as ProductSortValue, bq as ProductVolumePrice, br as ProductsQuery, bs as QuizAnswerInput, bt as QuizAnswerResult, bu as QuizQuestion, bv as QuizResult, bw as QuoteItem, bx as QuoteRequest, by as RegisterInput, bz as RegisterResult, bA as RequestInterceptor, bB as RequestInterceptorConfig, bC as ResponseInterceptor, bD as ResponseInterceptorData, bE as ReturnRequest, bF as ReturnRequestItem, bG as ReturnStatus, bH as ReturnStatusItem, bI as ReturnableOrder, bJ as ReturnableOrderItem, bK as SdkError, bL as ShippingMethodSummary, bM as ShippingQuote, bN as ShippingQuoteInput, bO as ShopAppearance, bP as ShopInfo, bQ as ShopScript, bR as ShopScriptPlacement, bS as ShopScriptType, bT as ShopScripts, bU as ShopSeo, bV as ShopSeoIdentity, bW as SiteFormField, bX as SiteFormFieldOption, bY as SiteFormFieldType, bZ as Sitemap, b_ as SitemapEntry, b$ as StockBehavior, c0 as StockMode, c1 as StorefrontForm, c2 as StorefrontFormFieldErrorCode, c3 as StorefrontFormFile, c4 as StorefrontFormSettings, c5 as StorefrontFormSubmitInput, c6 as StorefrontFormSubmitResult, c7 as StorefrontFormUpload, c8 as SubmitQuoteInput, c9 as SubmitReturnInput, ca as SubmitReviewInput, cb as Subscription, cc as SubscriptionAction, cd as SubscriptionFrequency, ce as SubscriptionItem, cf as SubscriptionStatus, cg as TaxBreakdownLine, ch as VariantAxis, ci as VariantAxisValue, cj as WishlistItem, ck as err, cl as ok, cm as publishCartSummary, cn as toSdkError } from './client-udU7tGhi.js';
3
3
 
4
4
  /**
5
5
  * Format a price amount with currency using Intl.NumberFormat.
package/dist/index.js CHANGED
@@ -10,7 +10,8 @@
10
10
 
11
11
 
12
12
 
13
- var _chunkPUAQHLBVjs = require('./chunk-PUAQHLBV.js');
13
+
14
+ var _chunkXVKKDVOOjs = require('./chunk-XVKKDVOO.js');
14
15
 
15
16
  // src/react/utils/format-price.ts
16
17
  function formatPrice(amount, currency, locale, display) {
@@ -948,7 +949,7 @@ var GENERIC = {
948
949
  en: "Something went wrong, please try again."
949
950
  };
950
951
  function bodyOf(err2) {
951
- const body = err2 instanceof _chunkPUAQHLBVjs.BehioApiError ? err2.body : err2 && typeof err2 === "object" && "body" in err2 ? err2.body : err2;
952
+ const body = err2 instanceof _chunkXVKKDVOOjs.BehioApiError ? err2.body : err2 && typeof err2 === "object" && "body" in err2 ? err2.body : err2;
952
953
  return body && typeof body === "object" ? body : null;
953
954
  }
954
955
  function errorCode(err2) {
@@ -1060,4 +1061,5 @@ function formFieldErrors(err2) {
1060
1061
 
1061
1062
 
1062
1063
 
1063
- exports.AddressTypes = _chunkPUAQHLBVjs.AddressTypes; exports.BehioApiError = _chunkPUAQHLBVjs.BehioApiError; exports.BehioNetworkError = _chunkPUAQHLBVjs.BehioNetworkError; exports.BehioStorefront = _chunkPUAQHLBVjs.BehioStorefront; exports.FulfillmentStatuses = _chunkPUAQHLBVjs.FulfillmentStatuses; exports.OrderStatuses = _chunkPUAQHLBVjs.OrderStatuses; exports.PaymentStatuses = _chunkPUAQHLBVjs.PaymentStatuses; exports.ProductSort = _chunkPUAQHLBVjs.ProductSort; exports.VARIANT_QUERY_PARAM = VARIANT_QUERY_PARAM; exports.availableAxisValues = availableAxisValues; exports.buildVariantComparison = buildVariantComparison; exports.err = _chunkPUAQHLBVjs.err; exports.errorCode = errorCode; exports.errorMessage = errorMessage; exports.errorParams = errorParams; exports.findVariantByAttributes = findVariantByAttributes; exports.formFieldErrors = formFieldErrors; exports.formatPrice = formatPrice; exports.generateVisitorId = generateVisitorId; exports.getStoredVisitorId = getStoredVisitorId; exports.grantAnalyticsConsent = grantAnalyticsConsent; exports.ok = _chunkPUAQHLBVjs.ok; exports.resolveVariantContent = resolveVariantContent; exports.revokeAnalyticsConsent = revokeAnalyticsConsent; exports.toSdkError = _chunkPUAQHLBVjs.toSdkError; exports.trackEcommerceEvent = trackEcommerceEvent; exports.validationFieldMessages = validationFieldMessages; exports.variantFromQuery = variantFromQuery; exports.variantHref = variantHref;
1064
+
1065
+ exports.AddressTypes = _chunkXVKKDVOOjs.AddressTypes; exports.BehioApiError = _chunkXVKKDVOOjs.BehioApiError; exports.BehioNetworkError = _chunkXVKKDVOOjs.BehioNetworkError; exports.BehioStorefront = _chunkXVKKDVOOjs.BehioStorefront; exports.FulfillmentStatuses = _chunkXVKKDVOOjs.FulfillmentStatuses; exports.OrderStatuses = _chunkXVKKDVOOjs.OrderStatuses; exports.PaymentStatuses = _chunkXVKKDVOOjs.PaymentStatuses; exports.ProductSort = _chunkXVKKDVOOjs.ProductSort; exports.VARIANT_QUERY_PARAM = VARIANT_QUERY_PARAM; exports.availableAxisValues = availableAxisValues; exports.buildVariantComparison = buildVariantComparison; exports.err = _chunkXVKKDVOOjs.err; exports.errorCode = errorCode; exports.errorMessage = errorMessage; exports.errorParams = errorParams; exports.findVariantByAttributes = findVariantByAttributes; exports.formFieldErrors = formFieldErrors; exports.formatPrice = formatPrice; exports.generateVisitorId = generateVisitorId; exports.getStoredVisitorId = getStoredVisitorId; exports.grantAnalyticsConsent = grantAnalyticsConsent; exports.ok = _chunkXVKKDVOOjs.ok; exports.publishCartSummary = _chunkXVKKDVOOjs.publishCartSummary; exports.resolveVariantContent = resolveVariantContent; exports.revokeAnalyticsConsent = revokeAnalyticsConsent; exports.toSdkError = _chunkXVKKDVOOjs.toSdkError; exports.trackEcommerceEvent = trackEcommerceEvent; exports.validationFieldMessages = validationFieldMessages; exports.variantFromQuery = variantFromQuery; exports.variantHref = variantHref;
package/dist/index.mjs CHANGED
@@ -9,8 +9,9 @@ import {
9
9
  ProductSort,
10
10
  err,
11
11
  ok,
12
+ publishCartSummary,
12
13
  toSdkError
13
- } from "./chunk-5C43BIAZ.mjs";
14
+ } from "./chunk-5WHX5QA4.mjs";
14
15
 
15
16
  // src/react/utils/format-price.ts
16
17
  function formatPrice(amount, currency, locale, display) {
@@ -1053,6 +1054,7 @@ export {
1053
1054
  getStoredVisitorId,
1054
1055
  grantAnalyticsConsent,
1055
1056
  ok,
1057
+ publishCartSummary,
1056
1058
  resolveVariantContent,
1057
1059
  revokeAnalyticsConsent,
1058
1060
  toSdkError,
package/dist/next.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { p as BehioStorefrontConfig, B as BehioStorefront } from './client-BhdlZIGe.mjs';
1
+ import { p as BehioStorefrontConfig, B as BehioStorefront } from './client-udU7tGhi.mjs';
2
2
 
3
3
  interface GetBehioOptions extends Partial<BehioStorefrontConfig> {
4
4
  /** Override the cart session cookie name (default: "behio_cart_session"). */
package/dist/next.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { p as BehioStorefrontConfig, B as BehioStorefront } from './client-BhdlZIGe.js';
1
+ import { p as BehioStorefrontConfig, B as BehioStorefront } from './client-udU7tGhi.js';
2
2
 
3
3
  interface GetBehioOptions extends Partial<BehioStorefrontConfig> {
4
4
  /** Override the cart session cookie name (default: "behio_cart_session"). */
package/dist/next.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
2
 
3
- var _chunkPUAQHLBVjs = require('./chunk-PUAQHLBV.js');
3
+ var _chunkXVKKDVOOjs = require('./chunk-XVKKDVOO.js');
4
4
 
5
5
  // src/next.ts
6
6
  var _headers = require('next/headers');
@@ -19,7 +19,7 @@ async function getBehio(options = {}) {
19
19
  const locale = _nullishCoalesce(options.locale, () => ( process.env.BEHIO_LOCALE));
20
20
  const currency = _nullishCoalesce(options.currency, () => ( process.env.BEHIO_CURRENCY));
21
21
  const cookieName = _nullishCoalesce(options.cartCookieName, () => ( CART_COOKIE_NAME));
22
- const client = new (0, _chunkPUAQHLBVjs.BehioStorefront)({
22
+ const client = new (0, _chunkXVKKDVOOjs.BehioStorefront)({
23
23
  apiKey,
24
24
  ...baseUrl ? { baseUrl } : {},
25
25
  ...locale ? { locale } : {},
package/dist/next.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  BehioStorefront
3
- } from "./chunk-5C43BIAZ.mjs";
3
+ } from "./chunk-5WHX5QA4.mjs";
4
4
 
5
5
  // src/next.ts
6
6
  import { cookies, headers } from "next/headers";
package/dist/react.d.mts CHANGED
@@ -2862,6 +2862,16 @@ interface Sitemap {
2862
2862
  categories: SitemapEntry[];
2863
2863
  pages: SitemapEntry[];
2864
2864
  }
2865
+ /** Result of `cart.claimLink(token)`: the updated cart plus what the link did. */
2866
+ interface CartLinkClaimed extends Cart {
2867
+ /** New anonymous cart session (the SDK stores it automatically). */
2868
+ newSessionToken?: string;
2869
+ /** Products from the link that can no longer be bought and were skipped. */
2870
+ linkSkippedItems: number;
2871
+ /** A discount code carried by the link was applied. */
2872
+ linkDiscountApplied: boolean;
2873
+ linkDiscountCode: string | null;
2874
+ }
2865
2875
 
2866
2876
  declare class BehioStorefront {
2867
2877
  private baseUrl;
@@ -3360,6 +3370,17 @@ declare class CartModule {
3360
3370
  merge(): Promise<SdkResult<Cart>>;
3361
3371
  /** Apply discount code */
3362
3372
  applyDiscount(code: string): Promise<SdkResult<Cart>>;
3373
+ /**
3374
+ * Add the products of a prepared cart link to the visitor's cart (SDK 2.4).
3375
+ * Behio Chat creates these links when the AI assembles a cart for the
3376
+ * visitor; the storefront handles `/cart/link/<token>`, calls this on the
3377
+ * server (Server Action or route handler, so the session cookie can be
3378
+ * written) and redirects to checkout. Items are ADDED, never replacing the
3379
+ * cart; opening the link twice does not double quantities. A discount code
3380
+ * carried by the link is applied with the normal validation. An expired or
3381
+ * unknown link fails with `be.storefront.cartLinkExpired` (404).
3382
+ */
3383
+ claimLink(token: string): Promise<SdkResult<CartLinkClaimed>>;
3363
3384
  /** Remove discount code */
3364
3385
  removeDiscount(): Promise<SdkResult<Cart>>;
3365
3386
  }
package/dist/react.d.ts CHANGED
@@ -2862,6 +2862,16 @@ interface Sitemap {
2862
2862
  categories: SitemapEntry[];
2863
2863
  pages: SitemapEntry[];
2864
2864
  }
2865
+ /** Result of `cart.claimLink(token)`: the updated cart plus what the link did. */
2866
+ interface CartLinkClaimed extends Cart {
2867
+ /** New anonymous cart session (the SDK stores it automatically). */
2868
+ newSessionToken?: string;
2869
+ /** Products from the link that can no longer be bought and were skipped. */
2870
+ linkSkippedItems: number;
2871
+ /** A discount code carried by the link was applied. */
2872
+ linkDiscountApplied: boolean;
2873
+ linkDiscountCode: string | null;
2874
+ }
2865
2875
 
2866
2876
  declare class BehioStorefront {
2867
2877
  private baseUrl;
@@ -3360,6 +3370,17 @@ declare class CartModule {
3360
3370
  merge(): Promise<SdkResult<Cart>>;
3361
3371
  /** Apply discount code */
3362
3372
  applyDiscount(code: string): Promise<SdkResult<Cart>>;
3373
+ /**
3374
+ * Add the products of a prepared cart link to the visitor's cart (SDK 2.4).
3375
+ * Behio Chat creates these links when the AI assembles a cart for the
3376
+ * visitor; the storefront handles `/cart/link/<token>`, calls this on the
3377
+ * server (Server Action or route handler, so the session cookie can be
3378
+ * written) and redirects to checkout. Items are ADDED, never replacing the
3379
+ * cart; opening the link twice does not double quantities. A discount code
3380
+ * carried by the link is applied with the normal validation. An expired or
3381
+ * unknown link fails with `be.storefront.cartLinkExpired` (404).
3382
+ */
3383
+ claimLink(token: string): Promise<SdkResult<CartLinkClaimed>>;
3363
3384
  /** Remove discount code */
3364
3385
  removeDiscount(): Promise<SdkResult<Cart>>;
3365
3386
  }
package/dist/react.js CHANGED
@@ -1380,6 +1380,25 @@ var CartModule = class {
1380
1380
  this.client.emit("cart:updated", res.data);
1381
1381
  return res;
1382
1382
  }
1383
+ /**
1384
+ * Add the products of a prepared cart link to the visitor's cart (SDK 2.4).
1385
+ * Behio Chat creates these links when the AI assembles a cart for the
1386
+ * visitor; the storefront handles `/cart/link/<token>`, calls this on the
1387
+ * server (Server Action or route handler, so the session cookie can be
1388
+ * written) and redirects to checkout. Items are ADDED, never replacing the
1389
+ * cart; opening the link twice does not double quantities. A discount code
1390
+ * carried by the link is applied with the normal validation. An expired or
1391
+ * unknown link fails with `be.storefront.cartLinkExpired` (404).
1392
+ */
1393
+ async claimLink(token) {
1394
+ const res = await this.client.request("POST", `/cart/links/${encodeURIComponent(token)}/claim`, {});
1395
+ if (res.error) return res;
1396
+ if (res.data.newSessionToken) {
1397
+ this.client.setCartSession(res.data.newSessionToken);
1398
+ }
1399
+ this.client.emit("cart:updated", res.data);
1400
+ return res;
1401
+ }
1383
1402
  /** Remove discount code */
1384
1403
  async removeDiscount() {
1385
1404
  const res = await this.client.request("DELETE", "/cart/discount");
@@ -2183,22 +2202,28 @@ var NewsletterModule = class {
2183
2202
  );
2184
2203
  }
2185
2204
  };
2186
- function emitCartEvent(data) {
2205
+ function publishCartSummary(summary) {
2187
2206
  if (typeof window === "undefined" || typeof window.dispatchEvent !== "function") return;
2207
+ if (!Number.isFinite(summary.total) || !Number.isFinite(summary.itemCount)) return;
2208
+ const detail = { total: summary.total, currency: summary.currency ?? null, itemCount: summary.itemCount };
2209
+ try {
2210
+ window.__behioCart = detail;
2211
+ window.dispatchEvent(new CustomEvent("behio:cart", { detail }));
2212
+ } catch {
2213
+ }
2214
+ }
2215
+ function emitCartEvent(data) {
2216
+ if (typeof window === "undefined") return;
2188
2217
  const cart = data;
2189
2218
  if (!cart || typeof cart !== "object" || !Array.isArray(cart.items)) return;
2219
+ if (cart.totalsAvailable === false) return;
2190
2220
  const items = cart.items;
2191
2221
  const total = typeof cart.grandTotal === "number" ? cart.grandTotal : typeof cart.subtotal === "number" ? cart.subtotal : 0;
2192
- const detail = {
2222
+ publishCartSummary({
2193
2223
  total,
2194
2224
  currency: typeof cart.currency === "string" ? cart.currency : null,
2195
2225
  itemCount: items.reduce((n, i) => n + (typeof i?.quantity === "number" ? i.quantity : 1), 0)
2196
- };
2197
- try {
2198
- window.__behioCart = detail;
2199
- window.dispatchEvent(new CustomEvent("behio:cart", { detail }));
2200
- } catch {
2201
- }
2226
+ });
2202
2227
  }
2203
2228
 
2204
2229
  // src/react/context.ts
package/dist/react.mjs CHANGED
@@ -1270,6 +1270,25 @@ var CartModule = class {
1270
1270
  this.client.emit("cart:updated", res.data);
1271
1271
  return res;
1272
1272
  }
1273
+ /**
1274
+ * Add the products of a prepared cart link to the visitor's cart (SDK 2.4).
1275
+ * Behio Chat creates these links when the AI assembles a cart for the
1276
+ * visitor; the storefront handles `/cart/link/<token>`, calls this on the
1277
+ * server (Server Action or route handler, so the session cookie can be
1278
+ * written) and redirects to checkout. Items are ADDED, never replacing the
1279
+ * cart; opening the link twice does not double quantities. A discount code
1280
+ * carried by the link is applied with the normal validation. An expired or
1281
+ * unknown link fails with `be.storefront.cartLinkExpired` (404).
1282
+ */
1283
+ async claimLink(token) {
1284
+ const res = await this.client.request("POST", `/cart/links/${encodeURIComponent(token)}/claim`, {});
1285
+ if (res.error) return res;
1286
+ if (res.data.newSessionToken) {
1287
+ this.client.setCartSession(res.data.newSessionToken);
1288
+ }
1289
+ this.client.emit("cart:updated", res.data);
1290
+ return res;
1291
+ }
1273
1292
  /** Remove discount code */
1274
1293
  async removeDiscount() {
1275
1294
  const res = await this.client.request("DELETE", "/cart/discount");
@@ -2073,22 +2092,28 @@ var NewsletterModule = class {
2073
2092
  );
2074
2093
  }
2075
2094
  };
2076
- function emitCartEvent(data) {
2095
+ function publishCartSummary(summary) {
2077
2096
  if (typeof window === "undefined" || typeof window.dispatchEvent !== "function") return;
2097
+ if (!Number.isFinite(summary.total) || !Number.isFinite(summary.itemCount)) return;
2098
+ const detail = { total: summary.total, currency: summary.currency ?? null, itemCount: summary.itemCount };
2099
+ try {
2100
+ window.__behioCart = detail;
2101
+ window.dispatchEvent(new CustomEvent("behio:cart", { detail }));
2102
+ } catch {
2103
+ }
2104
+ }
2105
+ function emitCartEvent(data) {
2106
+ if (typeof window === "undefined") return;
2078
2107
  const cart = data;
2079
2108
  if (!cart || typeof cart !== "object" || !Array.isArray(cart.items)) return;
2109
+ if (cart.totalsAvailable === false) return;
2080
2110
  const items = cart.items;
2081
2111
  const total = typeof cart.grandTotal === "number" ? cart.grandTotal : typeof cart.subtotal === "number" ? cart.subtotal : 0;
2082
- const detail = {
2112
+ publishCartSummary({
2083
2113
  total,
2084
2114
  currency: typeof cart.currency === "string" ? cart.currency : null,
2085
2115
  itemCount: items.reduce((n, i) => n + (typeof i?.quantity === "number" ? i.quantity : 1), 0)
2086
- };
2087
- try {
2088
- window.__behioCart = detail;
2089
- window.dispatchEvent(new CustomEvent("behio:cart", { detail }));
2090
- } catch {
2091
- }
2116
+ });
2092
2117
  }
2093
2118
 
2094
2119
  // src/react/context.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@behio/storefront-sdk",
3
- "version": "2.2.0",
3
+ "version": "2.4.0",
4
4
  "description": "TypeScript SDK for Behio headless e-commerce: core client + React hooks",
5
5
  "author": "Behio",
6
6
  "license": "MIT",