@behio/storefront-sdk 1.7.0 → 1.9.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/dist/{chunk-TJ4TZ5FI.js → chunk-CY6D2YEI.js} +27 -0
- package/dist/{chunk-TOSF3K7J.mjs → chunk-XMKY4RI5.mjs} +27 -0
- package/dist/{client-BSDdOEcK.d.mts → client-C635vSzU.d.mts} +33 -0
- package/dist/{client-BSDdOEcK.d.ts → client-C635vSzU.d.ts} +33 -0
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/index.mjs +1 -1
- package/dist/next.d.mts +1 -1
- package/dist/next.d.ts +1 -1
- package/dist/next.js +2 -2
- package/dist/next.mjs +1 -1
- package/dist/react.d.mts +88 -1
- package/dist/react.d.ts +88 -1
- package/dist/react.js +185 -89
- package/dist/react.mjs +161 -66
- package/package.json +2 -2
|
@@ -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);
|
|
@@ -219,6 +225,21 @@ var BehioStorefront = class {
|
|
|
219
225
|
body: input
|
|
220
226
|
});
|
|
221
227
|
}
|
|
228
|
+
/**
|
|
229
|
+
* Visitor messages from merchant automations (storefront.event action).
|
|
230
|
+
* Consent-gated visitor id; each message carries a merchant-defined `name`
|
|
231
|
+
* and free-form `payload` the template reacts to (modal, banner, ...).
|
|
232
|
+
* Messages stay listed until acknowledged via `ackVisitorMessage`.
|
|
233
|
+
*/
|
|
234
|
+
async getVisitorMessages(visitorId) {
|
|
235
|
+
return this.request("GET", "/messages", { query: { visitorId } });
|
|
236
|
+
}
|
|
237
|
+
/** Acknowledge a visitor message so it is not delivered again. */
|
|
238
|
+
async ackVisitorMessage(messageId, visitorId) {
|
|
239
|
+
return this.request("POST", `/messages/${messageId}/ack`, {
|
|
240
|
+
query: { visitorId }
|
|
241
|
+
});
|
|
242
|
+
}
|
|
222
243
|
/** Get basic shop info */
|
|
223
244
|
async getShopInfo() {
|
|
224
245
|
return this.request("GET", "/shop");
|
|
@@ -374,6 +395,9 @@ var BehioStorefront = class {
|
|
|
374
395
|
const data = await this.rawRequest(method, path, options);
|
|
375
396
|
return ok(data);
|
|
376
397
|
} catch (err2) {
|
|
398
|
+
if (this.throwOnAvailabilityError && isAvailabilityFailure(err2)) {
|
|
399
|
+
throw err2;
|
|
400
|
+
}
|
|
377
401
|
return { data: null, error: toSdkError(err2) };
|
|
378
402
|
}
|
|
379
403
|
}
|
|
@@ -401,6 +425,9 @@ var BehioStorefront = class {
|
|
|
401
425
|
}
|
|
402
426
|
return ok(await res.blob());
|
|
403
427
|
} catch (err2) {
|
|
428
|
+
if (this.throwOnAvailabilityError && isAvailabilityFailure(err2)) {
|
|
429
|
+
throw err2;
|
|
430
|
+
}
|
|
404
431
|
return { data: null, error: toSdkError(err2) };
|
|
405
432
|
}
|
|
406
433
|
}
|
|
@@ -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);
|
|
@@ -219,6 +225,21 @@ var BehioStorefront = class {
|
|
|
219
225
|
body: input
|
|
220
226
|
});
|
|
221
227
|
}
|
|
228
|
+
/**
|
|
229
|
+
* Visitor messages from merchant automations (storefront.event action).
|
|
230
|
+
* Consent-gated visitor id; each message carries a merchant-defined `name`
|
|
231
|
+
* and free-form `payload` the template reacts to (modal, banner, ...).
|
|
232
|
+
* Messages stay listed until acknowledged via `ackVisitorMessage`.
|
|
233
|
+
*/
|
|
234
|
+
async getVisitorMessages(visitorId) {
|
|
235
|
+
return this.request("GET", "/messages", { query: { visitorId } });
|
|
236
|
+
}
|
|
237
|
+
/** Acknowledge a visitor message so it is not delivered again. */
|
|
238
|
+
async ackVisitorMessage(messageId, visitorId) {
|
|
239
|
+
return this.request("POST", `/messages/${messageId}/ack`, {
|
|
240
|
+
query: { visitorId }
|
|
241
|
+
});
|
|
242
|
+
}
|
|
222
243
|
/** Get basic shop info */
|
|
223
244
|
async getShopInfo() {
|
|
224
245
|
return this.request("GET", "/shop");
|
|
@@ -374,6 +395,9 @@ var BehioStorefront = class {
|
|
|
374
395
|
const data = await this.rawRequest(method, path, options);
|
|
375
396
|
return ok(data);
|
|
376
397
|
} catch (err2) {
|
|
398
|
+
if (this.throwOnAvailabilityError && isAvailabilityFailure(err2)) {
|
|
399
|
+
throw err2;
|
|
400
|
+
}
|
|
377
401
|
return { data: null, error: toSdkError(err2) };
|
|
378
402
|
}
|
|
379
403
|
}
|
|
@@ -401,6 +425,9 @@ var BehioStorefront = class {
|
|
|
401
425
|
}
|
|
402
426
|
return ok(await res.blob());
|
|
403
427
|
} catch (err2) {
|
|
428
|
+
if (this.throwOnAvailabilityError && isAvailabilityFailure(err2)) {
|
|
429
|
+
throw err2;
|
|
430
|
+
}
|
|
404
431
|
return { data: null, error: toSdkError(err2) };
|
|
405
432
|
}
|
|
406
433
|
}
|
|
@@ -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;
|
|
@@ -2419,6 +2433,25 @@ declare class BehioStorefront {
|
|
|
2419
2433
|
percent: number;
|
|
2420
2434
|
expiresAt: number;
|
|
2421
2435
|
}>>;
|
|
2436
|
+
/**
|
|
2437
|
+
* Visitor messages from merchant automations (storefront.event action).
|
|
2438
|
+
* Consent-gated visitor id; each message carries a merchant-defined `name`
|
|
2439
|
+
* and free-form `payload` the template reacts to (modal, banner, ...).
|
|
2440
|
+
* Messages stay listed until acknowledged via `ackVisitorMessage`.
|
|
2441
|
+
*/
|
|
2442
|
+
getVisitorMessages(visitorId: string): Promise<SdkResult<{
|
|
2443
|
+
items: Array<{
|
|
2444
|
+
id: string;
|
|
2445
|
+
name: string;
|
|
2446
|
+
payload: Record<string, unknown> | null;
|
|
2447
|
+
createdAt: number;
|
|
2448
|
+
expiresAt: number;
|
|
2449
|
+
}>;
|
|
2450
|
+
}>>;
|
|
2451
|
+
/** Acknowledge a visitor message so it is not delivered again. */
|
|
2452
|
+
ackVisitorMessage(messageId: string, visitorId: string): Promise<SdkResult<{
|
|
2453
|
+
ok: boolean;
|
|
2454
|
+
}>>;
|
|
2422
2455
|
/** Get basic shop info */
|
|
2423
2456
|
getShopInfo(): Promise<SdkResult<ShopInfo>>;
|
|
2424
2457
|
/** Get SEO metadata for the shop homepage in the given locale (defaults to shop default). */
|
|
@@ -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;
|
|
@@ -2419,6 +2433,25 @@ declare class BehioStorefront {
|
|
|
2419
2433
|
percent: number;
|
|
2420
2434
|
expiresAt: number;
|
|
2421
2435
|
}>>;
|
|
2436
|
+
/**
|
|
2437
|
+
* Visitor messages from merchant automations (storefront.event action).
|
|
2438
|
+
* Consent-gated visitor id; each message carries a merchant-defined `name`
|
|
2439
|
+
* and free-form `payload` the template reacts to (modal, banner, ...).
|
|
2440
|
+
* Messages stay listed until acknowledged via `ackVisitorMessage`.
|
|
2441
|
+
*/
|
|
2442
|
+
getVisitorMessages(visitorId: string): Promise<SdkResult<{
|
|
2443
|
+
items: Array<{
|
|
2444
|
+
id: string;
|
|
2445
|
+
name: string;
|
|
2446
|
+
payload: Record<string, unknown> | null;
|
|
2447
|
+
createdAt: number;
|
|
2448
|
+
expiresAt: number;
|
|
2449
|
+
}>;
|
|
2450
|
+
}>>;
|
|
2451
|
+
/** Acknowledge a visitor message so it is not delivered again. */
|
|
2452
|
+
ackVisitorMessage(messageId: string, visitorId: string): Promise<SdkResult<{
|
|
2453
|
+
ok: boolean;
|
|
2454
|
+
}>>;
|
|
2422
2455
|
/** Get basic shop info */
|
|
2423
2456
|
getShopInfo(): Promise<SdkResult<ShopInfo>>;
|
|
2424
2457
|
/** Get SEO metadata for the shop homepage in the given locale (defaults to shop default). */
|
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-
|
|
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-
|
|
1
|
+
import { P as ProductDetail, a as ProductVariant, B as BehioStorefront, S as SdkResult, C as CookieConsent } from './client-C635vSzU.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-C635vSzU.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-
|
|
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-
|
|
1
|
+
import { P as ProductDetail, a as ProductVariant, B as BehioStorefront, S as SdkResult, C as CookieConsent } from './client-C635vSzU.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-C635vSzU.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
|
|
13
|
+
var _chunkCY6D2YEIjs = require('./chunk-CY6D2YEI.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 =
|
|
246
|
+
exports.AddressTypes = _chunkCY6D2YEIjs.AddressTypes; exports.BehioApiError = _chunkCY6D2YEIjs.BehioApiError; exports.BehioNetworkError = _chunkCY6D2YEIjs.BehioNetworkError; exports.BehioStorefront = _chunkCY6D2YEIjs.BehioStorefront; exports.FulfillmentStatuses = _chunkCY6D2YEIjs.FulfillmentStatuses; exports.OrderStatuses = _chunkCY6D2YEIjs.OrderStatuses; exports.PaymentStatuses = _chunkCY6D2YEIjs.PaymentStatuses; exports.ProductSort = _chunkCY6D2YEIjs.ProductSort; exports.VARIANT_QUERY_PARAM = VARIANT_QUERY_PARAM; exports.availableAxisValues = availableAxisValues; exports.buildVariantComparison = buildVariantComparison; exports.err = _chunkCY6D2YEIjs.err; exports.findVariantByAttributes = findVariantByAttributes; exports.formatPrice = formatPrice; exports.generateVisitorId = generateVisitorId; exports.getStoredVisitorId = getStoredVisitorId; exports.grantAnalyticsConsent = grantAnalyticsConsent; exports.ok = _chunkCY6D2YEIjs.ok; exports.resolveVariantContent = resolveVariantContent; exports.revokeAnalyticsConsent = revokeAnalyticsConsent; exports.toSdkError = _chunkCY6D2YEIjs.toSdkError; exports.trackEcommerceEvent = trackEcommerceEvent; exports.variantFromQuery = variantFromQuery; exports.variantHref = variantHref;
|
package/dist/index.mjs
CHANGED
package/dist/next.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { o as BehioStorefrontConfig, B as BehioStorefront } from './client-
|
|
1
|
+
import { o as BehioStorefrontConfig, B as BehioStorefront } from './client-C635vSzU.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-
|
|
1
|
+
import { o as BehioStorefrontConfig, B as BehioStorefront } from './client-C635vSzU.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
|
|
3
|
+
var _chunkCY6D2YEIjs = require('./chunk-CY6D2YEI.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,
|
|
21
|
+
const client = new (0, _chunkCY6D2YEIjs.BehioStorefront)({
|
|
22
22
|
apiKey,
|
|
23
23
|
...baseUrl ? { baseUrl } : {},
|
|
24
24
|
...locale ? { locale } : {},
|
package/dist/next.mjs
CHANGED
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;
|
|
@@ -2463,6 +2477,25 @@ declare class BehioStorefront {
|
|
|
2463
2477
|
percent: number;
|
|
2464
2478
|
expiresAt: number;
|
|
2465
2479
|
}>>;
|
|
2480
|
+
/**
|
|
2481
|
+
* Visitor messages from merchant automations (storefront.event action).
|
|
2482
|
+
* Consent-gated visitor id; each message carries a merchant-defined `name`
|
|
2483
|
+
* and free-form `payload` the template reacts to (modal, banner, ...).
|
|
2484
|
+
* Messages stay listed until acknowledged via `ackVisitorMessage`.
|
|
2485
|
+
*/
|
|
2486
|
+
getVisitorMessages(visitorId: string): Promise<SdkResult<{
|
|
2487
|
+
items: Array<{
|
|
2488
|
+
id: string;
|
|
2489
|
+
name: string;
|
|
2490
|
+
payload: Record<string, unknown> | null;
|
|
2491
|
+
createdAt: number;
|
|
2492
|
+
expiresAt: number;
|
|
2493
|
+
}>;
|
|
2494
|
+
}>>;
|
|
2495
|
+
/** Acknowledge a visitor message so it is not delivered again. */
|
|
2496
|
+
ackVisitorMessage(messageId: string, visitorId: string): Promise<SdkResult<{
|
|
2497
|
+
ok: boolean;
|
|
2498
|
+
}>>;
|
|
2466
2499
|
/** Get basic shop info */
|
|
2467
2500
|
getShopInfo(): Promise<SdkResult<ShopInfo>>;
|
|
2468
2501
|
/** Get SEO metadata for the shop homepage in the given locale (defaults to shop default). */
|
|
@@ -3733,6 +3766,60 @@ declare function usePersonalOffers(options?: UsePersonalOffersOptions): {
|
|
|
3733
3766
|
claimError: Error | null;
|
|
3734
3767
|
};
|
|
3735
3768
|
|
|
3769
|
+
/**
|
|
3770
|
+
* One message from a merchant automation (storefront.event action). `name`
|
|
3771
|
+
* and `payload` are merchant-defined in the automation builder; the template
|
|
3772
|
+
* decides how to react (modal, banner, toast, anything).
|
|
3773
|
+
*/
|
|
3774
|
+
interface VisitorMessage {
|
|
3775
|
+
id: string;
|
|
3776
|
+
name: string;
|
|
3777
|
+
payload: Record<string, unknown> | null;
|
|
3778
|
+
/** Epoch ms. */
|
|
3779
|
+
createdAt: number;
|
|
3780
|
+
/** Epoch ms. */
|
|
3781
|
+
expiresAt: number;
|
|
3782
|
+
}
|
|
3783
|
+
interface UseVisitorMessagesOptions {
|
|
3784
|
+
/**
|
|
3785
|
+
* Consent-gated analytics visitor id. When omitted the hook polls
|
|
3786
|
+
* `client.getAnalyticsVisitorId()` until the tracker resolves consent.
|
|
3787
|
+
*/
|
|
3788
|
+
visitorId?: string;
|
|
3789
|
+
enabled?: boolean;
|
|
3790
|
+
/** Poll interval in ms (default 30000). Set 0 to fetch only on mount/focus. */
|
|
3791
|
+
pollMs?: number;
|
|
3792
|
+
/**
|
|
3793
|
+
* Called once per delivered message. Acknowledge with the returned `ack`
|
|
3794
|
+
* (or call `ack(message.id)` yourself later) so the message is not shown
|
|
3795
|
+
* again on the next page view.
|
|
3796
|
+
*/
|
|
3797
|
+
onMessage?: (message: VisitorMessage) => void;
|
|
3798
|
+
/**
|
|
3799
|
+
* Also dispatch each delivered message as a `behio:visitor-message`
|
|
3800
|
+
* CustomEvent on `window` (detail = the message). Lets merchants react
|
|
3801
|
+
* with plain JS outside React. Default true.
|
|
3802
|
+
*/
|
|
3803
|
+
dispatchDomEvents?: boolean;
|
|
3804
|
+
}
|
|
3805
|
+
/**
|
|
3806
|
+
* Visitor messages channel: pull-based delivery of automation events to the
|
|
3807
|
+
* storefront. Consent-gated - without an analytics visitor id the hook stays
|
|
3808
|
+
* idle, so it is always safe to mount. Typical use: show a modal when an
|
|
3809
|
+
* automation sends `storefront.event` with name "sleva-modal".
|
|
3810
|
+
*/
|
|
3811
|
+
declare function useVisitorMessages(options?: UseVisitorMessagesOptions): {
|
|
3812
|
+
messages: VisitorMessage[];
|
|
3813
|
+
isLoading: boolean;
|
|
3814
|
+
error: Error | null;
|
|
3815
|
+
refetch: (options?: _tanstack_query_core.RefetchOptions) => Promise<_tanstack_query_core.QueryObserverResult<NoInfer<{
|
|
3816
|
+
items: VisitorMessage[];
|
|
3817
|
+
}>, Error>>;
|
|
3818
|
+
/** Mark a message as shown; it will not be delivered again. */
|
|
3819
|
+
ack: (messageId: string) => Promise<boolean>;
|
|
3820
|
+
visitorId: string | null;
|
|
3821
|
+
};
|
|
3822
|
+
|
|
3736
3823
|
/** One Behio Analytics ingest event (mirrors the public analytics DTO). */
|
|
3737
3824
|
interface AnalyticsEventInput {
|
|
3738
3825
|
type: "pageview" | "ecommerce" | "custom";
|
|
@@ -4666,4 +4753,4 @@ declare function revokeAnalyticsConsent(client: BehioStorefront): Promise<SdkRes
|
|
|
4666
4753
|
success: boolean;
|
|
4667
4754
|
}>>;
|
|
4668
4755
|
|
|
4669
|
-
export { type ActivePromotion, type AddToCartInput, type AnalyticsEventInput, type AuthTokens, BehioAnalyticsTracker, BehioApiError, BehioProvider, type BehioProviderProps, type Bundle, type BundleItem, type Cart, type CartDiscount, type CartItem, type Category, type CategoryDetail, type CheckoutAddress, type CheckoutInput, type CookieConsent, type CookieConsentInput, type CrossSellItem, CurrencySwitcher, type CurrencySwitcherProps, type CurrencySwitcherRenderProps, type CustomerAddress, type CustomerProfile, type EcommerceEventName, type EcommerceItem, type EcommercePayload, type Facet, type FacetRange, type FacetValue, type FacetsResponse, type FilterField, type FulfillmentStatus, type GiftCardBalance, type LoginInput, type MessageResponse, type OrderDetail, type OrderItem, type OrderListItem, type OrderStatus, type Page, type PageDetail, type PaginatedResponse, type PaymentStatus, type PersonalOffer, type ProductDetail, type ProductLabel, type ProductListItem, type ProductParameter, type ProductParameterGroup, type ProductParametersResponse, type ProductPrice, type ProductReview, type ProductReviewsResponse, type ProductVariant, type ProductsQuery, type QuoteRequest, type RegisterInput, type ReturnRequest, type ShopInfo, type ShopSeo, type StorageAdapter, StorefrontScripts, type StorefrontScriptsProps, type SubmitQuoteInput, type SubmitReturnInput, type SubmitReviewInput, type UseAddressAutocompleteOptions, type UseAddressAutocompleteReturn, type UseAddressesOptions, type UseCartCountOptions, type UseCartOptions, type UseCategoriesOptions, type UseCategoryOptions, type UseCertificateVerificationOptions, type UseCourseCertificatesOptions, type UseCourseOptions, type UseCoursesOptions, type UseCurrencyResult, type UseCustomerOptions, type UseFacetsOptions, type UseFeaturedOptions, type UseFiltersOptions, type UseLabelsOptions, type UseLessonCommentsOptions, type UseLessonNoteOptions, type UseLessonQuizOptions, type UseLessonTutorOptions, type UseLoyaltyOptions, type UseMenuOptions, type UseOrderOptions, type UseOrdersOptions, type UsePageOptions, type UsePagesOptions, type UsePaymentMethodsOptions, type UsePersonalOffersOptions, type UseProductOptions, type UseProductParametersOptions, type UseProductsOptions, type UseSearchOptions, type UseShippingMethodsOptions, type UseShippingQuoteOptions, type UseShopInfoOptions, type UseShopScriptsOptions, type UseShopSeoOptions, type UseSubscriptionsOptions, type WishlistItem, cookieStorage, createMemoryStorage, detectStorage, formatPrice, generateVisitorId, getStoredVisitorId, grantAnalyticsConsent, localStorageAdapter, memoryStorage, revokeAnalyticsConsent, trackEcommerceEvent, useAddressAutocomplete, useAddresses, useAnalyticsEvents, useAuth, useBehio, useBehioClient, useBundle, useBundles, useCart, useCartCount, useCategories, useCategory, useCertificateVerification, useCheckout, useCookieConsent, useCourse, useCourseCertificates, useCourses, useCrossSell, useCurrency, useCustomer, useFacets, useFeatured, useFilters, useGiftCardBalance, useIsInWishlist, useLabels, useLessonComments, useLessonNote, useLessonQuiz, useLessonTutor, useLookupReturnableOrder, useLoyalty, useMenu, useNewsletterSubscribe, useNewsletterUnsubscribe, useNotifyWhenAvailable, useOrder, useOrderAccess, useOrders, usePage, usePages, usePaymentMethods, usePersonalOffers, usePickupPoints, useProduct, useProductGroup, useProductParameters, useProductPromotions, useProductReviews, useProducts, useQuoteStatus, useReturnStatus, useSearch, useShippingMethods, useShippingQuote, useShopInfo, useShopScripts, useShopSeo, useSubmitQuote, useSubmitReturn, useSubmitReview, useSubscriptions, useWishlist };
|
|
4756
|
+
export { type ActivePromotion, type AddToCartInput, type AnalyticsEventInput, type AuthTokens, BehioAnalyticsTracker, BehioApiError, BehioProvider, type BehioProviderProps, type Bundle, type BundleItem, type Cart, type CartDiscount, type CartItem, type Category, type CategoryDetail, type CheckoutAddress, type CheckoutInput, type CookieConsent, type CookieConsentInput, type CrossSellItem, CurrencySwitcher, type CurrencySwitcherProps, type CurrencySwitcherRenderProps, type CustomerAddress, type CustomerProfile, type EcommerceEventName, type EcommerceItem, type EcommercePayload, type Facet, type FacetRange, type FacetValue, type FacetsResponse, type FilterField, type FulfillmentStatus, type GiftCardBalance, type LoginInput, type MessageResponse, type OrderDetail, type OrderItem, type OrderListItem, type OrderStatus, type Page, type PageDetail, type PaginatedResponse, type PaymentStatus, type PersonalOffer, type ProductDetail, type ProductLabel, type ProductListItem, type ProductParameter, type ProductParameterGroup, type ProductParametersResponse, type ProductPrice, type ProductReview, type ProductReviewsResponse, type ProductVariant, type ProductsQuery, type QuoteRequest, type RegisterInput, type ReturnRequest, type ShopInfo, type ShopSeo, type StorageAdapter, StorefrontScripts, type StorefrontScriptsProps, type SubmitQuoteInput, type SubmitReturnInput, type SubmitReviewInput, type UseAddressAutocompleteOptions, type UseAddressAutocompleteReturn, type UseAddressesOptions, type UseCartCountOptions, type UseCartOptions, type UseCategoriesOptions, type UseCategoryOptions, type UseCertificateVerificationOptions, type UseCourseCertificatesOptions, type UseCourseOptions, type UseCoursesOptions, type UseCurrencyResult, type UseCustomerOptions, type UseFacetsOptions, type UseFeaturedOptions, type UseFiltersOptions, type UseLabelsOptions, type UseLessonCommentsOptions, type UseLessonNoteOptions, type UseLessonQuizOptions, type UseLessonTutorOptions, type UseLoyaltyOptions, type UseMenuOptions, type UseOrderOptions, type UseOrdersOptions, type UsePageOptions, type UsePagesOptions, type UsePaymentMethodsOptions, type UsePersonalOffersOptions, type UseProductOptions, type UseProductParametersOptions, type UseProductsOptions, type UseSearchOptions, type UseShippingMethodsOptions, type UseShippingQuoteOptions, type UseShopInfoOptions, type UseShopScriptsOptions, type UseShopSeoOptions, type UseSubscriptionsOptions, type UseVisitorMessagesOptions, type VisitorMessage, type WishlistItem, cookieStorage, createMemoryStorage, detectStorage, formatPrice, generateVisitorId, getStoredVisitorId, grantAnalyticsConsent, localStorageAdapter, memoryStorage, revokeAnalyticsConsent, trackEcommerceEvent, useAddressAutocomplete, useAddresses, useAnalyticsEvents, useAuth, useBehio, useBehioClient, useBundle, useBundles, useCart, useCartCount, useCategories, useCategory, useCertificateVerification, useCheckout, useCookieConsent, useCourse, useCourseCertificates, useCourses, useCrossSell, useCurrency, useCustomer, useFacets, useFeatured, useFilters, useGiftCardBalance, useIsInWishlist, useLabels, useLessonComments, useLessonNote, useLessonQuiz, useLessonTutor, useLookupReturnableOrder, useLoyalty, useMenu, useNewsletterSubscribe, useNewsletterUnsubscribe, useNotifyWhenAvailable, useOrder, useOrderAccess, useOrders, usePage, usePages, usePaymentMethods, usePersonalOffers, usePickupPoints, useProduct, useProductGroup, useProductParameters, useProductPromotions, useProductReviews, useProducts, useQuoteStatus, useReturnStatus, useSearch, useShippingMethods, useShippingQuote, useShopInfo, useShopScripts, useShopSeo, useSubmitQuote, useSubmitReturn, useSubmitReview, useSubscriptions, useVisitorMessages, useWishlist };
|
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;
|
|
@@ -2463,6 +2477,25 @@ declare class BehioStorefront {
|
|
|
2463
2477
|
percent: number;
|
|
2464
2478
|
expiresAt: number;
|
|
2465
2479
|
}>>;
|
|
2480
|
+
/**
|
|
2481
|
+
* Visitor messages from merchant automations (storefront.event action).
|
|
2482
|
+
* Consent-gated visitor id; each message carries a merchant-defined `name`
|
|
2483
|
+
* and free-form `payload` the template reacts to (modal, banner, ...).
|
|
2484
|
+
* Messages stay listed until acknowledged via `ackVisitorMessage`.
|
|
2485
|
+
*/
|
|
2486
|
+
getVisitorMessages(visitorId: string): Promise<SdkResult<{
|
|
2487
|
+
items: Array<{
|
|
2488
|
+
id: string;
|
|
2489
|
+
name: string;
|
|
2490
|
+
payload: Record<string, unknown> | null;
|
|
2491
|
+
createdAt: number;
|
|
2492
|
+
expiresAt: number;
|
|
2493
|
+
}>;
|
|
2494
|
+
}>>;
|
|
2495
|
+
/** Acknowledge a visitor message so it is not delivered again. */
|
|
2496
|
+
ackVisitorMessage(messageId: string, visitorId: string): Promise<SdkResult<{
|
|
2497
|
+
ok: boolean;
|
|
2498
|
+
}>>;
|
|
2466
2499
|
/** Get basic shop info */
|
|
2467
2500
|
getShopInfo(): Promise<SdkResult<ShopInfo>>;
|
|
2468
2501
|
/** Get SEO metadata for the shop homepage in the given locale (defaults to shop default). */
|
|
@@ -3733,6 +3766,60 @@ declare function usePersonalOffers(options?: UsePersonalOffersOptions): {
|
|
|
3733
3766
|
claimError: Error | null;
|
|
3734
3767
|
};
|
|
3735
3768
|
|
|
3769
|
+
/**
|
|
3770
|
+
* One message from a merchant automation (storefront.event action). `name`
|
|
3771
|
+
* and `payload` are merchant-defined in the automation builder; the template
|
|
3772
|
+
* decides how to react (modal, banner, toast, anything).
|
|
3773
|
+
*/
|
|
3774
|
+
interface VisitorMessage {
|
|
3775
|
+
id: string;
|
|
3776
|
+
name: string;
|
|
3777
|
+
payload: Record<string, unknown> | null;
|
|
3778
|
+
/** Epoch ms. */
|
|
3779
|
+
createdAt: number;
|
|
3780
|
+
/** Epoch ms. */
|
|
3781
|
+
expiresAt: number;
|
|
3782
|
+
}
|
|
3783
|
+
interface UseVisitorMessagesOptions {
|
|
3784
|
+
/**
|
|
3785
|
+
* Consent-gated analytics visitor id. When omitted the hook polls
|
|
3786
|
+
* `client.getAnalyticsVisitorId()` until the tracker resolves consent.
|
|
3787
|
+
*/
|
|
3788
|
+
visitorId?: string;
|
|
3789
|
+
enabled?: boolean;
|
|
3790
|
+
/** Poll interval in ms (default 30000). Set 0 to fetch only on mount/focus. */
|
|
3791
|
+
pollMs?: number;
|
|
3792
|
+
/**
|
|
3793
|
+
* Called once per delivered message. Acknowledge with the returned `ack`
|
|
3794
|
+
* (or call `ack(message.id)` yourself later) so the message is not shown
|
|
3795
|
+
* again on the next page view.
|
|
3796
|
+
*/
|
|
3797
|
+
onMessage?: (message: VisitorMessage) => void;
|
|
3798
|
+
/**
|
|
3799
|
+
* Also dispatch each delivered message as a `behio:visitor-message`
|
|
3800
|
+
* CustomEvent on `window` (detail = the message). Lets merchants react
|
|
3801
|
+
* with plain JS outside React. Default true.
|
|
3802
|
+
*/
|
|
3803
|
+
dispatchDomEvents?: boolean;
|
|
3804
|
+
}
|
|
3805
|
+
/**
|
|
3806
|
+
* Visitor messages channel: pull-based delivery of automation events to the
|
|
3807
|
+
* storefront. Consent-gated - without an analytics visitor id the hook stays
|
|
3808
|
+
* idle, so it is always safe to mount. Typical use: show a modal when an
|
|
3809
|
+
* automation sends `storefront.event` with name "sleva-modal".
|
|
3810
|
+
*/
|
|
3811
|
+
declare function useVisitorMessages(options?: UseVisitorMessagesOptions): {
|
|
3812
|
+
messages: VisitorMessage[];
|
|
3813
|
+
isLoading: boolean;
|
|
3814
|
+
error: Error | null;
|
|
3815
|
+
refetch: (options?: _tanstack_query_core.RefetchOptions) => Promise<_tanstack_query_core.QueryObserverResult<NoInfer<{
|
|
3816
|
+
items: VisitorMessage[];
|
|
3817
|
+
}>, Error>>;
|
|
3818
|
+
/** Mark a message as shown; it will not be delivered again. */
|
|
3819
|
+
ack: (messageId: string) => Promise<boolean>;
|
|
3820
|
+
visitorId: string | null;
|
|
3821
|
+
};
|
|
3822
|
+
|
|
3736
3823
|
/** One Behio Analytics ingest event (mirrors the public analytics DTO). */
|
|
3737
3824
|
interface AnalyticsEventInput {
|
|
3738
3825
|
type: "pageview" | "ecommerce" | "custom";
|
|
@@ -4666,4 +4753,4 @@ declare function revokeAnalyticsConsent(client: BehioStorefront): Promise<SdkRes
|
|
|
4666
4753
|
success: boolean;
|
|
4667
4754
|
}>>;
|
|
4668
4755
|
|
|
4669
|
-
export { type ActivePromotion, type AddToCartInput, type AnalyticsEventInput, type AuthTokens, BehioAnalyticsTracker, BehioApiError, BehioProvider, type BehioProviderProps, type Bundle, type BundleItem, type Cart, type CartDiscount, type CartItem, type Category, type CategoryDetail, type CheckoutAddress, type CheckoutInput, type CookieConsent, type CookieConsentInput, type CrossSellItem, CurrencySwitcher, type CurrencySwitcherProps, type CurrencySwitcherRenderProps, type CustomerAddress, type CustomerProfile, type EcommerceEventName, type EcommerceItem, type EcommercePayload, type Facet, type FacetRange, type FacetValue, type FacetsResponse, type FilterField, type FulfillmentStatus, type GiftCardBalance, type LoginInput, type MessageResponse, type OrderDetail, type OrderItem, type OrderListItem, type OrderStatus, type Page, type PageDetail, type PaginatedResponse, type PaymentStatus, type PersonalOffer, type ProductDetail, type ProductLabel, type ProductListItem, type ProductParameter, type ProductParameterGroup, type ProductParametersResponse, type ProductPrice, type ProductReview, type ProductReviewsResponse, type ProductVariant, type ProductsQuery, type QuoteRequest, type RegisterInput, type ReturnRequest, type ShopInfo, type ShopSeo, type StorageAdapter, StorefrontScripts, type StorefrontScriptsProps, type SubmitQuoteInput, type SubmitReturnInput, type SubmitReviewInput, type UseAddressAutocompleteOptions, type UseAddressAutocompleteReturn, type UseAddressesOptions, type UseCartCountOptions, type UseCartOptions, type UseCategoriesOptions, type UseCategoryOptions, type UseCertificateVerificationOptions, type UseCourseCertificatesOptions, type UseCourseOptions, type UseCoursesOptions, type UseCurrencyResult, type UseCustomerOptions, type UseFacetsOptions, type UseFeaturedOptions, type UseFiltersOptions, type UseLabelsOptions, type UseLessonCommentsOptions, type UseLessonNoteOptions, type UseLessonQuizOptions, type UseLessonTutorOptions, type UseLoyaltyOptions, type UseMenuOptions, type UseOrderOptions, type UseOrdersOptions, type UsePageOptions, type UsePagesOptions, type UsePaymentMethodsOptions, type UsePersonalOffersOptions, type UseProductOptions, type UseProductParametersOptions, type UseProductsOptions, type UseSearchOptions, type UseShippingMethodsOptions, type UseShippingQuoteOptions, type UseShopInfoOptions, type UseShopScriptsOptions, type UseShopSeoOptions, type UseSubscriptionsOptions, type WishlistItem, cookieStorage, createMemoryStorage, detectStorage, formatPrice, generateVisitorId, getStoredVisitorId, grantAnalyticsConsent, localStorageAdapter, memoryStorage, revokeAnalyticsConsent, trackEcommerceEvent, useAddressAutocomplete, useAddresses, useAnalyticsEvents, useAuth, useBehio, useBehioClient, useBundle, useBundles, useCart, useCartCount, useCategories, useCategory, useCertificateVerification, useCheckout, useCookieConsent, useCourse, useCourseCertificates, useCourses, useCrossSell, useCurrency, useCustomer, useFacets, useFeatured, useFilters, useGiftCardBalance, useIsInWishlist, useLabels, useLessonComments, useLessonNote, useLessonQuiz, useLessonTutor, useLookupReturnableOrder, useLoyalty, useMenu, useNewsletterSubscribe, useNewsletterUnsubscribe, useNotifyWhenAvailable, useOrder, useOrderAccess, useOrders, usePage, usePages, usePaymentMethods, usePersonalOffers, usePickupPoints, useProduct, useProductGroup, useProductParameters, useProductPromotions, useProductReviews, useProducts, useQuoteStatus, useReturnStatus, useSearch, useShippingMethods, useShippingQuote, useShopInfo, useShopScripts, useShopSeo, useSubmitQuote, useSubmitReturn, useSubmitReview, useSubscriptions, useWishlist };
|
|
4756
|
+
export { type ActivePromotion, type AddToCartInput, type AnalyticsEventInput, type AuthTokens, BehioAnalyticsTracker, BehioApiError, BehioProvider, type BehioProviderProps, type Bundle, type BundleItem, type Cart, type CartDiscount, type CartItem, type Category, type CategoryDetail, type CheckoutAddress, type CheckoutInput, type CookieConsent, type CookieConsentInput, type CrossSellItem, CurrencySwitcher, type CurrencySwitcherProps, type CurrencySwitcherRenderProps, type CustomerAddress, type CustomerProfile, type EcommerceEventName, type EcommerceItem, type EcommercePayload, type Facet, type FacetRange, type FacetValue, type FacetsResponse, type FilterField, type FulfillmentStatus, type GiftCardBalance, type LoginInput, type MessageResponse, type OrderDetail, type OrderItem, type OrderListItem, type OrderStatus, type Page, type PageDetail, type PaginatedResponse, type PaymentStatus, type PersonalOffer, type ProductDetail, type ProductLabel, type ProductListItem, type ProductParameter, type ProductParameterGroup, type ProductParametersResponse, type ProductPrice, type ProductReview, type ProductReviewsResponse, type ProductVariant, type ProductsQuery, type QuoteRequest, type RegisterInput, type ReturnRequest, type ShopInfo, type ShopSeo, type StorageAdapter, StorefrontScripts, type StorefrontScriptsProps, type SubmitQuoteInput, type SubmitReturnInput, type SubmitReviewInput, type UseAddressAutocompleteOptions, type UseAddressAutocompleteReturn, type UseAddressesOptions, type UseCartCountOptions, type UseCartOptions, type UseCategoriesOptions, type UseCategoryOptions, type UseCertificateVerificationOptions, type UseCourseCertificatesOptions, type UseCourseOptions, type UseCoursesOptions, type UseCurrencyResult, type UseCustomerOptions, type UseFacetsOptions, type UseFeaturedOptions, type UseFiltersOptions, type UseLabelsOptions, type UseLessonCommentsOptions, type UseLessonNoteOptions, type UseLessonQuizOptions, type UseLessonTutorOptions, type UseLoyaltyOptions, type UseMenuOptions, type UseOrderOptions, type UseOrdersOptions, type UsePageOptions, type UsePagesOptions, type UsePaymentMethodsOptions, type UsePersonalOffersOptions, type UseProductOptions, type UseProductParametersOptions, type UseProductsOptions, type UseSearchOptions, type UseShippingMethodsOptions, type UseShippingQuoteOptions, type UseShopInfoOptions, type UseShopScriptsOptions, type UseShopSeoOptions, type UseSubscriptionsOptions, type UseVisitorMessagesOptions, type VisitorMessage, type WishlistItem, cookieStorage, createMemoryStorage, detectStorage, formatPrice, generateVisitorId, getStoredVisitorId, grantAnalyticsConsent, localStorageAdapter, memoryStorage, revokeAnalyticsConsent, trackEcommerceEvent, useAddressAutocomplete, useAddresses, useAnalyticsEvents, useAuth, useBehio, useBehioClient, useBundle, useBundles, useCart, useCartCount, useCategories, useCategory, useCertificateVerification, useCheckout, useCookieConsent, useCourse, useCourseCertificates, useCourses, useCrossSell, useCurrency, useCustomer, useFacets, useFeatured, useFilters, useGiftCardBalance, useIsInWishlist, useLabels, useLessonComments, useLessonNote, useLessonQuiz, useLessonTutor, useLookupReturnableOrder, useLoyalty, useMenu, useNewsletterSubscribe, useNewsletterUnsubscribe, useNotifyWhenAvailable, useOrder, useOrderAccess, useOrders, usePage, usePages, usePaymentMethods, usePersonalOffers, usePickupPoints, useProduct, useProductGroup, useProductParameters, useProductPromotions, useProductReviews, useProducts, useQuoteStatus, useReturnStatus, useSearch, useShippingMethods, useShippingQuote, useShopInfo, useShopScripts, useShopSeo, useSubmitQuote, useSubmitReturn, useSubmitReview, useSubscriptions, useVisitorMessages, useWishlist };
|