@behio/storefront-sdk 0.24.0 → 0.25.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/react.mjs CHANGED
@@ -4,7 +4,7 @@ import {
4
4
  } from "./chunk-ZOZAJG6T.mjs";
5
5
  import {
6
6
  BehioStorefront
7
- } from "./chunk-OFUECU3W.mjs";
7
+ } from "./chunk-V5WU3XI4.mjs";
8
8
 
9
9
  // src/react/provider.tsx
10
10
  import { useRef, useEffect, useMemo, useState, useCallback } from "react";
@@ -334,11 +334,22 @@ function useCategory(slug, options) {
334
334
  });
335
335
  }
336
336
 
337
- // src/react/hooks/use-labels.ts
337
+ // src/react/hooks/use-menu.ts
338
338
  import { useQuery as useQuery3 } from "@tanstack/react-query";
339
- function useLabels(locale, options) {
339
+ function useMenu(handle, options) {
340
340
  const { client } = useBehio();
341
341
  return useQuery3({
342
+ queryKey: ["behio", "menu", handle, options?.locale],
343
+ queryFn: () => unwrap(client.catalog.getMenu(handle, { locale: options?.locale })),
344
+ enabled: options?.enabled !== false && !!handle
345
+ });
346
+ }
347
+
348
+ // src/react/hooks/use-labels.ts
349
+ import { useQuery as useQuery4 } from "@tanstack/react-query";
350
+ function useLabels(locale, options) {
351
+ const { client } = useBehio();
352
+ return useQuery4({
342
353
  queryKey: ["behio", "labels", locale],
343
354
  queryFn: async () => {
344
355
  const result = await unwrap(client.catalog.getLabels(locale));
@@ -349,10 +360,10 @@ function useLabels(locale, options) {
349
360
  }
350
361
 
351
362
  // src/react/hooks/use-featured.ts
352
- import { useQuery as useQuery4 } from "@tanstack/react-query";
363
+ import { useQuery as useQuery5 } from "@tanstack/react-query";
353
364
  function useFeatured(options) {
354
365
  const { client } = useBehio();
355
- return useQuery4({
366
+ return useQuery5({
356
367
  queryKey: ["behio", "featured", options?.locale, options?.currency],
357
368
  queryFn: () => unwrap(client.catalog.getFeatured({
358
369
  locale: options?.locale,
@@ -364,10 +375,10 @@ function useFeatured(options) {
364
375
  }
365
376
 
366
377
  // src/react/hooks/use-filters.ts
367
- import { useQuery as useQuery5 } from "@tanstack/react-query";
378
+ import { useQuery as useQuery6 } from "@tanstack/react-query";
368
379
  function useFilters(options) {
369
380
  const { client } = useBehio();
370
- return useQuery5({
381
+ return useQuery6({
371
382
  queryKey: ["behio", "filters"],
372
383
  queryFn: async () => {
373
384
  const result = await unwrap(client.catalog.getFilters());
@@ -379,7 +390,7 @@ function useFilters(options) {
379
390
 
380
391
  // src/react/hooks/use-search.ts
381
392
  import { useState as useState3, useEffect as useEffect2 } from "react";
382
- import { useQuery as useQuery6 } from "@tanstack/react-query";
393
+ import { useQuery as useQuery7 } from "@tanstack/react-query";
383
394
  function useSearch(query, options) {
384
395
  const { client } = useBehio();
385
396
  const debounceMs = options?.debounceMs ?? 300;
@@ -392,7 +403,7 @@ function useSearch(query, options) {
392
403
  const timer = setTimeout(() => setDebouncedQuery(query), debounceMs);
393
404
  return () => clearTimeout(timer);
394
405
  }, [query, debounceMs]);
395
- return useQuery6({
406
+ return useQuery7({
396
407
  queryKey: ["behio", "search", debouncedQuery, options?.page, options?.limit],
397
408
  queryFn: () => unwrap(client.catalog.search(debouncedQuery, {
398
409
  page: options?.page,
@@ -404,7 +415,7 @@ function useSearch(query, options) {
404
415
 
405
416
  // src/react/hooks/use-cart.ts
406
417
  import { useCallback as useCallback3 } from "react";
407
- import { useQuery as useQuery7, useMutation, useQueryClient } from "@tanstack/react-query";
418
+ import { useQuery as useQuery8, useMutation, useQueryClient } from "@tanstack/react-query";
408
419
  var CART_KEY = ["behio", "cart"];
409
420
  function useCart(options) {
410
421
  const { client, storage } = useBehio();
@@ -413,7 +424,7 @@ function useCart(options) {
413
424
  data: cart,
414
425
  isLoading,
415
426
  error
416
- } = useQuery7({
427
+ } = useQuery8({
417
428
  queryKey: [...CART_KEY],
418
429
  queryFn: () => unwrap(client.cart.get()),
419
430
  // Only fetch if we have a cart session or are logged in
@@ -563,13 +574,13 @@ function useCart(options) {
563
574
  }
564
575
 
565
576
  // src/react/hooks/use-cart-count.ts
566
- import { useQuery as useQuery8, useQueryClient as useQueryClient2 } from "@tanstack/react-query";
577
+ import { useQuery as useQuery9, useQueryClient as useQueryClient2 } from "@tanstack/react-query";
567
578
  var CART_KEY2 = ["behio", "cart"];
568
579
  function useCartCount(options) {
569
580
  const { client } = useBehio();
570
581
  const queryClient = useQueryClient2();
571
582
  const cachedCart = queryClient.getQueryData([...CART_KEY2]);
572
- const { data } = useQuery8({
583
+ const { data } = useQuery9({
573
584
  queryKey: [...CART_KEY2],
574
585
  queryFn: () => unwrap(client.cart.get()),
575
586
  enabled: options?.enabled !== false && !cachedCart && (!!client.getCartSession() || !!client.getAccessToken())
@@ -580,7 +591,7 @@ function useCartCount(options) {
580
591
 
581
592
  // src/react/hooks/use-auth.ts
582
593
  import { useCallback as useCallback4 } from "react";
583
- import { useQuery as useQuery9, useMutation as useMutation2, useQueryClient as useQueryClient3 } from "@tanstack/react-query";
594
+ import { useQuery as useQuery10, useMutation as useMutation2, useQueryClient as useQueryClient3 } from "@tanstack/react-query";
584
595
  var CUSTOMER_KEY = ["behio", "customer"];
585
596
  var CART_KEY3 = ["behio", "cart"];
586
597
  function useAuth() {
@@ -590,7 +601,7 @@ function useAuth() {
590
601
  const {
591
602
  data: customer,
592
603
  isLoading
593
- } = useQuery9({
604
+ } = useQuery10({
594
605
  queryKey: [...CUSTOMER_KEY],
595
606
  queryFn: () => unwrap(client.customer.getProfile()),
596
607
  enabled: isLoggedIn
@@ -703,7 +714,7 @@ function useAuth() {
703
714
 
704
715
  // src/react/hooks/use-customer.ts
705
716
  import { useCallback as useCallback5 } from "react";
706
- import { useQuery as useQuery10, useMutation as useMutation3, useQueryClient as useQueryClient4 } from "@tanstack/react-query";
717
+ import { useQuery as useQuery11, useMutation as useMutation3, useQueryClient as useQueryClient4 } from "@tanstack/react-query";
707
718
  var CUSTOMER_KEY2 = ["behio", "customer"];
708
719
  function useCustomer(options) {
709
720
  const { client } = useBehio();
@@ -712,7 +723,7 @@ function useCustomer(options) {
712
723
  data,
713
724
  isLoading,
714
725
  error
715
- } = useQuery10({
726
+ } = useQuery11({
716
727
  queryKey: [...CUSTOMER_KEY2],
717
728
  queryFn: () => unwrap(client.customer.getProfile()),
718
729
  enabled: options?.enabled !== false && !!client.getAccessToken()
@@ -738,7 +749,7 @@ function useCustomer(options) {
738
749
 
739
750
  // src/react/hooks/use-addresses.ts
740
751
  import { useCallback as useCallback6 } from "react";
741
- import { useQuery as useQuery11, useMutation as useMutation4, useQueryClient as useQueryClient5 } from "@tanstack/react-query";
752
+ import { useQuery as useQuery12, useMutation as useMutation4, useQueryClient as useQueryClient5 } from "@tanstack/react-query";
742
753
  var ADDRESSES_KEY = ["behio", "addresses"];
743
754
  function useAddresses(options) {
744
755
  const { client } = useBehio();
@@ -747,7 +758,7 @@ function useAddresses(options) {
747
758
  data,
748
759
  isLoading,
749
760
  error
750
- } = useQuery11({
761
+ } = useQuery12({
751
762
  queryKey: [...ADDRESSES_KEY],
752
763
  queryFn: async () => {
753
764
  const result = await unwrap(client.customer.getAddresses());
@@ -799,7 +810,7 @@ function useAddresses(options) {
799
810
 
800
811
  // src/react/hooks/use-address-autocomplete.ts
801
812
  import { useState as useState4, useEffect as useEffect3, useRef as useRef2, useCallback as useCallback7 } from "react";
802
- import { useQuery as useQuery12 } from "@tanstack/react-query";
813
+ import { useQuery as useQuery13 } from "@tanstack/react-query";
803
814
  var AC_KEY = ["behio", "address-autocomplete"];
804
815
  function useAddressAutocomplete(options) {
805
816
  const { country, debounce = 300, minChars = 3, enabled = true } = options;
@@ -822,7 +833,7 @@ function useAddressAutocomplete(options) {
822
833
  if (timerRef.current) clearTimeout(timerRef.current);
823
834
  };
824
835
  }, [query, debounce, minChars]);
825
- const { data, isLoading } = useQuery12({
836
+ const { data, isLoading } = useQuery13({
826
837
  queryKey: [...AC_KEY, debouncedQuery, country],
827
838
  queryFn: () => unwrap(client.addresses.autocomplete(debouncedQuery, country)),
828
839
  enabled: enabled && debouncedQuery.length >= minChars,
@@ -914,7 +925,7 @@ function useOrders(options) {
914
925
 
915
926
  // src/react/hooks/use-order.ts
916
927
  import { useCallback as useCallback9 } from "react";
917
- import { useQuery as useQuery13, useMutation as useMutation5, useQueryClient as useQueryClient7 } from "@tanstack/react-query";
928
+ import { useQuery as useQuery14, useMutation as useMutation5, useQueryClient as useQueryClient7 } from "@tanstack/react-query";
918
929
  function useOrder(orderNumber, options) {
919
930
  const { client } = useBehio();
920
931
  const queryClient = useQueryClient7();
@@ -922,7 +933,7 @@ function useOrder(orderNumber, options) {
922
933
  data,
923
934
  isLoading,
924
935
  error
925
- } = useQuery13({
936
+ } = useQuery14({
926
937
  queryKey: ["behio", "order", orderNumber],
927
938
  queryFn: () => unwrap(client.orders.get(orderNumber)),
928
939
  enabled: options?.enabled !== false && !!orderNumber && !!client.getAccessToken()
@@ -1041,10 +1052,10 @@ function useCheckout() {
1041
1052
  }
1042
1053
 
1043
1054
  // src/react/hooks/use-pages.ts
1044
- import { useQuery as useQuery14 } from "@tanstack/react-query";
1055
+ import { useQuery as useQuery15 } from "@tanstack/react-query";
1045
1056
  function usePages(locale, options) {
1046
1057
  const { client } = useBehio();
1047
- return useQuery14({
1058
+ return useQuery15({
1048
1059
  queryKey: ["behio", "pages", locale],
1049
1060
  queryFn: async () => {
1050
1061
  const result = await unwrap(client.pages.list(locale));
@@ -1055,7 +1066,7 @@ function usePages(locale, options) {
1055
1066
  }
1056
1067
  function usePage(slug, locale, options) {
1057
1068
  const { client } = useBehio();
1058
- return useQuery14({
1069
+ return useQuery15({
1059
1070
  queryKey: ["behio", "page", slug, locale],
1060
1071
  queryFn: () => unwrap(client.pages.get(slug, locale)),
1061
1072
  enabled: options?.enabled !== false && !!slug
@@ -1063,10 +1074,10 @@ function usePage(slug, locale, options) {
1063
1074
  }
1064
1075
 
1065
1076
  // src/react/hooks/use-shop-info.ts
1066
- import { useQuery as useQuery15 } from "@tanstack/react-query";
1077
+ import { useQuery as useQuery16 } from "@tanstack/react-query";
1067
1078
  function useShopInfo(options) {
1068
1079
  const { client } = useBehio();
1069
- return useQuery15({
1080
+ return useQuery16({
1070
1081
  queryKey: ["behio", "shop-info"],
1071
1082
  queryFn: () => unwrap(client.getShopInfo()),
1072
1083
  enabled: options?.enabled !== false
@@ -1074,10 +1085,10 @@ function useShopInfo(options) {
1074
1085
  }
1075
1086
 
1076
1087
  // src/react/hooks/use-shop-scripts.ts
1077
- import { useQuery as useQuery16 } from "@tanstack/react-query";
1088
+ import { useQuery as useQuery17 } from "@tanstack/react-query";
1078
1089
  function useShopScripts(options) {
1079
1090
  const { client } = useBehio();
1080
- return useQuery16({
1091
+ return useQuery17({
1081
1092
  queryKey: ["behio", "shop-scripts"],
1082
1093
  queryFn: () => unwrap(client.getShopScripts()),
1083
1094
  enabled: options?.enabled !== false
@@ -1085,11 +1096,11 @@ function useShopScripts(options) {
1085
1096
  }
1086
1097
 
1087
1098
  // src/react/hooks/use-shop-seo.ts
1088
- import { useQuery as useQuery17 } from "@tanstack/react-query";
1099
+ import { useQuery as useQuery18 } from "@tanstack/react-query";
1089
1100
  function useShopSeo(options) {
1090
1101
  const { client } = useBehio();
1091
1102
  const { locale, initialData, enabled = true } = options ?? {};
1092
- return useQuery17({
1103
+ return useQuery18({
1093
1104
  queryKey: ["behio", "shop-seo", locale ?? "_default"],
1094
1105
  queryFn: () => unwrap(client.getShopSeo(locale)),
1095
1106
  initialData,
@@ -1152,11 +1163,11 @@ function CurrencySwitcher({
1152
1163
  import { useEffect as useEffect4, useMemo as useMemo4, useState as useState8 } from "react";
1153
1164
 
1154
1165
  // src/react/hooks/use-consent.ts
1155
- import { useQuery as useQuery18, useMutation as useMutation8, useQueryClient as useQueryClient9 } from "@tanstack/react-query";
1166
+ import { useQuery as useQuery19, useMutation as useMutation8, useQueryClient as useQueryClient9 } from "@tanstack/react-query";
1156
1167
  function useCookieConsent(visitorId) {
1157
1168
  const { client } = useBehio();
1158
1169
  const qc = useQueryClient9();
1159
- const query = useQuery18({
1170
+ const query = useQuery19({
1160
1171
  queryKey: ["behio", "consent", visitorId],
1161
1172
  queryFn: () => unwrap(client.consent.get(visitorId)),
1162
1173
  enabled: Boolean(visitorId)
@@ -1497,10 +1508,10 @@ function utmFromSearch(search) {
1497
1508
  }
1498
1509
 
1499
1510
  // src/react/hooks/use-bundles.ts
1500
- import { useQuery as useQuery19 } from "@tanstack/react-query";
1511
+ import { useQuery as useQuery20 } from "@tanstack/react-query";
1501
1512
  function useBundles(options) {
1502
1513
  const { client } = useBehio();
1503
- return useQuery19({
1514
+ return useQuery20({
1504
1515
  queryKey: ["behio", "bundles"],
1505
1516
  queryFn: () => unwrap(client.catalog.getBundles()),
1506
1517
  enabled: options?.enabled ?? true,
@@ -1509,7 +1520,7 @@ function useBundles(options) {
1509
1520
  }
1510
1521
  function useBundle(slug, options) {
1511
1522
  const { client } = useBehio();
1512
- return useQuery19({
1523
+ return useQuery20({
1513
1524
  queryKey: ["behio", "bundle", slug],
1514
1525
  queryFn: () => unwrap(client.catalog.getBundle(slug)),
1515
1526
  enabled: Boolean(slug) && (options?.enabled ?? true),
@@ -1518,10 +1529,10 @@ function useBundle(slug, options) {
1518
1529
  }
1519
1530
 
1520
1531
  // src/react/hooks/use-cross-sell.ts
1521
- import { useQuery as useQuery20 } from "@tanstack/react-query";
1532
+ import { useQuery as useQuery21 } from "@tanstack/react-query";
1522
1533
  function useCrossSell(productSlug, options) {
1523
1534
  const { client } = useBehio();
1524
- return useQuery20({
1535
+ return useQuery21({
1525
1536
  queryKey: ["behio", "cross-sell", productSlug],
1526
1537
  queryFn: () => unwrap(client.catalog.getCrossSell(productSlug)),
1527
1538
  enabled: Boolean(productSlug) && (options?.enabled ?? true),
@@ -1530,10 +1541,10 @@ function useCrossSell(productSlug, options) {
1530
1541
  }
1531
1542
 
1532
1543
  // src/react/hooks/use-product-promotions.ts
1533
- import { useQuery as useQuery21 } from "@tanstack/react-query";
1544
+ import { useQuery as useQuery22 } from "@tanstack/react-query";
1534
1545
  function useProductPromotions(productSlug, options) {
1535
1546
  const { client } = useBehio();
1536
- return useQuery21({
1547
+ return useQuery22({
1537
1548
  queryKey: ["behio", "product-promotions", productSlug],
1538
1549
  queryFn: () => unwrap(client.catalog.getProductPromotions(productSlug)),
1539
1550
  enabled: Boolean(productSlug) && (options?.enabled ?? true),
@@ -1542,11 +1553,11 @@ function useProductPromotions(productSlug, options) {
1542
1553
  }
1543
1554
 
1544
1555
  // src/react/hooks/use-gift-card.ts
1545
- import { useQuery as useQuery22 } from "@tanstack/react-query";
1556
+ import { useQuery as useQuery23 } from "@tanstack/react-query";
1546
1557
  function useGiftCardBalance(code, options) {
1547
1558
  const { client } = useBehio();
1548
1559
  const trimmed = code?.trim();
1549
- return useQuery22({
1560
+ return useQuery23({
1550
1561
  queryKey: ["behio", "gift-card-balance", trimmed],
1551
1562
  queryFn: () => unwrap(client.catalog.checkGiftCard(trimmed)),
1552
1563
  enabled: Boolean(trimmed && trimmed.length >= 6) && (options?.enabled ?? true)
@@ -1554,11 +1565,11 @@ function useGiftCardBalance(code, options) {
1554
1565
  }
1555
1566
 
1556
1567
  // src/react/hooks/use-wishlist.ts
1557
- import { useQuery as useQuery23, useMutation as useMutation9, useQueryClient as useQueryClient10 } from "@tanstack/react-query";
1568
+ import { useQuery as useQuery24, useMutation as useMutation9, useQueryClient as useQueryClient10 } from "@tanstack/react-query";
1558
1569
  function useWishlist(options) {
1559
1570
  const { client } = useBehio();
1560
1571
  const qc = useQueryClient10();
1561
- const query = useQuery23({
1572
+ const query = useQuery24({
1562
1573
  queryKey: ["behio", "wishlist"],
1563
1574
  queryFn: () => unwrap(client.wishlist.get()),
1564
1575
  enabled: options?.enabled ?? true
@@ -1581,7 +1592,7 @@ function useWishlist(options) {
1581
1592
  }
1582
1593
  function useIsInWishlist(productId) {
1583
1594
  const { client } = useBehio();
1584
- return useQuery23({
1595
+ return useQuery24({
1585
1596
  queryKey: ["behio", "wishlist-check", productId],
1586
1597
  queryFn: () => unwrap(client.wishlist.isInWishlist(productId)),
1587
1598
  enabled: Boolean(productId)
@@ -1589,10 +1600,10 @@ function useIsInWishlist(productId) {
1589
1600
  }
1590
1601
 
1591
1602
  // src/react/hooks/use-reviews.ts
1592
- import { useQuery as useQuery24, useMutation as useMutation10, useQueryClient as useQueryClient11 } from "@tanstack/react-query";
1603
+ import { useQuery as useQuery25, useMutation as useMutation10, useQueryClient as useQueryClient11 } from "@tanstack/react-query";
1593
1604
  function useProductReviews(productId, options) {
1594
1605
  const { client } = useBehio();
1595
- return useQuery24({
1606
+ return useQuery25({
1596
1607
  queryKey: ["behio", "reviews", productId, options?.page ?? 1],
1597
1608
  queryFn: () => unwrap(client.reviews.getProductReviews(productId, options?.page, options?.limit)),
1598
1609
  enabled: Boolean(productId) && (options?.enabled ?? true)
@@ -1608,7 +1619,7 @@ function useSubmitReview() {
1608
1619
  }
1609
1620
 
1610
1621
  // src/react/hooks/use-returns.ts
1611
- import { useQuery as useQuery25, useMutation as useMutation11 } from "@tanstack/react-query";
1622
+ import { useQuery as useQuery26, useMutation as useMutation11 } from "@tanstack/react-query";
1612
1623
  function useLookupReturnableOrder() {
1613
1624
  const { client } = useBehio();
1614
1625
  return useMutation11({
@@ -1623,7 +1634,7 @@ function useSubmitReturn() {
1623
1634
  }
1624
1635
  function useReturnStatus(returnId, email) {
1625
1636
  const { client } = useBehio();
1626
- return useQuery25({
1637
+ return useQuery26({
1627
1638
  queryKey: ["behio", "return-status", returnId],
1628
1639
  queryFn: () => unwrap(client.returns.getStatus(returnId, email)),
1629
1640
  enabled: Boolean(returnId && email)
@@ -1631,7 +1642,7 @@ function useReturnStatus(returnId, email) {
1631
1642
  }
1632
1643
 
1633
1644
  // src/react/hooks/use-quotes.ts
1634
- import { useMutation as useMutation12, useQuery as useQuery26 } from "@tanstack/react-query";
1645
+ import { useMutation as useMutation12, useQuery as useQuery27 } from "@tanstack/react-query";
1635
1646
  function useSubmitQuote() {
1636
1647
  const { client } = useBehio();
1637
1648
  return useMutation12({
@@ -1640,7 +1651,7 @@ function useSubmitQuote() {
1640
1651
  }
1641
1652
  function useQuoteStatus(quoteId, email) {
1642
1653
  const { client } = useBehio();
1643
- return useQuery26({
1654
+ return useQuery27({
1644
1655
  queryKey: ["behio", "quote-status", quoteId],
1645
1656
  queryFn: () => unwrap(client.quotes.getStatus(quoteId, email)),
1646
1657
  enabled: Boolean(quoteId && email)
@@ -1689,6 +1700,7 @@ export {
1689
1700
  useIsInWishlist,
1690
1701
  useLabels,
1691
1702
  useLookupReturnableOrder,
1703
+ useMenu,
1692
1704
  useNotifyWhenAvailable,
1693
1705
  useOrder,
1694
1706
  useOrderAccess,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@behio/storefront-sdk",
3
- "version": "0.24.0",
4
- "description": "TypeScript SDK for Behio Headless E-Shop core client + React hooks",
3
+ "version": "0.25.0",
4
+ "description": "TypeScript SDK for Behio Headless E-Shop \u2014 core client + React hooks",
5
5
  "author": "Behio",
6
6
  "license": "MIT",
7
7
  "main": "./dist/index.js",
@@ -63,4 +63,4 @@
63
63
  "tsup": "^8.0.0",
64
64
  "typescript": "^5.2.0"
65
65
  }
66
- }
66
+ }