@behio/storefront-sdk 0.3.0 → 0.5.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/index.d.ts CHANGED
@@ -50,10 +50,50 @@ interface ShopSeo {
50
50
  ogDescription: string | null;
51
51
  ogImage: string | null;
52
52
  }
53
+ /**
54
+ * Money amount displayed to a customer in a chosen currency.
55
+ *
56
+ * Two cases:
57
+ * - **Fixed price** (preferred): merchant configured an explicit price for
58
+ * this currency. `isApproximate` is `false`/absent and `fxSource` is `null`.
59
+ * - **Approximate / FX-converted**: no fixed price for the requested
60
+ * currency, so Behio converted from the eshop's default currency using
61
+ * today's rate from `fxSource` (CNB or Frankfurter/ECB) plus the eshop's
62
+ * safety margin. UI should show a `≈` hint and offer the base price too.
63
+ */
64
+ /**
65
+ * Payment method available at checkout. Returned by
66
+ * `GET /storefront/v1/catalog/payment-methods` filtered for the customer's
67
+ * chosen currency. Credentials (API keys, merchant ids) stay server-side
68
+ * — only customer-safe fields appear here.
69
+ */
70
+ interface CheckoutPaymentMethod {
71
+ id: string;
72
+ /** Merchant-chosen label, e.g. "Kartou (Stripe)" or "Převodem na účet". */
73
+ name: string;
74
+ description?: string | null;
75
+ /** Provider id: "stripe" | "gopay" | "comgate" | "bank_transfer" | "cod" | "custom". */
76
+ provider: string;
77
+ /** Currencies this method accepts. Empty = any. */
78
+ currencies: string[];
79
+ /** Optional fee added to the order total (e.g. COD surcharge). */
80
+ fee?: number | null;
81
+ feeCurrency?: string | null;
82
+ /** Customer-safe slice of config: bank account, IBAN, instructions, … */
83
+ publicConfig?: Record<string, unknown>;
84
+ }
53
85
  interface ProductPrice {
54
86
  amount: number;
55
87
  currency: string;
56
88
  compareAtPrice?: number | null;
89
+ /** `true` when this amount was FX-converted from the eshop default currency. */
90
+ isApproximate?: boolean;
91
+ /** Provider id ("cnb" | "frankfurter" | "manual") when FX-converted. */
92
+ fxSource?: string | null;
93
+ /** Original amount in the eshop default currency before conversion. */
94
+ baseAmount?: number | null;
95
+ /** ISO code of the currency `baseAmount` is denominated in. */
96
+ baseCurrency?: string | null;
57
97
  }
58
98
  interface ProductVolumePrice {
59
99
  minQuantity: number;
@@ -68,6 +108,17 @@ interface ProductVariant {
68
108
  price: ProductPrice;
69
109
  inStock: boolean;
70
110
  stockQuantity?: number;
111
+ /**
112
+ * Cover image URL for the variant. Falls back to the parent product's
113
+ * cover when the variant has no photo of its own — see `imageIsInherited`.
114
+ */
115
+ imageUrl?: string | null;
116
+ /**
117
+ * `true` when `imageUrl` is borrowed from the parent product because the
118
+ * variant has no cover image of its own. Use this to render a hint like
119
+ * "default photo" or to render the picture in a subtler style.
120
+ */
121
+ imageIsInherited: boolean;
71
122
  }
72
123
  interface ProductLabel {
73
124
  id: string;
@@ -371,6 +422,51 @@ declare class BehioNetworkError extends Error {
371
422
  readonly isRetryable = true;
372
423
  constructor(message: string, isTimeout?: boolean);
373
424
  }
425
+ /**
426
+ * Shape every SDK call returns. Destructure `{data, error}` — exactly
427
+ * one of them is non-null on any given call. No more try/catch for
428
+ * expected failures; the type system forces you to handle `error`
429
+ * before touching `data`.
430
+ *
431
+ * const {data, error} = await behio.catalog.getProduct(slug);
432
+ * if (error) return <ErrorState code={error.code} />;
433
+ * return <ProductView product={data} />;
434
+ */
435
+ type SdkResult<T> = {
436
+ data: T;
437
+ error: null;
438
+ } | {
439
+ data: null;
440
+ error: SdkError;
441
+ };
442
+ /**
443
+ * Canonical error shape returned from every SDK call. Always carries a
444
+ * `code` you can branch on without parsing messages.
445
+ */
446
+ interface SdkError {
447
+ /**
448
+ * High-level category. `BehioErrorCode` covers API errors; additional
449
+ * buckets are network/timeout/abort/unknown.
450
+ */
451
+ code: BehioErrorCode;
452
+ /** Human-readable message (fallback for unknown codes / dev logging). */
453
+ message: string;
454
+ /** HTTP status, if the error came from the API. Null for network / abort. */
455
+ status: number | null;
456
+ /** Raw API body, if present. */
457
+ body?: unknown;
458
+ /** Whether the operation is safe to retry (true for 5xx / 429 / network). */
459
+ isRetryable: boolean;
460
+ /** Preserves the original thrown instance for stack traces + rethrows. */
461
+ cause?: unknown;
462
+ }
463
+ declare function ok<T>(data: T): SdkResult<T>;
464
+ declare function err<T = never>(error: SdkError): SdkResult<T>;
465
+ /**
466
+ * Converts any thrown value into a canonical SdkError. Used by the
467
+ * request wrapper when catching internal throws.
468
+ */
469
+ declare function toSdkError(err: unknown): SdkError;
374
470
  type BehioEventType = "auth:login" | "auth:logout" | "auth:token-refresh" | "auth:token-refresh-failed" | "cart:updated" | "cart:cleared" | "order:created" | "error" | "request" | "response" | "rate-limit-warning";
375
471
  type BehioEventHandler = (data?: unknown) => void;
376
472
  interface RequestInterceptorConfig {
@@ -409,10 +505,85 @@ interface Bundle {
409
505
  coverImage: string | null;
410
506
  endsAt: number | null;
411
507
  itemsSum: number;
508
+ /** Absolute saving vs buying the components separately, in `currency`. */
412
509
  savings: number;
510
+ /** Percentage saving, 0–100. 0 when `itemsSum` is zero. */
413
511
  savingsPercent: number;
512
+ /** Minimum bundles per order. Default 1. */
513
+ minQuantity: number;
514
+ /** Maximum bundles per order. `null` = uncapped. */
515
+ maxQuantity: number | null;
516
+ /** Lifetime stock limit. `null` = uncapped. Once exceeded, add-to-cart fails. */
517
+ stockLimit: number | null;
518
+ /** Lifetime units sold (materialized counter). Used for "X sold" badges. */
519
+ soldCount: number;
414
520
  items: BundleItem[];
415
521
  }
522
+ /**
523
+ * Shape returned by `behio.shipping.listMethods()` — the merchant's
524
+ * configured shipping methods filtered by cart currency + destination
525
+ * country. Use this for the "always-on" picker; for live quotes, prefer
526
+ * `behio.shipping.quote()` which can dispatch to the meta-provider
527
+ * (Zaslat, Shippo, …) for a live carrier rate per address.
528
+ */
529
+ interface ShippingMethodSummary {
530
+ id: string;
531
+ name: string;
532
+ description: string | null;
533
+ /** Internal routing id ("zaslat", "ppl_direct", "manual", …). Not for display. */
534
+ provider: string;
535
+ currency: string | null;
536
+ /** Final customer-facing price. Equals `basePrice` unless free-shipping kicks in. */
537
+ price: number;
538
+ /** Per-currency base price from the merchant's config. */
539
+ basePrice: number;
540
+ isFreeShipping: boolean;
541
+ freeShippingThreshold: number | null;
542
+ /** "address" | "pickup_point" | "in_store" | "digital". */
543
+ deliveryType: string;
544
+ supportsPickupPoints: boolean;
545
+ etaDaysMin: number | null;
546
+ etaDaysMax: number | null;
547
+ allowedCountries: string[];
548
+ /** Customer-safe config fields the merchant filled in (pickup address, instructions). */
549
+ publicConfig: Record<string, unknown>;
550
+ }
551
+ /**
552
+ * Input for `behio.shipping.quote()`. At minimum requires the destination
553
+ * country — passing more (zip, weight per item, cart total) lets the
554
+ * meta-provider return better-fitting carriers and triggers free-shipping
555
+ * thresholds correctly.
556
+ */
557
+ interface ShippingQuoteInput {
558
+ destinationAddress: {
559
+ country: string;
560
+ zip?: string;
561
+ city?: string;
562
+ street?: string;
563
+ };
564
+ items?: Array<{
565
+ whItemId: string;
566
+ quantity: number;
567
+ weightKg?: number;
568
+ }>;
569
+ cartTotal?: number;
570
+ currency?: string;
571
+ }
572
+ /**
573
+ * One option returned by `behio.shipping.quote()`. Methods configured for
574
+ * fixed pricing always come back with `available: true` and the merchant's
575
+ * configured price. Methods configured for live quoting come back available
576
+ * only when the upstream meta-provider returned a rate for the destination
577
+ * — otherwise `available: false` with a `reason` (e.g. `"no_rate_returned"`,
578
+ * `"live_quote_not_implemented"`). Filter `available: true` in your
579
+ * checkout picker.
580
+ */
581
+ interface ShippingQuote extends ShippingMethodSummary {
582
+ /** `"fixed"` uses `pricing` rows; `"live_quote"` came from the upstream provider. */
583
+ strategy: "fixed" | "live_quote";
584
+ available: boolean;
585
+ reason: string | null;
586
+ }
416
587
  interface CrossSellItem {
417
588
  productId: string;
418
589
  slug: string | null;
@@ -572,10 +743,11 @@ declare class BehioStorefront {
572
743
  readonly consent: ConsentModule;
573
744
  readonly quotes: QuotesModule;
574
745
  readonly addresses: AddressModule;
746
+ readonly shipping: ShippingModule;
575
747
  /** Get basic shop info */
576
- getShopInfo(): Promise<ShopInfo>;
748
+ getShopInfo(): Promise<SdkResult<ShopInfo>>;
577
749
  /** Get SEO metadata for the shop homepage in the given locale (defaults to shop default). */
578
- getShopSeo(locale?: string): Promise<ShopSeo>;
750
+ getShopSeo(locale?: string): Promise<SdkResult<ShopSeo>>;
579
751
  /** Set auth tokens (e.g. from localStorage) */
580
752
  setTokens(tokens: {
581
753
  accessToken: string;
@@ -607,88 +779,99 @@ declare class BehioStorefront {
607
779
  reset: number | null;
608
780
  };
609
781
  private handleTokenRefresh;
610
- /** @internal */
782
+ /**
783
+ * Every public module method funnels through here. Internally calls
784
+ * `rawRequest` (which throws on failure) and maps thrown errors to
785
+ * `SdkError` so the public surface can return `SdkResult<T>`.
786
+ *
787
+ * @internal — don't call from outside the SDK; use the typed module
788
+ * methods (behio.catalog.*, behio.cart.*, …) instead.
789
+ */
611
790
  request<T>(method: string, path: string, options?: {
612
791
  body?: unknown;
613
792
  query?: Record<string, string | number | boolean | undefined | string[] | number[]>;
614
793
  auth?: boolean;
615
794
  signal?: AbortSignal;
616
- /** @internal Prevents infinite refresh loops */
617
- _isRetryAfterRefresh?: boolean;
618
- }): Promise<T>;
795
+ }): Promise<SdkResult<T>>;
796
+ /**
797
+ * Throws on failure (API error / network / timeout). Kept private so
798
+ * internal auth refresh recursion keeps its existing control flow —
799
+ * public callers must go through `request()` which returns Result.
800
+ */
801
+ private rawRequest;
619
802
  }
620
803
  declare class CatalogModule {
621
804
  private client;
622
805
  constructor(client: BehioStorefront);
623
806
  /** List products with filtering, pagination, search */
624
- getProducts(query?: ProductsQuery): Promise<PaginatedResponse<ProductListItem>>;
807
+ getProducts(query?: ProductsQuery): Promise<SdkResult<PaginatedResponse<ProductListItem>>>;
625
808
  /** Get product detail by slug */
626
809
  getProduct(slug: string, options?: {
627
810
  locale?: string;
628
811
  currency?: string;
629
- }): Promise<ProductDetail>;
812
+ }): Promise<SdkResult<ProductDetail>>;
630
813
  /** Get category tree */
631
- getCategories(locale?: string): Promise<{
814
+ getCategories(locale?: string): Promise<SdkResult<{
632
815
  categories: Category[];
633
- }>;
816
+ }>>;
634
817
  /** Get category detail by slug */
635
- getCategory(slug: string, locale?: string): Promise<CategoryDetail>;
818
+ getCategory(slug: string, locale?: string): Promise<SdkResult<CategoryDetail>>;
636
819
  /** Get products in a category */
637
- getCategoryProducts(slug: string, query?: ProductsQuery): Promise<PaginatedResponse<ProductListItem>>;
820
+ getCategoryProducts(slug: string, query?: ProductsQuery): Promise<SdkResult<PaginatedResponse<ProductListItem>>>;
638
821
  /** Get all labels */
639
- getLabels(locale?: string): Promise<{
822
+ getLabels(locale?: string): Promise<SdkResult<{
640
823
  labels: ProductLabel[];
641
- }>;
824
+ }>>;
642
825
  /** Get featured products */
643
826
  getFeatured(options?: {
644
827
  locale?: string;
645
828
  currency?: string;
646
- }): Promise<PaginatedResponse<ProductListItem>>;
829
+ }): Promise<SdkResult<PaginatedResponse<ProductListItem>>>;
647
830
  /** Get available filter fields for dynamic filter UI */
648
- getFilters(): Promise<{
831
+ getFilters(): Promise<SdkResult<{
649
832
  filters: FilterField[];
650
- }>;
833
+ }>>;
651
834
  /** Search products */
652
835
  search(query: string, options?: {
653
836
  page?: number;
654
837
  limit?: number;
655
- }): Promise<PaginatedResponse<ProductListItem>>;
838
+ }): Promise<SdkResult<PaginatedResponse<ProductListItem>>>;
656
839
  /** List all active bundles */
657
- getBundles(): Promise<{
840
+ getBundles(): Promise<SdkResult<{
658
841
  items: Bundle[];
659
- }>;
842
+ }>>;
660
843
  /** Get a single bundle by slug */
661
- getBundle(slug: string): Promise<Bundle>;
844
+ getBundle(slug: string): Promise<SdkResult<Bundle>>;
662
845
  /** Cross-sell / related / upsell products for a product */
663
- getCrossSell(productSlug: string): Promise<{
846
+ getCrossSell(productSlug: string): Promise<SdkResult<{
664
847
  related: CrossSellItem[];
665
848
  upsell: CrossSellItem[];
666
849
  crossSell: CrossSellItem[];
667
- }>;
850
+ }>>;
668
851
  /** Active promotions applicable to a product (with countdown end time) */
669
- getProductPromotions(productSlug: string): Promise<{
852
+ getProductPromotions(productSlug: string): Promise<SdkResult<{
670
853
  items: ActivePromotion[];
671
- }>;
854
+ }>>;
672
855
  /** Check a gift card code — returns validity and remaining balance */
673
- checkGiftCard(code: string): Promise<GiftCardBalance>;
856
+ checkGiftCard(code: string): Promise<SdkResult<GiftCardBalance>>;
674
857
  }
675
858
  declare class AuthModule {
676
859
  private client;
677
860
  constructor(client: BehioStorefront);
678
861
  /** Register a new customer */
679
- register(input: RegisterInput): Promise<AuthTokens>;
862
+ register(input: RegisterInput): Promise<SdkResult<AuthTokens>>;
680
863
  /** Login with email and password */
681
- login(input: LoginInput): Promise<AuthTokens>;
864
+ login(input: LoginInput): Promise<SdkResult<AuthTokens>>;
682
865
  /** Refresh access token using refresh token */
683
- refresh(refreshToken?: string): Promise<AuthTokens>;
866
+ refresh(refreshToken?: string): Promise<SdkResult<AuthTokens>>;
684
867
  /** Logout (invalidate refresh token) */
685
- logout(refreshToken?: string): Promise<MessageResponse>;
868
+ logout(refreshToken?: string): Promise<SdkResult<MessageResponse>>;
686
869
  /** Request password reset email */
687
- forgotPassword(email: string): Promise<MessageResponse>;
870
+ forgotPassword(email: string): Promise<SdkResult<MessageResponse>>;
688
871
  /** Reset password with token */
689
- resetPassword(token: string, newPassword: string): Promise<MessageResponse>;
872
+ resetPassword(token: string, newPassword: string): Promise<SdkResult<MessageResponse>>;
690
873
  /** Verify email with token */
691
- verifyEmail(token: string): Promise<MessageResponse>;
874
+ verifyEmail(token: string): Promise<SdkResult<MessageResponse>>;
692
875
  /** Check if user is logged in (has access token) */
693
876
  isLoggedIn(): boolean;
694
877
  }
@@ -696,39 +879,59 @@ declare class CartModule {
696
879
  private client;
697
880
  constructor(client: BehioStorefront);
698
881
  /** Get current cart */
699
- get(): Promise<Cart>;
882
+ get(): Promise<SdkResult<Cart>>;
700
883
  /** Add item to cart */
701
- addItem(input: AddToCartInput): Promise<Cart & {
884
+ addItem(input: AddToCartInput): Promise<SdkResult<Cart & {
702
885
  newSessionToken?: string;
703
- }>;
886
+ }>>;
704
887
  /** Update item quantity */
705
- updateQuantity(itemId: string, quantity: number): Promise<Cart>;
888
+ updateQuantity(itemId: string, quantity: number): Promise<SdkResult<Cart>>;
706
889
  /** Remove item from cart */
707
- removeItem(itemId: string): Promise<Cart>;
890
+ removeItem(itemId: string): Promise<SdkResult<Cart>>;
708
891
  /** Clear entire cart */
709
- clear(): Promise<void>;
892
+ clear(): Promise<SdkResult<void>>;
710
893
  /** Apply a gift card code to the cart. Balance is deducted at checkout. */
711
- applyGiftCard(code: string): Promise<Cart>;
894
+ applyGiftCard(code: string): Promise<SdkResult<Cart>>;
712
895
  /** Remove a gift card from the cart */
713
- removeGiftCard(): Promise<Cart>;
714
- /** Add a bundle to the cart (price is locked at the bundle's current price) */
715
- addBundle(bundleId: string, quantity?: number): Promise<Cart>;
896
+ removeGiftCard(): Promise<SdkResult<Cart>>;
897
+ /**
898
+ * Add a bundle to the cart. Price is snapshotted at the bundle's current
899
+ * price. Pass either the bundle id or its slug — slug is more ergonomic
900
+ * for static storefront wiring (`behio.cart.addBundle({slug: "morning-set"})`).
901
+ *
902
+ * Respects the bundle's `minQuantity`, `maxQuantity`, and `stockLimit`:
903
+ * the request rejects with HTTP 400 if the resulting cart line would
904
+ * violate any of them. The returned error includes the relevant field
905
+ * (`minQuantity`, `maxQuantity`, or `remaining`) so the storefront can
906
+ * surface a meaningful message.
907
+ *
908
+ * @param identifier Either `{id: bundleId}` or `{slug: bundleSlug}`. As a
909
+ * convenience, passing a plain string is treated as the
910
+ * bundle id for backwards compatibility.
911
+ * @param quantity How many bundles to add (defaults to 1). Capped by
912
+ * the bundle's `maxQuantity` if set.
913
+ */
914
+ addBundle(identifier: string | {
915
+ id: string;
916
+ } | {
917
+ slug: string;
918
+ }, quantity?: number): Promise<SdkResult<Cart>>;
716
919
  /** Update quantity of a bundle already in the cart */
717
- updateBundleQuantity(bundleId: string, quantity: number): Promise<Cart>;
920
+ updateBundleQuantity(bundleId: string, quantity: number): Promise<SdkResult<Cart>>;
718
921
  /** Remove a bundle from the cart */
719
- removeBundle(bundleId: string): Promise<Cart>;
922
+ removeBundle(bundleId: string): Promise<SdkResult<Cart>>;
720
923
  /** Merge anonymous cart into authenticated customer cart */
721
- merge(): Promise<Cart>;
924
+ merge(): Promise<SdkResult<Cart>>;
722
925
  /** Apply discount code */
723
- applyDiscount(code: string): Promise<Cart>;
926
+ applyDiscount(code: string): Promise<SdkResult<Cart>>;
724
927
  /** Remove discount code */
725
- removeDiscount(): Promise<Cart>;
928
+ removeDiscount(): Promise<SdkResult<Cart>>;
726
929
  }
727
930
  declare class CheckoutModule {
728
931
  private client;
729
932
  constructor(client: BehioStorefront);
730
933
  /** Create order from cart */
731
- createOrder(input: CheckoutInput): Promise<OrderDetail>;
934
+ createOrder(input: CheckoutInput): Promise<SdkResult<OrderDetail>>;
732
935
  }
733
936
  declare class OrdersModule {
734
937
  private client;
@@ -737,92 +940,92 @@ declare class OrdersModule {
737
940
  list(options?: {
738
941
  page?: number;
739
942
  limit?: number;
740
- }): Promise<PaginatedResponse<OrderListItem>>;
943
+ }): Promise<SdkResult<PaginatedResponse<OrderListItem>>>;
741
944
  /** Get order detail (requires auth) */
742
- get(orderNumber: string): Promise<OrderDetail>;
945
+ get(orderNumber: string): Promise<SdkResult<OrderDetail>>;
743
946
  /** Cancel a PENDING order (requires auth) */
744
- cancel(orderNumber: string): Promise<OrderDetail>;
947
+ cancel(orderNumber: string): Promise<SdkResult<OrderDetail>>;
745
948
  /** Track order by tracking token (no customer login required, only API key) */
746
- track(trackingToken: string): Promise<OrderDetail>;
949
+ track(trackingToken: string): Promise<SdkResult<OrderDetail>>;
747
950
  }
748
951
  declare class CustomerModule {
749
952
  private client;
750
953
  constructor(client: BehioStorefront);
751
954
  /** Get customer profile */
752
- getProfile(): Promise<CustomerProfile>;
955
+ getProfile(): Promise<SdkResult<CustomerProfile>>;
753
956
  /** Update customer profile */
754
- updateProfile(data: Partial<Pick<CustomerProfile, "firstName" | "lastName" | "phone">>): Promise<CustomerProfile>;
957
+ updateProfile(data: Partial<Pick<CustomerProfile, "firstName" | "lastName" | "phone">>): Promise<SdkResult<CustomerProfile>>;
755
958
  /** Change password */
756
- changePassword(currentPassword: string, newPassword: string): Promise<MessageResponse>;
959
+ changePassword(currentPassword: string, newPassword: string): Promise<SdkResult<MessageResponse>>;
757
960
  /** List addresses */
758
- getAddresses(): Promise<{
961
+ getAddresses(): Promise<SdkResult<{
759
962
  items: CustomerAddress[];
760
- }>;
963
+ }>>;
761
964
  /** Create address */
762
- createAddress(address: Omit<CustomerAddress, "id">): Promise<CustomerAddress>;
965
+ createAddress(address: Omit<CustomerAddress, "id">): Promise<SdkResult<CustomerAddress>>;
763
966
  /** Update address */
764
- updateAddress(addressId: string, data: Partial<CustomerAddress>): Promise<CustomerAddress>;
967
+ updateAddress(addressId: string, data: Partial<CustomerAddress>): Promise<SdkResult<CustomerAddress>>;
765
968
  /** Delete address */
766
- deleteAddress(addressId: string): Promise<void>;
969
+ deleteAddress(addressId: string): Promise<SdkResult<void>>;
767
970
  }
768
971
  declare class PagesModule {
769
972
  private client;
770
973
  constructor(client: BehioStorefront);
771
974
  /** List CMS pages */
772
- list(locale?: string): Promise<{
975
+ list(locale?: string): Promise<SdkResult<{
773
976
  pages: Page[];
774
- }>;
977
+ }>>;
775
978
  /** Get page by slug */
776
- get(slug: string, locale?: string): Promise<PageDetail>;
979
+ get(slug: string, locale?: string): Promise<SdkResult<PageDetail>>;
777
980
  }
778
981
  declare class WishlistModule {
779
982
  private client;
780
983
  constructor(client: BehioStorefront);
781
- get(): Promise<{
984
+ get(): Promise<SdkResult<{
782
985
  items: WishlistItem[];
783
- }>;
784
- add(productId: string): Promise<{
986
+ }>>;
987
+ add(productId: string): Promise<SdkResult<{
785
988
  success: boolean;
786
- }>;
787
- remove(productId: string): Promise<{
989
+ }>>;
990
+ remove(productId: string): Promise<SdkResult<{
788
991
  success: boolean;
789
- }>;
790
- isInWishlist(productId: string): Promise<{
992
+ }>>;
993
+ isInWishlist(productId: string): Promise<SdkResult<{
791
994
  inWishlist: boolean;
792
- }>;
995
+ }>>;
793
996
  }
794
997
  declare class ReviewsModule {
795
998
  private client;
796
999
  constructor(client: BehioStorefront);
797
- getProductReviews(productId: string, page?: number, limit?: number): Promise<ProductReviewsResponse>;
798
- submit(input: SubmitReviewInput): Promise<{
1000
+ getProductReviews(productId: string, page?: number, limit?: number): Promise<SdkResult<ProductReviewsResponse>>;
1001
+ submit(input: SubmitReviewInput): Promise<SdkResult<{
799
1002
  id: string;
800
- }>;
801
- voteHelpful(reviewId: string, helpful: boolean): Promise<{
1003
+ }>>;
1004
+ voteHelpful(reviewId: string, helpful: boolean): Promise<SdkResult<{
802
1005
  success: boolean;
803
- }>;
1006
+ }>>;
804
1007
  }
805
1008
  declare class ReturnsModule {
806
1009
  private client;
807
1010
  constructor(client: BehioStorefront);
808
- submit(input: SubmitReturnInput): Promise<ReturnRequest>;
809
- getStatus(returnId: string, email: string): Promise<ReturnRequest>;
1011
+ submit(input: SubmitReturnInput): Promise<SdkResult<ReturnRequest>>;
1012
+ getStatus(returnId: string, email: string): Promise<SdkResult<ReturnRequest>>;
810
1013
  }
811
1014
  declare class ConsentModule {
812
1015
  private client;
813
1016
  constructor(client: BehioStorefront);
814
- record(input: CookieConsentInput): Promise<CookieConsent>;
815
- get(visitorId: string): Promise<CookieConsent | null>;
816
- revoke(visitorId: string): Promise<{
1017
+ record(input: CookieConsentInput): Promise<SdkResult<CookieConsent>>;
1018
+ get(visitorId: string): Promise<SdkResult<CookieConsent | null>>;
1019
+ revoke(visitorId: string): Promise<SdkResult<{
817
1020
  success: boolean;
818
- }>;
1021
+ }>>;
819
1022
  }
820
1023
  declare class QuotesModule {
821
1024
  private client;
822
1025
  constructor(client: BehioStorefront);
823
- submit(input: SubmitQuoteInput): Promise<QuoteRequest>;
824
- accept(quoteId: string, email: string): Promise<QuoteRequest>;
825
- getStatus(quoteId: string): Promise<QuoteRequest>;
1026
+ submit(input: SubmitQuoteInput): Promise<SdkResult<QuoteRequest>>;
1027
+ accept(quoteId: string, email: string): Promise<SdkResult<QuoteRequest>>;
1028
+ getStatus(quoteId: string): Promise<SdkResult<QuoteRequest>>;
826
1029
  }
827
1030
  interface AddressSuggestion {
828
1031
  placeId: string;
@@ -848,11 +1051,52 @@ declare class AddressModule {
848
1051
  private client;
849
1052
  constructor(client: BehioStorefront);
850
1053
  /** Search for address suggestions (debounce on your side, or use the React hook) */
851
- autocomplete(query: string, country: string): Promise<{
1054
+ autocomplete(query: string, country: string): Promise<SdkResult<{
852
1055
  suggestions: AddressSuggestion[];
853
- }>;
1056
+ }>>;
854
1057
  /** Get full structured address from a suggestion's placeId */
855
- getDetail(placeId: string): Promise<AddressDetail>;
1058
+ getDetail(placeId: string): Promise<SdkResult<AddressDetail>>;
1059
+ }
1060
+ /**
1061
+ * Storefront shipping module — list configured methods and fetch live
1062
+ * quotes for a destination + cart. Use `listMethods` for the always-on
1063
+ * picker (sidebar, info page) and `quote` once the customer enters a
1064
+ * destination address so live-quote providers (Zaslat etc.) can return
1065
+ * destination-specific prices.
1066
+ */
1067
+ declare class ShippingModule {
1068
+ private client;
1069
+ constructor(client: BehioStorefront);
1070
+ /**
1071
+ * Return the configured shipping methods that pass the current
1072
+ * currency + country filter. Fixed-price methods come back with
1073
+ * their `pricing[]` row resolved; live-quote methods come back with
1074
+ * `price` 0 here — call `quote()` to get the real live price.
1075
+ */
1076
+ listMethods(opts?: {
1077
+ currency?: string;
1078
+ country?: string;
1079
+ cartTotal?: number;
1080
+ cartWeightKg?: number;
1081
+ }): Promise<SdkResult<{
1082
+ items: ShippingMethodSummary[];
1083
+ }>>;
1084
+ /**
1085
+ * Quote shipping for a destination address + cart contents. Each
1086
+ * configured method is evaluated:
1087
+ * - `priceStrategy="fixed"` → resolved from the merchant's per-currency
1088
+ * `pricing[]` rows + free-shipping threshold check.
1089
+ * - `priceStrategy="live_quote"` → dispatched to the upstream
1090
+ * meta-provider (Zaslat, future Shippo / Sendcloud / …) and run
1091
+ * through the merchant's markup/rounding rules.
1092
+ *
1093
+ * Filter `available: true` for the checkout picker; `available: false`
1094
+ * rows carry a `reason` (`"no_rate_returned"`, `"live_quote_not_implemented"`,
1095
+ * …) you can log but should not display.
1096
+ */
1097
+ quote(input: ShippingQuoteInput): Promise<SdkResult<{
1098
+ items: ShippingQuote[];
1099
+ }>>;
856
1100
  }
857
1101
 
858
- export { type ActivePromotion, type AddToCartInput, type AddressDetail, type AddressSuggestion, type AddressType, AddressTypes, type AuthTokens, BehioApiError, type BehioErrorCode, type BehioEventHandler, type BehioEventType, BehioNetworkError, BehioStorefront, type BehioStorefrontConfig, type Bundle, type BundleItem, type Cart, type CartDiscount, type CartItem, type CartItemProduct, type Category, type CategoryDetail, type CheckoutAddress, type CheckoutInput, type CookieConsent, type CookieConsentInput, type CrossSellItem, type CustomerAddress, type CustomerProfile, type DataGroupFieldType, type FilterField, type FulfillmentStatus, FulfillmentStatuses, type GiftCardBalance, type LoginInput, type MessageResponse, type OrderDetail, type OrderItem, type OrderListItem, type OrderStatus, type OrderStatusHistory, OrderStatuses, type Page, type PageDetail, type PaginatedResponse, type PaymentStatus, PaymentStatuses, type ProductDetail, type ProductLabel, type ProductListItem, type ProductPrice, type ProductReview, type ProductReviewsResponse, ProductSort, type ProductSortValue, type ProductVariant, type ProductVolumePrice, type ProductsQuery, type QuoteRequest, type RegisterInput, type RequestInterceptor, type RequestInterceptorConfig, type ResponseInterceptor, type ResponseInterceptorData, type ReturnRequest, type ShopInfo, type ShopSeo, type SubmitQuoteInput, type SubmitReturnInput, type SubmitReviewInput, type WishlistItem };
1102
+ export { type ActivePromotion, type AddToCartInput, type AddressDetail, type AddressSuggestion, type AddressType, AddressTypes, type AuthTokens, BehioApiError, type BehioErrorCode, type BehioEventHandler, type BehioEventType, BehioNetworkError, BehioStorefront, type BehioStorefrontConfig, type Bundle, type BundleItem, type Cart, type CartDiscount, type CartItem, type CartItemProduct, type Category, type CategoryDetail, type CheckoutAddress, type CheckoutInput, type CheckoutPaymentMethod, type CookieConsent, type CookieConsentInput, type CrossSellItem, type CustomerAddress, type CustomerProfile, type DataGroupFieldType, type FilterField, type FulfillmentStatus, FulfillmentStatuses, type GiftCardBalance, type LoginInput, type MessageResponse, type OrderDetail, type OrderItem, type OrderListItem, type OrderStatus, type OrderStatusHistory, OrderStatuses, type Page, type PageDetail, type PaginatedResponse, type PaymentStatus, PaymentStatuses, type ProductDetail, type ProductLabel, type ProductListItem, type ProductPrice, type ProductReview, type ProductReviewsResponse, ProductSort, type ProductSortValue, type ProductVariant, type ProductVolumePrice, type ProductsQuery, type QuoteRequest, type RegisterInput, type RequestInterceptor, type RequestInterceptorConfig, type ResponseInterceptor, type ResponseInterceptorData, type ReturnRequest, type SdkError, type SdkResult, type ShippingMethodSummary, type ShippingQuote, type ShippingQuoteInput, type ShopInfo, type ShopSeo, type SubmitQuoteInput, type SubmitReturnInput, type SubmitReviewInput, type WishlistItem, err, ok, toSdkError };
package/dist/index.js CHANGED
@@ -7,14 +7,20 @@
7
7
 
8
8
 
9
9
 
10
- var _chunkZEPWNT56js = require('./chunk-ZEPWNT56.js');
11
10
 
12
11
 
13
12
 
13
+ var _chunkKRGDHGTYjs = require('./chunk-KRGDHGTY.js');
14
14
 
15
15
 
16
16
 
17
17
 
18
18
 
19
19
 
20
- exports.AddressTypes = _chunkZEPWNT56js.AddressTypes; exports.BehioApiError = _chunkZEPWNT56js.BehioApiError; exports.BehioNetworkError = _chunkZEPWNT56js.BehioNetworkError; exports.BehioStorefront = _chunkZEPWNT56js.BehioStorefront; exports.FulfillmentStatuses = _chunkZEPWNT56js.FulfillmentStatuses; exports.OrderStatuses = _chunkZEPWNT56js.OrderStatuses; exports.PaymentStatuses = _chunkZEPWNT56js.PaymentStatuses; exports.ProductSort = _chunkZEPWNT56js.ProductSort;
20
+
21
+
22
+
23
+
24
+
25
+
26
+ exports.AddressTypes = _chunkKRGDHGTYjs.AddressTypes; exports.BehioApiError = _chunkKRGDHGTYjs.BehioApiError; exports.BehioNetworkError = _chunkKRGDHGTYjs.BehioNetworkError; exports.BehioStorefront = _chunkKRGDHGTYjs.BehioStorefront; exports.FulfillmentStatuses = _chunkKRGDHGTYjs.FulfillmentStatuses; exports.OrderStatuses = _chunkKRGDHGTYjs.OrderStatuses; exports.PaymentStatuses = _chunkKRGDHGTYjs.PaymentStatuses; exports.ProductSort = _chunkKRGDHGTYjs.ProductSort; exports.err = _chunkKRGDHGTYjs.err; exports.ok = _chunkKRGDHGTYjs.ok; exports.toSdkError = _chunkKRGDHGTYjs.toSdkError;
package/dist/index.mjs CHANGED
@@ -6,8 +6,11 @@ import {
6
6
  FulfillmentStatuses,
7
7
  OrderStatuses,
8
8
  PaymentStatuses,
9
- ProductSort
10
- } from "./chunk-45FTJKSW.mjs";
9
+ ProductSort,
10
+ err,
11
+ ok,
12
+ toSdkError
13
+ } from "./chunk-3GOQSB25.mjs";
11
14
  export {
12
15
  AddressTypes,
13
16
  BehioApiError,
@@ -16,5 +19,8 @@ export {
16
19
  FulfillmentStatuses,
17
20
  OrderStatuses,
18
21
  PaymentStatuses,
19
- ProductSort
22
+ ProductSort,
23
+ err,
24
+ ok,
25
+ toSdkError
20
26
  };