@behio/storefront-sdk 0.32.0 → 0.34.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.
@@ -100,7 +100,21 @@ interface CheckoutSettings {
100
100
  lowStockThreshold: number;
101
101
  /** Google Places address autocomplete is enabled; mount the UX when true. */
102
102
  addressAutocompleteEnabled: boolean;
103
+ /**
104
+ * How prices are presented to the customer (GAP-30):
105
+ * - `INCL_VAT` (default, B2C): catalog/cart prices already include VAT; the
106
+ * VAT breakdown is the portion contained within.
107
+ * - `EXCL_VAT` (B2B): prices are net; render "bez DPH" labels and show VAT
108
+ * added on top.
109
+ * - `CUSTOMER_CHOICE`: the customer toggles incl/excl.
110
+ * Pair with per-line `taxRate` + cart/order `taxBreakdown` to render VAT rows.
111
+ */
112
+ priceDisplay: PriceDisplay;
113
+ /** Shop default VAT rate (percent, e.g. 21) for labelling a single-rate cart. */
114
+ vatRate: number;
103
115
  }
116
+ /** Price presentation mode (Eshop.priceDisplay). See `CheckoutSettings.priceDisplay`. */
117
+ type PriceDisplay = "INCL_VAT" | "EXCL_VAT" | "CUSTOMER_CHOICE";
104
118
  interface ShopInfo {
105
119
  id: string;
106
120
  name: string;
@@ -125,6 +139,20 @@ interface ShopInfo {
125
139
  quotesEnabled: boolean;
126
140
  /** Full merchant checkout & cart contract. Honour these in cart + checkout. */
127
141
  checkout: CheckoutSettings;
142
+ /**
143
+ * Public shop identity for SEO / structured data (GAP-31). Reads of existing
144
+ * merchant data — feed into the Organization JSON-LD and degrade gracefully
145
+ * on nulls. Optional because cached ShopInfo payloads predating the field
146
+ * may still be served.
147
+ */
148
+ seo?: ShopSeoIdentity;
149
+ }
150
+ /** Public shop identity for SEO / structured data (GAP-31). */
151
+ interface ShopSeoIdentity {
152
+ /** Merchant shop description — Organization JSON-LD `description`. */
153
+ description: string | null;
154
+ /** Public contact e-mail (shop e-mail sender config) for ContactPoint. */
155
+ contactEmail: string | null;
128
156
  }
129
157
  interface NewsletterSubscribeInput {
130
158
  email: string;
@@ -245,7 +273,9 @@ interface ProductVariant {
245
273
  /** `null` when prices are gated behind login for guests (B2B mode). */
246
274
  price: ProductPrice | null;
247
275
  inStock: boolean;
248
- stockQuantity?: number;
276
+ /** Exact remaining stock, or `null` when the merchant hides the count
277
+ * (showStockCount off) — treat null as "unknown", never as 0. */
278
+ stockQuantity?: number | null;
249
279
  /** "Only X left" for this variant — same contract as ProductListItem.lowStockRemaining. */
250
280
  lowStockRemaining?: number | null;
251
281
  /**
@@ -298,7 +328,9 @@ interface ProductListItem {
298
328
  /** `null` when prices are gated behind login for guests (B2B mode). */
299
329
  price: ProductPrice | null;
300
330
  inStock: boolean;
301
- stockQuantity?: number;
331
+ /** Exact remaining stock, or `null` when the merchant hides the count
332
+ * (showStockCount off) — treat null as "unknown", never as 0. */
333
+ stockQuantity?: number | null;
302
334
  /**
303
335
  * "Zbývá posledních X kusů" nudge, computed SERVER-side. Non-null ONLY when
304
336
  * the merchant enabled the low-stock indicator AND 0 < stock <= threshold;
@@ -316,6 +348,57 @@ interface ProductListItem {
316
348
  } | null;
317
349
  labels: ProductLabel[];
318
350
  isFeatured: boolean;
351
+ /**
352
+ * Minimum order quantity (units); null/undefined = no minimum. Start the
353
+ * quantity stepper here — the server rejects add-to-cart / checkout below it.
354
+ */
355
+ minOrderQuantity?: number | null;
356
+ /**
357
+ * Order quantity step / multiple (units); null/undefined = any quantity. The
358
+ * stepper moves by this amount and the server rejects non-multiple quantities.
359
+ */
360
+ orderQuantityStep?: number | null;
361
+ /**
362
+ * Cheapest applicable auto-promotion for this product (GAP-13), or null. Same
363
+ * priority-based selection the checkout uses, so a card badge matches what the
364
+ * customer pays. Render a badge chip + a STATIC end date ("do 20. 7.") on
365
+ * cards; keep the live countdown on the PDP only (no per-card tickers).
366
+ */
367
+ activePromotion?: ProductPromotionSummary | null;
368
+ /**
369
+ * Rollover image URL for the card (GAP-27), from the product's HOVER-role
370
+ * image when the merchant set one. Null/absent = no hover image (show the
371
+ * cover only). Crossfade to it on desktop hover (opacity only, no transform).
372
+ */
373
+ hoverImageUrl?: string | null;
374
+ /**
375
+ * Aggregate rating from APPROVED reviews (GAP-23): mean 1-5 rating, or null
376
+ * when the product has no approved reviews. Server-computed + cached. Render
377
+ * gold stars only when `ratingCount > 0`; do NOT compute this from the
378
+ * paginated reviews endpoint.
379
+ */
380
+ ratingAverage?: number | null;
381
+ /** Number of approved reviews behind `ratingAverage` (0 when none). */
382
+ ratingCount?: number;
383
+ /**
384
+ * Last modification of the product record (epoch ms) — sitemap `lastmod`
385
+ * and `dateModified` structured data (GAP-31).
386
+ */
387
+ updatedAt?: number;
388
+ }
389
+ /** Display-only summary of the promotion winning for a card (GAP-13). */
390
+ interface ProductPromotionSummary {
391
+ promotionId: string;
392
+ /** Merchant badge label ("1+1"); null → render "-{discountValue} %" from the discount. */
393
+ badgeText: string | null;
394
+ /** Merchant hex badge color; null falls back to the shop's sale color. */
395
+ badgeColor: string | null;
396
+ discountType: 'PERCENTAGE' | 'FIXED_AMOUNT' | 'BUY_X_GET_Y';
397
+ discountValue: number;
398
+ /** Promotion end (epoch ms), or null for open-ended. */
399
+ endsAt: number | null;
400
+ /** Merchant opted into a countdown (the PDP shows a ticker; cards stay static). */
401
+ showCountdown: boolean;
319
402
  }
320
403
  /** A single responsive derivative (size + format) of a media image. */
321
404
  interface ProductMediaVariant {
@@ -363,13 +446,39 @@ interface VariantAxis {
363
446
  /** Values present among the purchasable variants, in admin-defined order. */
364
447
  values: VariantAxisValue[];
365
448
  }
449
+ /**
450
+ * One custom-field (data-group value) rendered as a spec-table row. BOOLEAN
451
+ * carries a typed `booleanValue` (value is null) so the storefront can localize
452
+ * Ano/Ne; MONEY carries its currency in `unit`; PERCENTAGE carries "%" in
453
+ * `unit`.
454
+ */
455
+ interface ProductCustomField {
456
+ key: string;
457
+ name: string;
458
+ /** TEXT | NUMBER | DECIMAL | BOOLEAN | DATE | TIME | DATETIME | PERCENTAGE | MONEY | ITEM_LIST | ... */
459
+ type: string;
460
+ value: string | null;
461
+ booleanValue: boolean | null;
462
+ unit: string | null;
463
+ }
464
+ /** A spec-table section (one inventory data group) with its fields. */
465
+ interface ProductCustomFieldGroup {
466
+ key: string;
467
+ name: string;
468
+ fields: ProductCustomField[];
469
+ }
366
470
  interface ProductDetail extends ProductListItem {
367
471
  longDescription?: string;
368
- /** @deprecated Legacy per-listing images. Prefer `media`. */
472
+ /**
473
+ * @deprecated Legacy per-listing images. Prefer `media`. Each carries its
474
+ * `role` (COVER | LISTING | HOVER | GALLERY) so the storefront can pick a
475
+ * specific image deliberately (GAP-27).
476
+ */
369
477
  images: Array<{
370
478
  url: string;
371
479
  alt?: string;
372
480
  order: number;
481
+ role?: string;
373
482
  }>;
374
483
  /** Product gallery (images + videos) with responsive derivatives. */
375
484
  media: ProductMedia[];
@@ -385,7 +494,15 @@ interface ProductDetail extends ProductListItem {
385
494
  */
386
495
  variantAxes: VariantAxis[];
387
496
  volumePricing: ProductVolumePrice[];
388
- customFields: Record<string, unknown>;
497
+ /**
498
+ * Structured product parameters from custom fields (inventory data groups),
499
+ * grouped into spec-table sections (GAP-12). Empty when the product has no
500
+ * data-group values. Distinct from `longDescription` (free HTML): this is
501
+ * machine-readable key/value data for a "Parametry" table + comparison
502
+ * engines. (Corrected from the old untyped `Record<string, unknown>` — the
503
+ * API never populated that; it now sends this structured shape.)
504
+ */
505
+ customFields: ProductCustomFieldGroup[];
389
506
  seo: {
390
507
  title?: string | null;
391
508
  description?: string | null;
@@ -601,6 +718,12 @@ interface CartItemProduct {
601
718
  imageUrl?: string;
602
719
  inStock: boolean;
603
720
  currentPrice: number;
721
+ /** Minimum order quantity (units); null = no minimum. Clamp the cart
722
+ * stepper's lower bound to this (GAP-48). */
723
+ minOrderQuantity?: number | null;
724
+ /** Order quantity step/multiple (units); null = any. Move the cart stepper
725
+ * by this amount so quantities stay valid. */
726
+ orderQuantityStep?: number | null;
604
727
  }
605
728
  interface CartItem {
606
729
  id: string;
@@ -616,6 +739,27 @@ interface CartItem {
616
739
  totalPrice: number;
617
740
  priceChanged: boolean;
618
741
  volumePriceApplied: boolean;
742
+ /** VAT rate for this line in percent (e.g. 21). Estimated from the shop /
743
+ * product rate; refined by the shipping country at checkout (GAP-30). */
744
+ taxRate: number;
745
+ /** Net amount for this line (without VAT) = totalPrice. */
746
+ netAmount: number;
747
+ /** VAT amount for this line at `taxRate`. */
748
+ taxAmount: number;
749
+ /** Gross amount for this line (net + VAT). */
750
+ grossAmount: number;
751
+ }
752
+ /** One VAT rate's slice of a cart or order (GAP-30). Render "DPH {rate} %:
753
+ * {taxAmount}" summary rows from these. `netAmount + taxAmount = grossAmount`. */
754
+ interface TaxBreakdownLine {
755
+ /** VAT rate in percent, e.g. 21 or 12 or 0. */
756
+ rate: number;
757
+ /** Base amount (net, without VAT) taxed at this rate. */
758
+ netAmount: number;
759
+ /** VAT amount charged at this rate. */
760
+ taxAmount: number;
761
+ /** Gross amount (net + VAT) at this rate. */
762
+ grossAmount: number;
619
763
  }
620
764
  interface CartDiscount {
621
765
  code: string;
@@ -643,6 +787,12 @@ interface Cart {
643
787
  /** Sum of `appliedPromotions[].discountAmount`; already reflected in `grandTotal`. */
644
788
  promotionDiscountTotal: number;
645
789
  grandTotal: number;
790
+ /** Total VAT contained in / added to the cart across all lines (GAP-30). An
791
+ * estimate finalized at checkout once the shipping country is known. */
792
+ taxTotal: number;
793
+ /** VAT split by rate for "DPH 21 %: X Kč" summary rows. Empty for a
794
+ * non-VAT-payer shop. */
795
+ taxBreakdown: TaxBreakdownLine[];
646
796
  currency: string;
647
797
  itemCount: number;
648
798
  /** Applied gift cards (multi). They deduct at checkout (consumed in order, each
@@ -808,6 +958,9 @@ interface OrderDetail extends OrderListItem {
808
958
  customerNote?: string;
809
959
  subtotal: number;
810
960
  taxTotal: number;
961
+ /** VAT split by rate (GAP-30), summed from the order lines. Render
962
+ * "DPH 21 %: X Kč" rows. Empty for a non-VAT order. */
963
+ taxBreakdown: TaxBreakdownLine[];
811
964
  shippingTotal: number;
812
965
  discountTotal: number;
813
966
  fulfillmentStatus: FulfillmentStatus;
@@ -888,6 +1041,14 @@ interface CustomerProfile {
888
1041
  lastName?: string;
889
1042
  phone?: string;
890
1043
  emailVerified: boolean;
1044
+ /**
1045
+ * B2B approval gate (GAP-19). `false` = the account is awaiting merchant
1046
+ * approval (or was deactivated) — show a "pending approval" banner and gate
1047
+ * ordering. `true` = approved / active. New registrations on a shop with
1048
+ * `requireRegistrationApproval` start unapproved and cannot log in until
1049
+ * approved (register returns `pendingApproval`).
1050
+ */
1051
+ isApproved: boolean;
891
1052
  }
892
1053
  interface CustomerAddress {
893
1054
  id: string;
@@ -906,6 +1067,8 @@ interface Page {
906
1067
  slug: string;
907
1068
  title: string;
908
1069
  isActive: boolean;
1070
+ /** Last modification of the page record (epoch ms) — sitemap `lastmod` (GAP-31). */
1071
+ updatedAt?: number;
909
1072
  }
910
1073
  interface PageDetail {
911
1074
  slug: string;
@@ -1320,6 +1483,46 @@ interface WishlistItem {
1320
1483
  stockCached: number;
1321
1484
  createdAt: number;
1322
1485
  }
1486
+ type SubscriptionStatus = "ACTIVE" | "PAUSED" | "CANCELLED" | "EXPIRED" | "PAYMENT_FAILED";
1487
+ type SubscriptionFrequency = "WEEKLY" | "BIWEEKLY" | "MONTHLY" | "BIMONTHLY" | "QUARTERLY" | "EVERY_6_MONTHS" | "YEARLY" | "CUSTOM_DAYS";
1488
+ interface SubscriptionItem {
1489
+ id: string;
1490
+ productId: string;
1491
+ product: {
1492
+ id: string;
1493
+ slug: string | null;
1494
+ };
1495
+ quantity: number;
1496
+ unitPriceSnapshot: number;
1497
+ currency: string;
1498
+ }
1499
+ interface Subscription {
1500
+ id: string;
1501
+ status: SubscriptionStatus;
1502
+ frequency: SubscriptionFrequency;
1503
+ /** For CUSTOM_DAYS frequency: order every N days. */
1504
+ customDays: number | null;
1505
+ /** Unix ms of the next scheduled order. */
1506
+ nextOrderAt: number;
1507
+ /** Unix ms of the last generated order, if any. */
1508
+ lastOrderAt: number | null;
1509
+ totalOrders: number;
1510
+ /** Max number of orders before the subscription expires (null = unlimited). */
1511
+ maxOrders: number | null;
1512
+ /** Subscriber discount percent applied to each generated order. */
1513
+ discountPercent: number | null;
1514
+ items: SubscriptionItem[];
1515
+ orderCount: number;
1516
+ createdAt: number;
1517
+ updatedAt: number;
1518
+ }
1519
+ interface SubscriptionAction {
1520
+ id: string;
1521
+ status: SubscriptionStatus;
1522
+ /** Present after resume — the newly scheduled next order (Unix ms). */
1523
+ nextOrderAt?: number | null;
1524
+ updatedAt: number;
1525
+ }
1323
1526
  interface ProductReview {
1324
1527
  id: string;
1325
1528
  authorName: string;
@@ -1523,6 +1726,7 @@ declare class BehioStorefront {
1523
1726
  readonly addresses: AddressModule;
1524
1727
  readonly shipping: ShippingModule;
1525
1728
  readonly newsletter: NewsletterModule;
1729
+ readonly subscriptions: SubscriptionsModule;
1526
1730
  /**
1527
1731
  * Called by the analytics tracker when the visitor grants (id) or revokes
1528
1732
  * (null) analytics consent. When set, requests carry the X-Behio-Vid header
@@ -1550,6 +1754,10 @@ declare class BehioStorefront {
1550
1754
  utmSource?: string;
1551
1755
  utmMedium?: string;
1552
1756
  utmCampaign?: string;
1757
+ utmTerm?: string;
1758
+ utmContent?: string;
1759
+ gclid?: string;
1760
+ fbclid?: string;
1553
1761
  dwellMs?: number;
1554
1762
  value?: number;
1555
1763
  currency?: string;
@@ -1943,6 +2151,24 @@ declare class WishlistModule {
1943
2151
  inWishlist: boolean;
1944
2152
  }>>;
1945
2153
  }
2154
+ declare class SubscriptionsModule {
2155
+ private client;
2156
+ constructor(client: BehioStorefront);
2157
+ /**
2158
+ * List the logged-in customer's recurring-order subscriptions (products,
2159
+ * cadence, next order date, status). Requires an authenticated customer
2160
+ * session. Subscriptions are created by the merchant in v1.
2161
+ */
2162
+ list(): Promise<SdkResult<{
2163
+ items: Subscription[];
2164
+ }>>;
2165
+ /** Pause an active subscription (no orders are generated while paused). */
2166
+ pause(subscriptionId: string): Promise<SdkResult<SubscriptionAction>>;
2167
+ /** Resume a paused subscription (re-schedules the next order). */
2168
+ resume(subscriptionId: string): Promise<SdkResult<SubscriptionAction>>;
2169
+ /** Cancel a subscription permanently (no more orders). */
2170
+ cancel(subscriptionId: string): Promise<SdkResult<SubscriptionAction>>;
2171
+ }
1946
2172
  declare class ReviewsModule {
1947
2173
  private client;
1948
2174
  constructor(client: BehioStorefront);
@@ -1984,6 +2210,14 @@ declare class QuotesModule {
1984
2210
  /** Email is the ownership gate — quotes carry contact PII and negotiated
1985
2211
  * prices, so the id alone is never enough. POST keeps it out of URLs. */
1986
2212
  getStatus(quoteId: string, email: string): Promise<SdkResult<QuoteRequest>>;
2213
+ /**
2214
+ * The logged-in customer's own quote requests ("Moje poptávky", GAP-18).
2215
+ * Requires an authenticated session; ownership is the auth token (customer id
2216
+ * + verified email), never a payload. Newest first.
2217
+ */
2218
+ listMine(): Promise<SdkResult<{
2219
+ items: QuoteRequest[];
2220
+ }>>;
1987
2221
  }
1988
2222
  interface AddressSuggestion {
1989
2223
  placeId: string;
@@ -2080,4 +2314,4 @@ declare class NewsletterModule {
2080
2314
  unsubscribe(email: string): Promise<SdkResult<NewsletterUnsubscribeResult>>;
2081
2315
  }
2082
2316
 
2083
- export { type BundleItem as $, type AddressSuggestion as A, type BehioStorefrontConfig as B, type Category as C, type ProductReviewsResponse as D, type SubmitReviewInput as E, type FilterField as F, type GiftCardBalance as G, type ReturnableOrder as H, type ReturnStatus as I, type ReturnRequest as J, type SubmitReturnInput as K, type LoyaltySummary as L, type Menu as M, type NewsletterSubscribeResult as N, type OrderListItem as O, type ProductsQuery as P, type CookieConsent as Q, type RegisterInput as R, type ShopInfo as S, type CookieConsentInput as T, type QuoteRequest as U, type SubmitQuoteInput as V, type WishlistItem as W, type BackInStockSubscription as X, type AddToCartInput as Y, type AuthTokens as Z, BehioApiError as _, BehioStorefront as a, type SdkError as a$, type CartDiscount as a0, type CartItem as a1, type CheckoutAddress as a2, type FulfillmentStatus as a3, type LoginInput as a4, type MessageResponse as a5, type OrderItem as a6, type OrderStatus as a7, type PaymentStatus as a8, type ProductPrice as a9, type LoyaltyTierPerks as aA, type LoyaltyTransaction as aB, type MenuItem as aC, type MenuItemRef as aD, type MenuItemType as aE, type NewsletterOptInDefault as aF, type OrderStatusHistory as aG, OrderStatuses as aH, type OrderTracking as aI, type PageAttachment as aJ, PaymentStatuses as aK, type PickupPointHours as aL, type ProductAvailability as aM, type ProductMedia as aN, type ProductMediaVariant as aO, ProductSort as aP, type ProductSortValue as aQ, type ProductVolumePrice as aR, type QuoteItem as aS, type RegisterResult as aT, type RequestInterceptor as aU, type RequestInterceptorConfig as aV, type ResponseInterceptor as aW, type ResponseInterceptorData as aX, type ReturnRequestItem as aY, type ReturnStatusItem as aZ, type ReturnableOrderItem as a_, type ProductReview as aa, type ProductVariant as ab, type AddressType as ac, AddressTypes as ad, type BadgeTone as ae, type BehioErrorCode as af, type BehioEventHandler as ag, type BehioEventType as ah, BehioNetworkError as ai, type CartBundleLine as aj, type CartBundleLineItem as ak, type CartItemProduct as al, type CartPromotion as am, type CheckoutPaymentMethod as an, type CheckoutSettings as ao, type DataGroupFieldType as ap, type DigitalDownload as aq, type DownloadUrl as ar, FulfillmentStatuses as as, type GiftCardPurchaseInput as at, type GiftCardPurchaseResult as au, type GiftCardSummary as av, type LoyaltyBalance as aw, type LoyaltyNextTier as ax, type LoyaltyProgram as ay, type LoyaltyTier as az, type PaginatedResponse as b, type SdkResult as b0, type ShippingMethodSummary as b1, type ShippingQuote as b2, type ShippingQuoteInput as b3, type ShopScript as b4, type ShopScriptPlacement as b5, type ShopScriptType as b6, type StockBehavior as b7, type VariantAxis as b8, type VariantAxisValue as b9, err as ba, ok as bb, toSdkError as bc, type ProductListItem as c, type ProductDetail as d, type CategoryDetail as e, type ProductLabel as f, type Cart as g, type CustomerProfile as h, type CustomerAddress as i, type AddressDetail as j, type PickupPointsInput as k, type PickupPoint as l, type NewsletterSubscribeInput as m, type NewsletterUnsubscribeResult as n, type OrderDetail as o, type OrderAccessRequestResponse as p, type OrderAccessVerifyResponse as q, type CheckoutInput as r, type PageDetail as s, type Page as t, type ShopScripts as u, type ShopSeo as v, type Bundle as w, type ProductGroup as x, type CrossSellItem as y, type ActivePromotion as z };
2317
+ export { type QuoteRequest as $, type AddressSuggestion as A, type BehioStorefrontConfig as B, type Category as C, type ShopScripts as D, type ShopSeo as E, type FilterField as F, type Bundle as G, type ProductGroup as H, type CrossSellItem as I, type ActivePromotion as J, type GiftCardBalance as K, type LoyaltySummary as L, type Menu as M, type NewsletterSubscribeResult as N, type OrderListItem as O, type ProductsQuery as P, type ProductReviewsResponse as Q, type RegisterInput as R, type Subscription as S, type SubmitReviewInput as T, type ReturnableOrder as U, type ReturnStatus as V, type WishlistItem as W, type ReturnRequest as X, type SubmitReturnInput as Y, type CookieConsent as Z, type CookieConsentInput as _, BehioStorefront as a, type ProductVolumePrice as a$, type SubmitQuoteInput as a0, type BackInStockSubscription as a1, type AddToCartInput as a2, type AuthTokens as a3, BehioApiError as a4, type BundleItem as a5, type CartDiscount as a6, type CartItem as a7, type CheckoutAddress as a8, type FulfillmentStatus as a9, type GiftCardPurchaseResult as aA, type GiftCardSummary as aB, type LoyaltyBalance as aC, type LoyaltyNextTier as aD, type LoyaltyProgram as aE, type LoyaltyTier as aF, type LoyaltyTierPerks as aG, type LoyaltyTransaction as aH, type MenuItem as aI, type MenuItemRef as aJ, type MenuItemType as aK, type NewsletterOptInDefault as aL, type OrderStatusHistory as aM, OrderStatuses as aN, type OrderTracking as aO, type PageAttachment as aP, PaymentStatuses as aQ, type PickupPointHours as aR, type PriceDisplay as aS, type ProductAvailability as aT, type ProductCustomField as aU, type ProductCustomFieldGroup as aV, type ProductMedia as aW, type ProductMediaVariant as aX, type ProductPromotionSummary as aY, ProductSort as aZ, type ProductSortValue as a_, type LoginInput as aa, type MessageResponse as ab, type OrderItem as ac, type OrderStatus as ad, type PaymentStatus as ae, type ProductPrice as af, type ProductReview as ag, type ProductVariant as ah, type SdkResult as ai, type AddressType as aj, AddressTypes as ak, type BadgeTone as al, type BehioErrorCode as am, type BehioEventHandler as an, type BehioEventType as ao, BehioNetworkError as ap, type CartBundleLine as aq, type CartBundleLineItem as ar, type CartItemProduct as as, type CartPromotion as at, type CheckoutSettings as au, type DataGroupFieldType as av, type DigitalDownload as aw, type DownloadUrl as ax, FulfillmentStatuses as ay, type GiftCardPurchaseInput as az, type PaginatedResponse as b, type QuoteItem as b0, type RegisterResult as b1, type RequestInterceptor as b2, type RequestInterceptorConfig as b3, type ResponseInterceptor as b4, type ResponseInterceptorData as b5, type ReturnRequestItem as b6, type ReturnStatusItem as b7, type ReturnableOrderItem as b8, type SdkError as b9, type ShopScript as ba, type ShopScriptPlacement as bb, type ShopScriptType as bc, type ShopSeoIdentity as bd, type StockBehavior as be, type SubscriptionFrequency as bf, type SubscriptionItem as bg, type SubscriptionStatus as bh, type TaxBreakdownLine as bi, type VariantAxis as bj, type VariantAxisValue as bk, err as bl, ok as bm, toSdkError as bn, type ProductListItem as c, type ProductDetail as d, type CategoryDetail as e, type ProductLabel as f, type Cart as g, type CustomerProfile as h, type CustomerAddress as i, type AddressDetail as j, type SubscriptionAction as k, type PickupPointsInput as l, type PickupPoint as m, type ShippingMethodSummary as n, type ShippingQuoteInput as o, type ShippingQuote as p, type CheckoutPaymentMethod as q, type NewsletterSubscribeInput as r, type NewsletterUnsubscribeResult as s, type OrderDetail as t, type OrderAccessRequestResponse as u, type OrderAccessVerifyResponse as v, type CheckoutInput as w, type PageDetail as x, type Page as y, type ShopInfo as z };
package/dist/index.d.mts CHANGED
@@ -1,4 +1,5 @@
1
- export { z as ActivePromotion, Y as AddToCartInput, j as AddressDetail, A as AddressSuggestion, ac as AddressType, ad as AddressTypes, Z as AuthTokens, X as BackInStockSubscription, ae as BadgeTone, _ as BehioApiError, af as BehioErrorCode, ag as BehioEventHandler, ah as BehioEventType, ai as BehioNetworkError, a as BehioStorefront, B as BehioStorefrontConfig, w as Bundle, $ as BundleItem, g as Cart, aj as CartBundleLine, ak as CartBundleLineItem, a0 as CartDiscount, a1 as CartItem, al as CartItemProduct, am as CartPromotion, C as Category, e as CategoryDetail, a2 as CheckoutAddress, r as CheckoutInput, an as CheckoutPaymentMethod, ao as CheckoutSettings, Q as CookieConsent, T as CookieConsentInput, y as CrossSellItem, i as CustomerAddress, h as CustomerProfile, ap as DataGroupFieldType, aq as DigitalDownload, ar as DownloadUrl, F as FilterField, a3 as FulfillmentStatus, as as FulfillmentStatuses, G as GiftCardBalance, at as GiftCardPurchaseInput, au as GiftCardPurchaseResult, av as GiftCardSummary, a4 as LoginInput, aw as LoyaltyBalance, ax as LoyaltyNextTier, ay as LoyaltyProgram, L as LoyaltySummary, az as LoyaltyTier, aA as LoyaltyTierPerks, aB as LoyaltyTransaction, M as Menu, aC as MenuItem, aD as MenuItemRef, aE as MenuItemType, a5 as MessageResponse, aF as NewsletterOptInDefault, m as NewsletterSubscribeInput, N as NewsletterSubscribeResult, n as NewsletterUnsubscribeResult, p as OrderAccessRequestResponse, q as OrderAccessVerifyResponse, o as OrderDetail, a6 as OrderItem, O as OrderListItem, a7 as OrderStatus, aG as OrderStatusHistory, aH as OrderStatuses, aI as OrderTracking, t as Page, aJ as PageAttachment, s as PageDetail, b as PaginatedResponse, a8 as PaymentStatus, aK as PaymentStatuses, l as PickupPoint, aL as PickupPointHours, k as PickupPointsInput, aM as ProductAvailability, d as ProductDetail, x as ProductGroup, f as ProductLabel, c as ProductListItem, aN as ProductMedia, aO as ProductMediaVariant, a9 as ProductPrice, aa as ProductReview, D as ProductReviewsResponse, aP as ProductSort, aQ as ProductSortValue, ab as ProductVariant, aR as ProductVolumePrice, P as ProductsQuery, aS as QuoteItem, U as QuoteRequest, R as RegisterInput, aT as RegisterResult, aU as RequestInterceptor, aV as RequestInterceptorConfig, aW as ResponseInterceptor, aX as ResponseInterceptorData, J as ReturnRequest, aY as ReturnRequestItem, I as ReturnStatus, aZ as ReturnStatusItem, H as ReturnableOrder, a_ as ReturnableOrderItem, a$ as SdkError, b0 as SdkResult, b1 as ShippingMethodSummary, b2 as ShippingQuote, b3 as ShippingQuoteInput, S as ShopInfo, b4 as ShopScript, b5 as ShopScriptPlacement, b6 as ShopScriptType, u as ShopScripts, v as ShopSeo, b7 as StockBehavior, V as SubmitQuoteInput, K as SubmitReturnInput, E as SubmitReviewInput, b8 as VariantAxis, b9 as VariantAxisValue, W as WishlistItem, ba as err, bb as ok, bc as toSdkError } from './client-BOz1trRk.mjs';
1
+ import { a as BehioStorefront, ai as SdkResult, Z as CookieConsent } from './client-DdaC0_6x.mjs';
2
+ export { J as ActivePromotion, a2 as AddToCartInput, j as AddressDetail, A as AddressSuggestion, aj as AddressType, ak as AddressTypes, a3 as AuthTokens, a1 as BackInStockSubscription, al as BadgeTone, a4 as BehioApiError, am as BehioErrorCode, an as BehioEventHandler, ao as BehioEventType, ap as BehioNetworkError, B as BehioStorefrontConfig, G as Bundle, a5 as BundleItem, g as Cart, aq as CartBundleLine, ar as CartBundleLineItem, a6 as CartDiscount, a7 as CartItem, as as CartItemProduct, at as CartPromotion, C as Category, e as CategoryDetail, a8 as CheckoutAddress, w as CheckoutInput, q as CheckoutPaymentMethod, au as CheckoutSettings, _ as CookieConsentInput, I as CrossSellItem, i as CustomerAddress, h as CustomerProfile, av as DataGroupFieldType, aw as DigitalDownload, ax as DownloadUrl, F as FilterField, a9 as FulfillmentStatus, ay as FulfillmentStatuses, K as GiftCardBalance, az as GiftCardPurchaseInput, aA as GiftCardPurchaseResult, aB as GiftCardSummary, aa as LoginInput, aC as LoyaltyBalance, aD as LoyaltyNextTier, aE as LoyaltyProgram, L as LoyaltySummary, aF as LoyaltyTier, aG as LoyaltyTierPerks, aH as LoyaltyTransaction, M as Menu, aI as MenuItem, aJ as MenuItemRef, aK as MenuItemType, ab as MessageResponse, aL as NewsletterOptInDefault, r as NewsletterSubscribeInput, N as NewsletterSubscribeResult, s as NewsletterUnsubscribeResult, u as OrderAccessRequestResponse, v as OrderAccessVerifyResponse, t as OrderDetail, ac as OrderItem, O as OrderListItem, ad as OrderStatus, aM as OrderStatusHistory, aN as OrderStatuses, aO as OrderTracking, y as Page, aP as PageAttachment, x as PageDetail, b as PaginatedResponse, ae as PaymentStatus, aQ as PaymentStatuses, m as PickupPoint, aR as PickupPointHours, l as PickupPointsInput, aS as PriceDisplay, aT as ProductAvailability, aU as ProductCustomField, aV as ProductCustomFieldGroup, d as ProductDetail, H as ProductGroup, f as ProductLabel, c as ProductListItem, aW as ProductMedia, aX as ProductMediaVariant, af as ProductPrice, aY as ProductPromotionSummary, ag as ProductReview, Q as ProductReviewsResponse, aZ as ProductSort, a_ as ProductSortValue, ah as ProductVariant, a$ as ProductVolumePrice, P as ProductsQuery, b0 as QuoteItem, $ as QuoteRequest, R as RegisterInput, b1 as RegisterResult, b2 as RequestInterceptor, b3 as RequestInterceptorConfig, b4 as ResponseInterceptor, b5 as ResponseInterceptorData, X as ReturnRequest, b6 as ReturnRequestItem, V as ReturnStatus, b7 as ReturnStatusItem, U as ReturnableOrder, b8 as ReturnableOrderItem, b9 as SdkError, n as ShippingMethodSummary, p as ShippingQuote, o as ShippingQuoteInput, z as ShopInfo, ba as ShopScript, bb as ShopScriptPlacement, bc as ShopScriptType, D as ShopScripts, E as ShopSeo, bd as ShopSeoIdentity, be as StockBehavior, a0 as SubmitQuoteInput, Y as SubmitReturnInput, T as SubmitReviewInput, S as Subscription, k as SubscriptionAction, bf as SubscriptionFrequency, bg as SubscriptionItem, bh as SubscriptionStatus, bi as TaxBreakdownLine, bj as VariantAxis, bk as VariantAxisValue, W as WishlistItem, bl as err, bm as ok, bn as toSdkError } from './client-DdaC0_6x.mjs';
2
3
 
3
4
  /**
4
5
  * Format a price amount with currency using Intl.NumberFormat.
@@ -13,20 +14,29 @@ declare function formatPrice(amount: number, currency: string, locale?: string):
13
14
  /**
14
15
  * GA4 e-commerce event helper.
15
16
  *
16
- * Fires standard GA4 ecommerce events (view_item, add_to_cart, begin_checkout,
17
- * purchase, ...) into whatever analytics runtime the shop has injected via
18
- * `<StorefrontScripts/>`:
17
+ * Fires standard GA4 ecommerce/engagement events (view_item, add_to_cart,
18
+ * begin_checkout, purchase, search, ...) into whatever analytics runtime the
19
+ * shop has injected via `<StorefrontScripts/>`, and — crucially — into Behio
20
+ * Analytics via the sink the tracker registers. One call, both systems.
19
21
  *
22
+ * Sinks:
23
+ * - Behio Analytics (`__behioEcommerceSink`) — always, when the tracker is
24
+ * mounted. Records the ORIGINAL event name so Behio-exclusive signals
25
+ * (variant_selected, newsletter_signup) stay distinct.
20
26
  * - direct GA4 (`gtag` present) -> `gtag("event", name, payload)`
21
27
  * - GTM (`dataLayer` array present) -> `dataLayer.push({event, ecommerce})`
22
28
  * (with the recommended `ecommerce: null` reset push first)
23
29
  * - neither present (no analytics configured, or consent not granted yet so
24
- * the consent-gated script never loaded) -> silent no-op
30
+ * the consent-gated script never loaded) -> silent no-op for the GA path
31
+ *
32
+ * Behio-only signal names that have a GA4 recommended equivalent are remapped
33
+ * for the GA path only (see `GA4_NAME_MAP`), so merchants keep clean GA4
34
+ * reports while Behio keeps the richer signal.
25
35
  *
26
36
  * Consent stays the script layer's job: this helper never loads anything, it
27
37
  * only talks to runtimes that already exist on the page.
28
38
  */
29
- type EcommerceEventName = "view_item" | "add_to_cart" | "remove_from_cart" | "view_cart" | "begin_checkout" | "add_payment_info" | "add_shipping_info" | "purchase";
39
+ type EcommerceEventName = "view_item" | "view_item_list" | "select_item" | "add_to_cart" | "remove_from_cart" | "view_cart" | "add_to_wishlist" | "view_promotion" | "select_promotion" | "begin_checkout" | "add_payment_info" | "add_shipping_info" | "search" | "generate_lead" | "purchase" | "variant_selected" | "newsletter_signup";
30
40
  type EcommerceItem = {
31
41
  item_id: string;
32
42
  item_name: string;
@@ -34,6 +44,8 @@ type EcommerceItem = {
34
44
  quantity?: number;
35
45
  item_variant?: string;
36
46
  item_category?: string;
47
+ /** Position in the list (1-based) — for select_item rail/list attribution. */
48
+ index?: number;
37
49
  };
38
50
  type EcommercePayload = {
39
51
  currency?: string;
@@ -42,8 +54,74 @@ type EcommercePayload = {
42
54
  /** Required for `purchase` — the order number. */
43
55
  transaction_id?: string;
44
56
  shipping?: number;
45
- items: EcommerceItem[];
57
+ /** Optional for non-item events (search, add_shipping_info, newsletter). */
58
+ items?: EcommerceItem[];
59
+ /** search event: the query string. */
60
+ search_term?: string;
61
+ /** add_shipping_info: the selected shipping method label. */
62
+ shipping_tier?: string;
63
+ /** add_payment_info: the selected payment method type. */
64
+ payment_type?: string;
65
+ /** view_item_list / select_item: the list id (shop|category|search|rail:*). */
66
+ item_list_id?: string;
67
+ /** view_item_list / select_item: human-readable list name. */
68
+ item_list_name?: string;
69
+ /**
70
+ * Behio-only extra props forwarded verbatim into the Behio event `props`
71
+ * (ignored by GA4). Use for signals GA4 can't model: resultsCount,
72
+ * zeroResults, variantId, listId, position, source, ...
73
+ */
74
+ props?: Record<string, unknown>;
46
75
  };
47
76
  declare function trackEcommerceEvent(event: EcommerceEventName, payload: EcommercePayload): void;
48
77
 
49
- export { type EcommerceEventName, type EcommerceItem, type EcommercePayload, formatPrice, trackEcommerceEvent };
78
+ /**
79
+ * Consent-gated visitor identity helpers.
80
+ *
81
+ * Behio Analytics has three identity tiers (see BehioAnalyticsTracker):
82
+ * anonymous (cookieless server hash), consented (persistent behio_visitor_id),
83
+ * and customer-linked (server stitches at checkout/login). The persistent
84
+ * `behio_visitor_id` is what unlocks returning-visitor metrics, the customer
85
+ * journey and Smart Offers.
86
+ *
87
+ * Historically the SDK only READ that id and left generation/writing to each
88
+ * shop's consent banner — so any storefront that forgot the write stayed 100%
89
+ * anonymous. These helpers move the write into the SDK: the consent banner just
90
+ * calls `grantAnalyticsConsent(client)` / `revokeAnalyticsConsent(client)` and
91
+ * everything (id generation, storage, server record, tracker refresh) is
92
+ * handled here, identically for every template and AI-generated shop.
93
+ */
94
+
95
+ /** Read the persistent visitor id (localStorage first, cookie fallback for SSR-set ids). */
96
+ declare function getStoredVisitorId(): string | null;
97
+ /**
98
+ * Generate a fresh, URL-safe visitor id in the range the ingest DTO accepts
99
+ * (8..64 chars, [A-Za-z0-9_-]). Uses crypto when available, falling back to
100
+ * Math.random so it never throws in a locked-down runtime.
101
+ */
102
+ declare function generateVisitorId(): string;
103
+ /**
104
+ * Grant analytics consent: ensure a persistent `behio_visitor_id` exists, store
105
+ * it, record the consent server-side, wire the id into the client (so orders /
106
+ * logins can be attributed) and notify the tracker to start sending it.
107
+ *
108
+ * Returns the visitor id (or an SdkResult error if the server record failed —
109
+ * the id is still stored locally so tracking works and can retry later).
110
+ *
111
+ * @param categories optional marketing/preferences flags (default false); the
112
+ * analytics flag is always true here.
113
+ */
114
+ declare function grantAnalyticsConsent(client: BehioStorefront, categories?: {
115
+ marketing?: boolean;
116
+ preferences?: boolean;
117
+ }): Promise<SdkResult<CookieConsent>>;
118
+ /**
119
+ * Revoke analytics consent: tell the server, stop sending the id and notify the
120
+ * tracker. The stored id is kept (consent record now says analytics=false) so a
121
+ * later re-grant reuses the same visitor rather than fragmenting the journey.
122
+ */
123
+ declare function revokeAnalyticsConsent(client: BehioStorefront): Promise<SdkResult<{
124
+ success: boolean;
125
+ }>>;
126
+
127
+ export { BehioStorefront, CookieConsent, type EcommerceEventName, type EcommerceItem, type EcommercePayload, SdkResult, formatPrice, generateVisitorId, getStoredVisitorId, grantAnalyticsConsent, revokeAnalyticsConsent, trackEcommerceEvent };