@behio/storefront-sdk 1.7.0 → 1.8.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.
@@ -116,6 +116,11 @@ function toSdkError(err2) {
116
116
  }
117
117
 
118
118
  // src/client.ts
119
+ function isAvailabilityFailure(err2) {
120
+ if (err2 instanceof BehioNetworkError) return true;
121
+ if (err2 instanceof BehioApiError) return err2.isRetryable;
122
+ return false;
123
+ }
119
124
  var BehioStorefront = class {
120
125
  constructor(config) {
121
126
  /** Consent-gated persistent visitor id — set by the analytics tracker. */
@@ -144,6 +149,7 @@ var BehioStorefront = class {
144
149
  this.retries = config.retries ?? 1;
145
150
  this.retryDelay = config.retryDelay ?? 1e3;
146
151
  this.visitorIp = config.visitorIp;
152
+ this.throwOnAvailabilityError = config.throwOnAvailabilityError ?? false;
147
153
  this.catalog = new CatalogModule(this);
148
154
  this.auth = new AuthModule(this);
149
155
  this.cart = new CartModule(this);
@@ -374,6 +380,9 @@ var BehioStorefront = class {
374
380
  const data = await this.rawRequest(method, path, options);
375
381
  return ok(data);
376
382
  } catch (err2) {
383
+ if (this.throwOnAvailabilityError && isAvailabilityFailure(err2)) {
384
+ throw err2;
385
+ }
377
386
  return { data: null, error: toSdkError(err2) };
378
387
  }
379
388
  }
@@ -401,6 +410,9 @@ var BehioStorefront = class {
401
410
  }
402
411
  return ok(await res.blob());
403
412
  } catch (err2) {
413
+ if (this.throwOnAvailabilityError && isAvailabilityFailure(err2)) {
414
+ throw err2;
415
+ }
404
416
  return { data: null, error: toSdkError(err2) };
405
417
  }
406
418
  }
@@ -116,6 +116,11 @@ function toSdkError(err2) {
116
116
  }
117
117
 
118
118
  // src/client.ts
119
+ function isAvailabilityFailure(err2) {
120
+ if (err2 instanceof BehioNetworkError) return true;
121
+ if (err2 instanceof BehioApiError) return err2.isRetryable;
122
+ return false;
123
+ }
119
124
  var BehioStorefront = class {
120
125
  constructor(config) {
121
126
  /** Consent-gated persistent visitor id — set by the analytics tracker. */
@@ -144,6 +149,7 @@ var BehioStorefront = class {
144
149
  this.retries = _nullishCoalesce(config.retries, () => ( 1));
145
150
  this.retryDelay = _nullishCoalesce(config.retryDelay, () => ( 1e3));
146
151
  this.visitorIp = config.visitorIp;
152
+ this.throwOnAvailabilityError = _nullishCoalesce(config.throwOnAvailabilityError, () => ( false));
147
153
  this.catalog = new CatalogModule(this);
148
154
  this.auth = new AuthModule(this);
149
155
  this.cart = new CartModule(this);
@@ -374,6 +380,9 @@ var BehioStorefront = class {
374
380
  const data = await this.rawRequest(method, path, options);
375
381
  return ok(data);
376
382
  } catch (err2) {
383
+ if (this.throwOnAvailabilityError && isAvailabilityFailure(err2)) {
384
+ throw err2;
385
+ }
377
386
  return { data: null, error: toSdkError(err2) };
378
387
  }
379
388
  }
@@ -401,6 +410,9 @@ var BehioStorefront = class {
401
410
  }
402
411
  return ok(await res.blob());
403
412
  } catch (err2) {
413
+ if (this.throwOnAvailabilityError && isAvailabilityFailure(err2)) {
414
+ throw err2;
415
+ }
404
416
  return { data: null, error: toSdkError(err2) };
405
417
  }
406
418
  }
@@ -29,6 +29,19 @@ interface BehioStorefrontConfig {
29
29
  * automatically from the incoming request headers.
30
30
  */
31
31
  visitorIp?: string | (() => string | null | undefined | Promise<string | null | undefined>);
32
+ /**
33
+ * Throw availability failures (429, 5xx, network, timeout) instead of
34
+ * returning them as `SdkResult.error`. Business outcomes (400, 401, 404,
35
+ * 409, …) keep the tuple shape either way.
36
+ *
37
+ * Why this exists: a storefront section that reads `result.data ?? []`
38
+ * silently renders an EMPTY catalog when the API is rate-limited or down,
39
+ * which looks exactly like a shop with no products. With this flag the
40
+ * failure surfaces as an exception, so SSR/ISR keeps the last good page and
41
+ * the visitor gets an error boundary instead of a lying page. Recommended
42
+ * `true` for every server-rendered catalog client.
43
+ */
44
+ throwOnAvailabilityError?: boolean;
32
45
  /** Request timeout in milliseconds. Default: 30000 (30s) */
33
46
  timeout?: number;
34
47
  /** Number of retries on network/5xx errors. Default: 1 */
@@ -2334,6 +2347,7 @@ declare class BehioStorefront {
2334
2347
  private rateLimitRemaining;
2335
2348
  private rateLimitReset;
2336
2349
  private visitorIp?;
2350
+ private throwOnAvailabilityError;
2337
2351
  constructor(config: BehioStorefrontConfig);
2338
2352
  readonly catalog: CatalogModule;
2339
2353
  readonly auth: AuthModule;
@@ -29,6 +29,19 @@ interface BehioStorefrontConfig {
29
29
  * automatically from the incoming request headers.
30
30
  */
31
31
  visitorIp?: string | (() => string | null | undefined | Promise<string | null | undefined>);
32
+ /**
33
+ * Throw availability failures (429, 5xx, network, timeout) instead of
34
+ * returning them as `SdkResult.error`. Business outcomes (400, 401, 404,
35
+ * 409, …) keep the tuple shape either way.
36
+ *
37
+ * Why this exists: a storefront section that reads `result.data ?? []`
38
+ * silently renders an EMPTY catalog when the API is rate-limited or down,
39
+ * which looks exactly like a shop with no products. With this flag the
40
+ * failure surfaces as an exception, so SSR/ISR keeps the last good page and
41
+ * the visitor gets an error boundary instead of a lying page. Recommended
42
+ * `true` for every server-rendered catalog client.
43
+ */
44
+ throwOnAvailabilityError?: boolean;
32
45
  /** Request timeout in milliseconds. Default: 30000 (30s) */
33
46
  timeout?: number;
34
47
  /** Number of retries on network/5xx errors. Default: 1 */
@@ -2334,6 +2347,7 @@ declare class BehioStorefront {
2334
2347
  private rateLimitRemaining;
2335
2348
  private rateLimitReset;
2336
2349
  private visitorIp?;
2350
+ private throwOnAvailabilityError;
2337
2351
  constructor(config: BehioStorefrontConfig);
2338
2352
  readonly catalog: CatalogModule;
2339
2353
  readonly auth: AuthModule;
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 } from './client-BSDdOEcK.mjs';
2
- export { A as ActivePromotion, b as AddToCartInput, c as AddressDetail, d as AddressSuggestion, e as AddressType, f as AddressTypes, g as AuthTokens, h as BackInStockSubscription, i as BadgeTone, j as BehioApiError, k as BehioErrorCode, l as BehioEventHandler, m as BehioEventType, n as BehioNetworkError, o as BehioStorefrontConfig, p as Bundle, q as BundleItem, r as Cart, s as CartBundleLine, t as CartBundleLineItem, u as CartDiscount, v as CartItem, w as CartItemProduct, x as CartPromotion, y as Category, z as CategoryDetail, D as CertificateVerification, E as CheckoutAddress, F as CheckoutInput, G as CheckoutPaymentMethod, H as CheckoutSettings, I as CookieConsentInput, J as CourseAttachment, K as CourseCertificate, L as CourseComment, M as CourseCommentReply, N as CourseCommentsList, O as CourseDetail, Q as CourseLesson, R as CourseListItem, T as CourseModule, U as CoursePostedComment, V as CourseProgress, W as CourseTutorMessage, X as CourseTutorThread, Y as CrossSellItem, Z as CustomerAddress, _ as CustomerProfile, $ as DigitalDownload, a0 as DownloadUrl, a1 as Facet, a2 as FacetAvailability, a3 as FacetCategory, a4 as FacetLabel, a5 as FacetPriceRange, a6 as FacetRange, a7 as FacetRatingBucket, a8 as FacetValue, a9 as FacetsResponse, aa as FilterField, ab as FulfillmentStatus, ac as FulfillmentStatuses, ad as GiftCardBalance, ae as GiftCardPurchaseInput, af as GiftCardPurchaseResult, ag as GiftCardSummary, ah as LessonNote, ai as LessonQuiz, aj as LoginInput, ak as LoyaltyBalance, al as LoyaltyNextTier, am as LoyaltyProgram, an as LoyaltySummary, ao as LoyaltyTier, ap as LoyaltyTierPerks, aq as LoyaltyTransaction, ar as Menu, as as MenuItem, at as MenuItemRef, au as MenuItemType, av as MessageResponse, aw as NewsletterOptInDefault, ax as NewsletterSubscribeInput, ay as NewsletterSubscribeResult, az as NewsletterUnsubscribeResult, aA as OrderAccessRequestResponse, aB as OrderAccessVerifyResponse, aC as OrderDetail, aD as OrderItem, aE as OrderListItem, aF as OrderStatus, aG as OrderStatusHistory, aH as OrderStatuses, aI as OrderTracking, aJ as Page, aK as PageAttachment, aL as PageDetail, aM as PaginatedResponse, aN as PaymentStatus, aO as PaymentStatuses, aP as PickupPoint, aQ as PickupPointHours, aR as PickupPointsInput, aS as PriceDisplay, aT as ProductAssetGroup, aU as ProductAssetItem, aV as ProductAvailability, aW as ProductGroup, aX as ProductLabel, aY as ProductListItem, aZ as ProductMedia, a_ as ProductMediaVariant, a$ as ProductParameter, b0 as ProductParameterGroup, b1 as ProductParametersResponse, b2 as ProductPrice, b3 as ProductPromotionSummary, b4 as ProductReview, b5 as ProductReviewsResponse, b6 as ProductSibling, b7 as ProductSort, b8 as ProductSortValue, b9 as ProductVolumePrice, ba as ProductsQuery, bb as QuizAnswerInput, bc as QuizAnswerResult, bd as QuizQuestion, be as QuizResult, bf as QuoteItem, bg as QuoteRequest, bh as RegisterInput, bi as RegisterResult, bj as RequestInterceptor, bk as RequestInterceptorConfig, bl as ResponseInterceptor, bm as ResponseInterceptorData, bn as ReturnRequest, bo as ReturnRequestItem, bp as ReturnStatus, bq as ReturnStatusItem, br as ReturnableOrder, bs as ReturnableOrderItem, bt as SdkError, bu as ShippingMethodSummary, bv as ShippingQuote, bw as ShippingQuoteInput, bx as ShopInfo, by as ShopScript, bz as ShopScriptPlacement, bA as ShopScriptType, bB as ShopScripts, bC as ShopSeo, bD as ShopSeoIdentity, bE as Sitemap, bF as SitemapEntry, bG as StockBehavior, bH as StockMode, bI as SubmitQuoteInput, bJ as SubmitReturnInput, bK as SubmitReviewInput, bL as Subscription, bM as SubscriptionAction, bN as SubscriptionFrequency, bO as SubscriptionItem, bP as SubscriptionStatus, bQ as TaxBreakdownLine, bR as VariantAxis, bS as VariantAxisValue, bT as WishlistItem, bU as err, bV as ok, bW as toSdkError } from './client-BSDdOEcK.mjs';
1
+ import { P as ProductDetail, a as ProductVariant, B as BehioStorefront, S as SdkResult, C as CookieConsent } from './client-BP9n3a_D.mjs';
2
+ export { A as ActivePromotion, b as AddToCartInput, c as AddressDetail, d as AddressSuggestion, e as AddressType, f as AddressTypes, g as AuthTokens, h as BackInStockSubscription, i as BadgeTone, j as BehioApiError, k as BehioErrorCode, l as BehioEventHandler, m as BehioEventType, n as BehioNetworkError, o as BehioStorefrontConfig, p as Bundle, q as BundleItem, r as Cart, s as CartBundleLine, t as CartBundleLineItem, u as CartDiscount, v as CartItem, w as CartItemProduct, x as CartPromotion, y as Category, z as CategoryDetail, D as CertificateVerification, E as CheckoutAddress, F as CheckoutInput, G as CheckoutPaymentMethod, H as CheckoutSettings, I as CookieConsentInput, J as CourseAttachment, K as CourseCertificate, L as CourseComment, M as CourseCommentReply, N as CourseCommentsList, O as CourseDetail, Q as CourseLesson, R as CourseListItem, T as CourseModule, U as CoursePostedComment, V as CourseProgress, W as CourseTutorMessage, X as CourseTutorThread, Y as CrossSellItem, Z as CustomerAddress, _ as CustomerProfile, $ as DigitalDownload, a0 as DownloadUrl, a1 as Facet, a2 as FacetAvailability, a3 as FacetCategory, a4 as FacetLabel, a5 as FacetPriceRange, a6 as FacetRange, a7 as FacetRatingBucket, a8 as FacetValue, a9 as FacetsResponse, aa as FilterField, ab as FulfillmentStatus, ac as FulfillmentStatuses, ad as GiftCardBalance, ae as GiftCardPurchaseInput, af as GiftCardPurchaseResult, ag as GiftCardSummary, ah as LessonNote, ai as LessonQuiz, aj as LoginInput, ak as LoyaltyBalance, al as LoyaltyNextTier, am as LoyaltyProgram, an as LoyaltySummary, ao as LoyaltyTier, ap as LoyaltyTierPerks, aq as LoyaltyTransaction, ar as Menu, as as MenuItem, at as MenuItemRef, au as MenuItemType, av as MessageResponse, aw as NewsletterOptInDefault, ax as NewsletterSubscribeInput, ay as NewsletterSubscribeResult, az as NewsletterUnsubscribeResult, aA as OrderAccessRequestResponse, aB as OrderAccessVerifyResponse, aC as OrderDetail, aD as OrderItem, aE as OrderListItem, aF as OrderStatus, aG as OrderStatusHistory, aH as OrderStatuses, aI as OrderTracking, aJ as Page, aK as PageAttachment, aL as PageDetail, aM as PaginatedResponse, aN as PaymentStatus, aO as PaymentStatuses, aP as PickupPoint, aQ as PickupPointHours, aR as PickupPointsInput, aS as PriceDisplay, aT as ProductAssetGroup, aU as ProductAssetItem, aV as ProductAvailability, aW as ProductGroup, aX as ProductLabel, aY as ProductListItem, aZ as ProductMedia, a_ as ProductMediaVariant, a$ as ProductParameter, b0 as ProductParameterGroup, b1 as ProductParametersResponse, b2 as ProductPrice, b3 as ProductPromotionSummary, b4 as ProductReview, b5 as ProductReviewsResponse, b6 as ProductSibling, b7 as ProductSort, b8 as ProductSortValue, b9 as ProductVolumePrice, ba as ProductsQuery, bb as QuizAnswerInput, bc as QuizAnswerResult, bd as QuizQuestion, be as QuizResult, bf as QuoteItem, bg as QuoteRequest, bh as RegisterInput, bi as RegisterResult, bj as RequestInterceptor, bk as RequestInterceptorConfig, bl as ResponseInterceptor, bm as ResponseInterceptorData, bn as ReturnRequest, bo as ReturnRequestItem, bp as ReturnStatus, bq as ReturnStatusItem, br as ReturnableOrder, bs as ReturnableOrderItem, bt as SdkError, bu as ShippingMethodSummary, bv as ShippingQuote, bw as ShippingQuoteInput, bx as ShopInfo, by as ShopScript, bz as ShopScriptPlacement, bA as ShopScriptType, bB as ShopScripts, bC as ShopSeo, bD as ShopSeoIdentity, bE as Sitemap, bF as SitemapEntry, bG as StockBehavior, bH as StockMode, bI as SubmitQuoteInput, bJ as SubmitReturnInput, bK as SubmitReviewInput, bL as Subscription, bM as SubscriptionAction, bN as SubscriptionFrequency, bO as SubscriptionItem, bP as SubscriptionStatus, bQ as TaxBreakdownLine, bR as VariantAxis, bS as VariantAxisValue, bT as WishlistItem, bU as err, bV as ok, bW as toSdkError } from './client-BP9n3a_D.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 } from './client-BSDdOEcK.js';
2
- export { A as ActivePromotion, b as AddToCartInput, c as AddressDetail, d as AddressSuggestion, e as AddressType, f as AddressTypes, g as AuthTokens, h as BackInStockSubscription, i as BadgeTone, j as BehioApiError, k as BehioErrorCode, l as BehioEventHandler, m as BehioEventType, n as BehioNetworkError, o as BehioStorefrontConfig, p as Bundle, q as BundleItem, r as Cart, s as CartBundleLine, t as CartBundleLineItem, u as CartDiscount, v as CartItem, w as CartItemProduct, x as CartPromotion, y as Category, z as CategoryDetail, D as CertificateVerification, E as CheckoutAddress, F as CheckoutInput, G as CheckoutPaymentMethod, H as CheckoutSettings, I as CookieConsentInput, J as CourseAttachment, K as CourseCertificate, L as CourseComment, M as CourseCommentReply, N as CourseCommentsList, O as CourseDetail, Q as CourseLesson, R as CourseListItem, T as CourseModule, U as CoursePostedComment, V as CourseProgress, W as CourseTutorMessage, X as CourseTutorThread, Y as CrossSellItem, Z as CustomerAddress, _ as CustomerProfile, $ as DigitalDownload, a0 as DownloadUrl, a1 as Facet, a2 as FacetAvailability, a3 as FacetCategory, a4 as FacetLabel, a5 as FacetPriceRange, a6 as FacetRange, a7 as FacetRatingBucket, a8 as FacetValue, a9 as FacetsResponse, aa as FilterField, ab as FulfillmentStatus, ac as FulfillmentStatuses, ad as GiftCardBalance, ae as GiftCardPurchaseInput, af as GiftCardPurchaseResult, ag as GiftCardSummary, ah as LessonNote, ai as LessonQuiz, aj as LoginInput, ak as LoyaltyBalance, al as LoyaltyNextTier, am as LoyaltyProgram, an as LoyaltySummary, ao as LoyaltyTier, ap as LoyaltyTierPerks, aq as LoyaltyTransaction, ar as Menu, as as MenuItem, at as MenuItemRef, au as MenuItemType, av as MessageResponse, aw as NewsletterOptInDefault, ax as NewsletterSubscribeInput, ay as NewsletterSubscribeResult, az as NewsletterUnsubscribeResult, aA as OrderAccessRequestResponse, aB as OrderAccessVerifyResponse, aC as OrderDetail, aD as OrderItem, aE as OrderListItem, aF as OrderStatus, aG as OrderStatusHistory, aH as OrderStatuses, aI as OrderTracking, aJ as Page, aK as PageAttachment, aL as PageDetail, aM as PaginatedResponse, aN as PaymentStatus, aO as PaymentStatuses, aP as PickupPoint, aQ as PickupPointHours, aR as PickupPointsInput, aS as PriceDisplay, aT as ProductAssetGroup, aU as ProductAssetItem, aV as ProductAvailability, aW as ProductGroup, aX as ProductLabel, aY as ProductListItem, aZ as ProductMedia, a_ as ProductMediaVariant, a$ as ProductParameter, b0 as ProductParameterGroup, b1 as ProductParametersResponse, b2 as ProductPrice, b3 as ProductPromotionSummary, b4 as ProductReview, b5 as ProductReviewsResponse, b6 as ProductSibling, b7 as ProductSort, b8 as ProductSortValue, b9 as ProductVolumePrice, ba as ProductsQuery, bb as QuizAnswerInput, bc as QuizAnswerResult, bd as QuizQuestion, be as QuizResult, bf as QuoteItem, bg as QuoteRequest, bh as RegisterInput, bi as RegisterResult, bj as RequestInterceptor, bk as RequestInterceptorConfig, bl as ResponseInterceptor, bm as ResponseInterceptorData, bn as ReturnRequest, bo as ReturnRequestItem, bp as ReturnStatus, bq as ReturnStatusItem, br as ReturnableOrder, bs as ReturnableOrderItem, bt as SdkError, bu as ShippingMethodSummary, bv as ShippingQuote, bw as ShippingQuoteInput, bx as ShopInfo, by as ShopScript, bz as ShopScriptPlacement, bA as ShopScriptType, bB as ShopScripts, bC as ShopSeo, bD as ShopSeoIdentity, bE as Sitemap, bF as SitemapEntry, bG as StockBehavior, bH as StockMode, bI as SubmitQuoteInput, bJ as SubmitReturnInput, bK as SubmitReviewInput, bL as Subscription, bM as SubscriptionAction, bN as SubscriptionFrequency, bO as SubscriptionItem, bP as SubscriptionStatus, bQ as TaxBreakdownLine, bR as VariantAxis, bS as VariantAxisValue, bT as WishlistItem, bU as err, bV as ok, bW as toSdkError } from './client-BSDdOEcK.js';
1
+ import { P as ProductDetail, a as ProductVariant, B as BehioStorefront, S as SdkResult, C as CookieConsent } from './client-BP9n3a_D.js';
2
+ export { A as ActivePromotion, b as AddToCartInput, c as AddressDetail, d as AddressSuggestion, e as AddressType, f as AddressTypes, g as AuthTokens, h as BackInStockSubscription, i as BadgeTone, j as BehioApiError, k as BehioErrorCode, l as BehioEventHandler, m as BehioEventType, n as BehioNetworkError, o as BehioStorefrontConfig, p as Bundle, q as BundleItem, r as Cart, s as CartBundleLine, t as CartBundleLineItem, u as CartDiscount, v as CartItem, w as CartItemProduct, x as CartPromotion, y as Category, z as CategoryDetail, D as CertificateVerification, E as CheckoutAddress, F as CheckoutInput, G as CheckoutPaymentMethod, H as CheckoutSettings, I as CookieConsentInput, J as CourseAttachment, K as CourseCertificate, L as CourseComment, M as CourseCommentReply, N as CourseCommentsList, O as CourseDetail, Q as CourseLesson, R as CourseListItem, T as CourseModule, U as CoursePostedComment, V as CourseProgress, W as CourseTutorMessage, X as CourseTutorThread, Y as CrossSellItem, Z as CustomerAddress, _ as CustomerProfile, $ as DigitalDownload, a0 as DownloadUrl, a1 as Facet, a2 as FacetAvailability, a3 as FacetCategory, a4 as FacetLabel, a5 as FacetPriceRange, a6 as FacetRange, a7 as FacetRatingBucket, a8 as FacetValue, a9 as FacetsResponse, aa as FilterField, ab as FulfillmentStatus, ac as FulfillmentStatuses, ad as GiftCardBalance, ae as GiftCardPurchaseInput, af as GiftCardPurchaseResult, ag as GiftCardSummary, ah as LessonNote, ai as LessonQuiz, aj as LoginInput, ak as LoyaltyBalance, al as LoyaltyNextTier, am as LoyaltyProgram, an as LoyaltySummary, ao as LoyaltyTier, ap as LoyaltyTierPerks, aq as LoyaltyTransaction, ar as Menu, as as MenuItem, at as MenuItemRef, au as MenuItemType, av as MessageResponse, aw as NewsletterOptInDefault, ax as NewsletterSubscribeInput, ay as NewsletterSubscribeResult, az as NewsletterUnsubscribeResult, aA as OrderAccessRequestResponse, aB as OrderAccessVerifyResponse, aC as OrderDetail, aD as OrderItem, aE as OrderListItem, aF as OrderStatus, aG as OrderStatusHistory, aH as OrderStatuses, aI as OrderTracking, aJ as Page, aK as PageAttachment, aL as PageDetail, aM as PaginatedResponse, aN as PaymentStatus, aO as PaymentStatuses, aP as PickupPoint, aQ as PickupPointHours, aR as PickupPointsInput, aS as PriceDisplay, aT as ProductAssetGroup, aU as ProductAssetItem, aV as ProductAvailability, aW as ProductGroup, aX as ProductLabel, aY as ProductListItem, aZ as ProductMedia, a_ as ProductMediaVariant, a$ as ProductParameter, b0 as ProductParameterGroup, b1 as ProductParametersResponse, b2 as ProductPrice, b3 as ProductPromotionSummary, b4 as ProductReview, b5 as ProductReviewsResponse, b6 as ProductSibling, b7 as ProductSort, b8 as ProductSortValue, b9 as ProductVolumePrice, ba as ProductsQuery, bb as QuizAnswerInput, bc as QuizAnswerResult, bd as QuizQuestion, be as QuizResult, bf as QuoteItem, bg as QuoteRequest, bh as RegisterInput, bi as RegisterResult, bj as RequestInterceptor, bk as RequestInterceptorConfig, bl as ResponseInterceptor, bm as ResponseInterceptorData, bn as ReturnRequest, bo as ReturnRequestItem, bp as ReturnStatus, bq as ReturnStatusItem, br as ReturnableOrder, bs as ReturnableOrderItem, bt as SdkError, bu as ShippingMethodSummary, bv as ShippingQuote, bw as ShippingQuoteInput, bx as ShopInfo, by as ShopScript, bz as ShopScriptPlacement, bA as ShopScriptType, bB as ShopScripts, bC as ShopSeo, bD as ShopSeoIdentity, bE as Sitemap, bF as SitemapEntry, bG as StockBehavior, bH as StockMode, bI as SubmitQuoteInput, bJ as SubmitReturnInput, bK as SubmitReviewInput, bL as Subscription, bM as SubscriptionAction, bN as SubscriptionFrequency, bO as SubscriptionItem, bP as SubscriptionStatus, bQ as TaxBreakdownLine, bR as VariantAxis, bS as VariantAxisValue, bT as WishlistItem, bU as err, bV as ok, bW as toSdkError } from './client-BP9n3a_D.js';
3
3
 
4
4
  /**
5
5
  * Format a price amount with currency using Intl.NumberFormat.
package/dist/index.js CHANGED
@@ -10,7 +10,7 @@
10
10
 
11
11
 
12
12
 
13
- var _chunkTJ4TZ5FIjs = require('./chunk-TJ4TZ5FI.js');
13
+ var _chunkLQ4GGXMJjs = require('./chunk-LQ4GGXMJ.js');
14
14
 
15
15
  // src/react/utils/format-price.ts
16
16
  function formatPrice(amount, currency, locale) {
@@ -243,4 +243,4 @@ async function revokeAnalyticsConsent(client) {
243
243
 
244
244
 
245
245
 
246
- exports.AddressTypes = _chunkTJ4TZ5FIjs.AddressTypes; exports.BehioApiError = _chunkTJ4TZ5FIjs.BehioApiError; exports.BehioNetworkError = _chunkTJ4TZ5FIjs.BehioNetworkError; exports.BehioStorefront = _chunkTJ4TZ5FIjs.BehioStorefront; exports.FulfillmentStatuses = _chunkTJ4TZ5FIjs.FulfillmentStatuses; exports.OrderStatuses = _chunkTJ4TZ5FIjs.OrderStatuses; exports.PaymentStatuses = _chunkTJ4TZ5FIjs.PaymentStatuses; exports.ProductSort = _chunkTJ4TZ5FIjs.ProductSort; exports.VARIANT_QUERY_PARAM = VARIANT_QUERY_PARAM; exports.availableAxisValues = availableAxisValues; exports.buildVariantComparison = buildVariantComparison; exports.err = _chunkTJ4TZ5FIjs.err; exports.findVariantByAttributes = findVariantByAttributes; exports.formatPrice = formatPrice; exports.generateVisitorId = generateVisitorId; exports.getStoredVisitorId = getStoredVisitorId; exports.grantAnalyticsConsent = grantAnalyticsConsent; exports.ok = _chunkTJ4TZ5FIjs.ok; exports.resolveVariantContent = resolveVariantContent; exports.revokeAnalyticsConsent = revokeAnalyticsConsent; exports.toSdkError = _chunkTJ4TZ5FIjs.toSdkError; exports.trackEcommerceEvent = trackEcommerceEvent; exports.variantFromQuery = variantFromQuery; exports.variantHref = variantHref;
246
+ exports.AddressTypes = _chunkLQ4GGXMJjs.AddressTypes; exports.BehioApiError = _chunkLQ4GGXMJjs.BehioApiError; exports.BehioNetworkError = _chunkLQ4GGXMJjs.BehioNetworkError; exports.BehioStorefront = _chunkLQ4GGXMJjs.BehioStorefront; exports.FulfillmentStatuses = _chunkLQ4GGXMJjs.FulfillmentStatuses; exports.OrderStatuses = _chunkLQ4GGXMJjs.OrderStatuses; exports.PaymentStatuses = _chunkLQ4GGXMJjs.PaymentStatuses; exports.ProductSort = _chunkLQ4GGXMJjs.ProductSort; exports.VARIANT_QUERY_PARAM = VARIANT_QUERY_PARAM; exports.availableAxisValues = availableAxisValues; exports.buildVariantComparison = buildVariantComparison; exports.err = _chunkLQ4GGXMJjs.err; exports.findVariantByAttributes = findVariantByAttributes; exports.formatPrice = formatPrice; exports.generateVisitorId = generateVisitorId; exports.getStoredVisitorId = getStoredVisitorId; exports.grantAnalyticsConsent = grantAnalyticsConsent; exports.ok = _chunkLQ4GGXMJjs.ok; exports.resolveVariantContent = resolveVariantContent; exports.revokeAnalyticsConsent = revokeAnalyticsConsent; exports.toSdkError = _chunkLQ4GGXMJjs.toSdkError; exports.trackEcommerceEvent = trackEcommerceEvent; exports.variantFromQuery = variantFromQuery; exports.variantHref = variantHref;
package/dist/index.mjs CHANGED
@@ -10,7 +10,7 @@ import {
10
10
  err,
11
11
  ok,
12
12
  toSdkError
13
- } from "./chunk-TOSF3K7J.mjs";
13
+ } from "./chunk-LA6K4KYS.mjs";
14
14
 
15
15
  // src/react/utils/format-price.ts
16
16
  function formatPrice(amount, currency, locale) {
package/dist/next.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { o as BehioStorefrontConfig, B as BehioStorefront } from './client-BSDdOEcK.mjs';
1
+ import { o as BehioStorefrontConfig, B as BehioStorefront } from './client-BP9n3a_D.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 { o as BehioStorefrontConfig, B as BehioStorefront } from './client-BSDdOEcK.js';
1
+ import { o as BehioStorefrontConfig, B as BehioStorefront } from './client-BP9n3a_D.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 _chunkTJ4TZ5FIjs = require('./chunk-TJ4TZ5FI.js');
3
+ var _chunkLQ4GGXMJjs = require('./chunk-LQ4GGXMJ.js');
4
4
 
5
5
  // src/next.ts
6
6
  var _headers = require('next/headers');
@@ -18,7 +18,7 @@ async function getBehio(options = {}) {
18
18
  const locale = _nullishCoalesce(options.locale, () => ( process.env.BEHIO_LOCALE));
19
19
  const currency = _nullishCoalesce(options.currency, () => ( process.env.BEHIO_CURRENCY));
20
20
  const cookieName = _nullishCoalesce(options.cartCookieName, () => ( CART_COOKIE_NAME));
21
- const client = new (0, _chunkTJ4TZ5FIjs.BehioStorefront)({
21
+ const client = new (0, _chunkLQ4GGXMJjs.BehioStorefront)({
22
22
  apiKey,
23
23
  ...baseUrl ? { baseUrl } : {},
24
24
  ...locale ? { locale } : {},
package/dist/next.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  BehioStorefront
3
- } from "./chunk-TOSF3K7J.mjs";
3
+ } from "./chunk-LA6K4KYS.mjs";
4
4
 
5
5
  // src/next.ts
6
6
  import { cookies, headers } from "next/headers";
package/dist/react.d.mts CHANGED
@@ -85,6 +85,19 @@ interface BehioStorefrontConfig {
85
85
  * automatically from the incoming request headers.
86
86
  */
87
87
  visitorIp?: string | (() => string | null | undefined | Promise<string | null | undefined>);
88
+ /**
89
+ * Throw availability failures (429, 5xx, network, timeout) instead of
90
+ * returning them as `SdkResult.error`. Business outcomes (400, 401, 404,
91
+ * 409, …) keep the tuple shape either way.
92
+ *
93
+ * Why this exists: a storefront section that reads `result.data ?? []`
94
+ * silently renders an EMPTY catalog when the API is rate-limited or down,
95
+ * which looks exactly like a shop with no products. With this flag the
96
+ * failure surfaces as an exception, so SSR/ISR keeps the last good page and
97
+ * the visitor gets an error boundary instead of a lying page. Recommended
98
+ * `true` for every server-rendered catalog client.
99
+ */
100
+ throwOnAvailabilityError?: boolean;
88
101
  /** Request timeout in milliseconds. Default: 30000 (30s) */
89
102
  timeout?: number;
90
103
  /** Number of retries on network/5xx errors. Default: 1 */
@@ -2378,6 +2391,7 @@ declare class BehioStorefront {
2378
2391
  private rateLimitRemaining;
2379
2392
  private rateLimitReset;
2380
2393
  private visitorIp?;
2394
+ private throwOnAvailabilityError;
2381
2395
  constructor(config: BehioStorefrontConfig);
2382
2396
  readonly catalog: CatalogModule;
2383
2397
  readonly auth: AuthModule;
package/dist/react.d.ts CHANGED
@@ -85,6 +85,19 @@ interface BehioStorefrontConfig {
85
85
  * automatically from the incoming request headers.
86
86
  */
87
87
  visitorIp?: string | (() => string | null | undefined | Promise<string | null | undefined>);
88
+ /**
89
+ * Throw availability failures (429, 5xx, network, timeout) instead of
90
+ * returning them as `SdkResult.error`. Business outcomes (400, 401, 404,
91
+ * 409, …) keep the tuple shape either way.
92
+ *
93
+ * Why this exists: a storefront section that reads `result.data ?? []`
94
+ * silently renders an EMPTY catalog when the API is rate-limited or down,
95
+ * which looks exactly like a shop with no products. With this flag the
96
+ * failure surfaces as an exception, so SSR/ISR keeps the last good page and
97
+ * the visitor gets an error boundary instead of a lying page. Recommended
98
+ * `true` for every server-rendered catalog client.
99
+ */
100
+ throwOnAvailabilityError?: boolean;
88
101
  /** Request timeout in milliseconds. Default: 30000 (30s) */
89
102
  timeout?: number;
90
103
  /** Number of retries on network/5xx errors. Default: 1 */
@@ -2378,6 +2391,7 @@ declare class BehioStorefront {
2378
2391
  private rateLimitRemaining;
2379
2392
  private rateLimitReset;
2380
2393
  private visitorIp?;
2394
+ private throwOnAvailabilityError;
2381
2395
  constructor(config: BehioStorefrontConfig);
2382
2396
  readonly catalog: CatalogModule;
2383
2397
  readonly auth: AuthModule;
package/dist/react.js CHANGED
@@ -188,6 +188,11 @@ function toSdkError(err) {
188
188
  }
189
189
 
190
190
  // src/client.ts
191
+ function isAvailabilityFailure(err) {
192
+ if (err instanceof BehioNetworkError) return true;
193
+ if (err instanceof BehioApiError) return err.isRetryable;
194
+ return false;
195
+ }
191
196
  var BehioStorefront = class {
192
197
  constructor(config) {
193
198
  /** Consent-gated persistent visitor id — set by the analytics tracker. */
@@ -216,6 +221,7 @@ var BehioStorefront = class {
216
221
  this.retries = config.retries ?? 1;
217
222
  this.retryDelay = config.retryDelay ?? 1e3;
218
223
  this.visitorIp = config.visitorIp;
224
+ this.throwOnAvailabilityError = config.throwOnAvailabilityError ?? false;
219
225
  this.catalog = new CatalogModule(this);
220
226
  this.auth = new AuthModule(this);
221
227
  this.cart = new CartModule(this);
@@ -446,6 +452,9 @@ var BehioStorefront = class {
446
452
  const data = await this.rawRequest(method, path, options);
447
453
  return ok(data);
448
454
  } catch (err) {
455
+ if (this.throwOnAvailabilityError && isAvailabilityFailure(err)) {
456
+ throw err;
457
+ }
449
458
  return { data: null, error: toSdkError(err) };
450
459
  }
451
460
  }
@@ -473,6 +482,9 @@ var BehioStorefront = class {
473
482
  }
474
483
  return ok(await res.blob());
475
484
  } catch (err) {
485
+ if (this.throwOnAvailabilityError && isAvailabilityFailure(err)) {
486
+ throw err;
487
+ }
476
488
  return { data: null, error: toSdkError(err) };
477
489
  }
478
490
  }
package/dist/react.mjs CHANGED
@@ -85,6 +85,11 @@ function toSdkError(err) {
85
85
  }
86
86
 
87
87
  // src/client.ts
88
+ function isAvailabilityFailure(err) {
89
+ if (err instanceof BehioNetworkError) return true;
90
+ if (err instanceof BehioApiError) return err.isRetryable;
91
+ return false;
92
+ }
88
93
  var BehioStorefront = class {
89
94
  constructor(config) {
90
95
  /** Consent-gated persistent visitor id — set by the analytics tracker. */
@@ -113,6 +118,7 @@ var BehioStorefront = class {
113
118
  this.retries = config.retries ?? 1;
114
119
  this.retryDelay = config.retryDelay ?? 1e3;
115
120
  this.visitorIp = config.visitorIp;
121
+ this.throwOnAvailabilityError = config.throwOnAvailabilityError ?? false;
116
122
  this.catalog = new CatalogModule(this);
117
123
  this.auth = new AuthModule(this);
118
124
  this.cart = new CartModule(this);
@@ -343,6 +349,9 @@ var BehioStorefront = class {
343
349
  const data = await this.rawRequest(method, path, options);
344
350
  return ok(data);
345
351
  } catch (err) {
352
+ if (this.throwOnAvailabilityError && isAvailabilityFailure(err)) {
353
+ throw err;
354
+ }
346
355
  return { data: null, error: toSdkError(err) };
347
356
  }
348
357
  }
@@ -370,6 +379,9 @@ var BehioStorefront = class {
370
379
  }
371
380
  return ok(await res.blob());
372
381
  } catch (err) {
382
+ if (this.throwOnAvailabilityError && isAvailabilityFailure(err)) {
383
+ throw err;
384
+ }
373
385
  return { data: null, error: toSdkError(err) };
374
386
  }
375
387
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@behio/storefront-sdk",
3
- "version": "1.7.0",
3
+ "version": "1.8.0",
4
4
  "description": "TypeScript SDK for Behio Headless E-Shop — core client + React hooks",
5
5
  "author": "Behio",
6
6
  "license": "MIT",