@behio/storefront-sdk 2.20.0 → 2.21.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
@@ -172,6 +172,7 @@ var BehioStorefront = class {
172
172
  this.blog = new BlogModule(this);
173
173
  this.forms = new FormsModule(this);
174
174
  this.collections = new CollectionsModule(this);
175
+ this.faq = new FaqModule(this);
175
176
  this.wishlist = new WishlistModule(this);
176
177
  this.reviews = new ReviewsModule(this);
177
178
  this.returns = new ReturnsModule(this);
@@ -1828,6 +1829,26 @@ var CollectionsModule = class {
1828
1829
  );
1829
1830
  }
1830
1831
  };
1832
+ var FaqModule = class {
1833
+ constructor(client) {
1834
+ this.client = client;
1835
+ }
1836
+ /** FAQ groups of the site in the admin order with the number of visible questions. */
1837
+ async list(query) {
1838
+ return this.client.request("GET", "/faq", {
1839
+ query: { locale: query?.locale }
1840
+ });
1841
+ }
1842
+ /**
1843
+ * One group by its slug or id with its visible questions. 404
1844
+ * `be.faq.groupNotFound` for an unknown group.
1845
+ */
1846
+ async get(group, query) {
1847
+ return this.client.request("GET", `/faq/${encodeURIComponent(group)}`, {
1848
+ query: { locale: query?.locale }
1849
+ });
1850
+ }
1851
+ };
1831
1852
  var FormsModule = class {
1832
1853
  constructor(client) {
1833
1854
  this.client = client;
@@ -4003,9 +4024,28 @@ function useCollectionItem(slug, itemSlugOrId, options) {
4003
4024
  });
4004
4025
  }
4005
4026
 
4027
+ // src/react/hooks/use-faq.ts
4028
+ import { useQuery as useQuery32 } from "@tanstack/react-query";
4029
+ function useFaqGroups(query, options) {
4030
+ const { client } = useBehio();
4031
+ return useQuery32({
4032
+ queryKey: ["behio", "faq", query?.locale],
4033
+ queryFn: () => unwrap(client.faq.list(query)),
4034
+ enabled: options?.enabled !== false
4035
+ });
4036
+ }
4037
+ function useFaqGroup(group, query, options) {
4038
+ const { client } = useBehio();
4039
+ return useQuery32({
4040
+ queryKey: ["behio", "faq", group, query?.locale],
4041
+ queryFn: () => unwrap(client.faq.get(group, query)),
4042
+ enabled: options?.enabled !== false && !!group
4043
+ });
4044
+ }
4045
+
4006
4046
  // src/react/hooks/use-site-form.ts
4007
4047
  import { useCallback as useCallback15, useMemo as useMemo4 } from "react";
4008
- import { useMutation as useMutation15, useQuery as useQuery32 } from "@tanstack/react-query";
4048
+ import { useMutation as useMutation15, useQuery as useQuery33 } from "@tanstack/react-query";
4009
4049
 
4010
4050
  // src/errors.ts
4011
4051
  function bodyOf(err) {
@@ -4056,7 +4096,7 @@ function formFieldErrors(err) {
4056
4096
  // src/react/hooks/use-site-form.ts
4057
4097
  function useSiteForm(slug, options) {
4058
4098
  const { client } = useBehio();
4059
- return useQuery32({
4099
+ return useQuery33({
4060
4100
  queryKey: ["behio", "form", slug],
4061
4101
  queryFn: () => unwrap(client.forms.get(slug)),
4062
4102
  enabled: options?.enabled !== false && !!slug
@@ -4100,10 +4140,10 @@ function useSiteFormSubmit(slug) {
4100
4140
  }
4101
4141
 
4102
4142
  // src/react/hooks/use-shop-info.ts
4103
- import { useQuery as useQuery33 } from "@tanstack/react-query";
4143
+ import { useQuery as useQuery34 } from "@tanstack/react-query";
4104
4144
  function useShopInfo(options) {
4105
4145
  const { client } = useBehio();
4106
- return useQuery33({
4146
+ return useQuery34({
4107
4147
  queryKey: ["behio", "shop-info"],
4108
4148
  queryFn: () => unwrap(client.getShopInfo()),
4109
4149
  enabled: options?.enabled !== false
@@ -4111,10 +4151,10 @@ function useShopInfo(options) {
4111
4151
  }
4112
4152
 
4113
4153
  // src/react/hooks/use-shop-scripts.ts
4114
- import { useQuery as useQuery34 } from "@tanstack/react-query";
4154
+ import { useQuery as useQuery35 } from "@tanstack/react-query";
4115
4155
  function useShopScripts(options) {
4116
4156
  const { client } = useBehio();
4117
- return useQuery34({
4157
+ return useQuery35({
4118
4158
  queryKey: ["behio", "shop-scripts"],
4119
4159
  queryFn: () => unwrap(client.getShopScripts()),
4120
4160
  enabled: options?.enabled !== false,
@@ -4123,11 +4163,11 @@ function useShopScripts(options) {
4123
4163
  }
4124
4164
 
4125
4165
  // src/react/hooks/use-shop-seo.ts
4126
- import { useQuery as useQuery35 } from "@tanstack/react-query";
4166
+ import { useQuery as useQuery36 } from "@tanstack/react-query";
4127
4167
  function useShopSeo(options) {
4128
4168
  const { client } = useBehio();
4129
4169
  const { locale, initialData, enabled = true } = options ?? {};
4130
- return useQuery35({
4170
+ return useQuery36({
4131
4171
  queryKey: ["behio", "shop-seo", locale ?? "_default"],
4132
4172
  queryFn: () => unwrap(client.getShopSeo(locale)),
4133
4173
  initialData,
@@ -4190,11 +4230,11 @@ function CurrencySwitcher({
4190
4230
  import { useEffect as useEffect7, useMemo as useMemo5, useRef as useRef4, useState as useState10 } from "react";
4191
4231
 
4192
4232
  // src/react/hooks/use-consent.ts
4193
- import { useQuery as useQuery36, useMutation as useMutation16, useQueryClient as useQueryClient16 } from "@tanstack/react-query";
4233
+ import { useQuery as useQuery37, useMutation as useMutation16, useQueryClient as useQueryClient16 } from "@tanstack/react-query";
4194
4234
  function useCookieConsent(visitorId) {
4195
4235
  const { client } = useBehio();
4196
4236
  const qc = useQueryClient16();
4197
- const query = useQuery36({
4237
+ const query = useQuery37({
4198
4238
  queryKey: ["behio", "consent", visitorId],
4199
4239
  queryFn: () => unwrap(client.consent.get(visitorId)),
4200
4240
  enabled: Boolean(visitorId)
@@ -4582,11 +4622,11 @@ function RichText({ html, className, as = "div" }) {
4582
4622
  }
4583
4623
 
4584
4624
  // src/react/hooks/use-bundles.ts
4585
- import { useQuery as useQuery37 } from "@tanstack/react-query";
4625
+ import { useQuery as useQuery38 } from "@tanstack/react-query";
4586
4626
  function useBundles(options) {
4587
4627
  const { client, sessionRestored } = useBehio();
4588
4628
  const query = { locale: options?.locale ?? client.getLocale(), currency: options?.currency ?? client.getCurrency(), country: options?.country ?? client.getCountry() };
4589
- return useQuery37({
4629
+ return useQuery38({
4590
4630
  queryKey: ["behio", "bundles", query],
4591
4631
  queryFn: () => unwrap(client.catalog.getBundles(query)),
4592
4632
  enabled: sessionRestored && (options?.enabled ?? true),
@@ -4596,7 +4636,7 @@ function useBundles(options) {
4596
4636
  function useBundle(slug, options) {
4597
4637
  const { client, sessionRestored } = useBehio();
4598
4638
  const query = { locale: options?.locale ?? client.getLocale(), currency: options?.currency ?? client.getCurrency(), country: options?.country ?? client.getCountry() };
4599
- return useQuery37({
4639
+ return useQuery38({
4600
4640
  queryKey: ["behio", "bundle", slug, query],
4601
4641
  queryFn: () => unwrap(client.catalog.getBundle(slug, query)),
4602
4642
  enabled: sessionRestored && Boolean(slug) && (options?.enabled ?? true),
@@ -4605,10 +4645,10 @@ function useBundle(slug, options) {
4605
4645
  }
4606
4646
 
4607
4647
  // src/react/hooks/use-product-group.ts
4608
- import { useQuery as useQuery38 } from "@tanstack/react-query";
4648
+ import { useQuery as useQuery39 } from "@tanstack/react-query";
4609
4649
  function useProductGroup(slug, options) {
4610
4650
  const { client } = useBehio();
4611
- return useQuery38({
4651
+ return useQuery39({
4612
4652
  queryKey: ["behio", "product-group", slug, options?.locale, options?.currency],
4613
4653
  queryFn: () => unwrap(
4614
4654
  client.catalog.getProductGroup(slug, {
@@ -4622,10 +4662,10 @@ function useProductGroup(slug, options) {
4622
4662
  }
4623
4663
 
4624
4664
  // src/react/hooks/use-cross-sell.ts
4625
- import { useQuery as useQuery39 } from "@tanstack/react-query";
4665
+ import { useQuery as useQuery40 } from "@tanstack/react-query";
4626
4666
  function useCrossSell(productSlug, options) {
4627
4667
  const { client } = useBehio();
4628
- return useQuery39({
4668
+ return useQuery40({
4629
4669
  queryKey: ["behio", "cross-sell", productSlug, options?.locale, options?.currency],
4630
4670
  queryFn: () => unwrap(
4631
4671
  client.catalog.getCrossSell(productSlug, {
@@ -4639,10 +4679,10 @@ function useCrossSell(productSlug, options) {
4639
4679
  }
4640
4680
 
4641
4681
  // src/react/hooks/use-product-promotions.ts
4642
- import { useQuery as useQuery40 } from "@tanstack/react-query";
4682
+ import { useQuery as useQuery41 } from "@tanstack/react-query";
4643
4683
  function useProductPromotions(productSlug, options) {
4644
4684
  const { client } = useBehio();
4645
- return useQuery40({
4685
+ return useQuery41({
4646
4686
  queryKey: ["behio", "product-promotions", productSlug],
4647
4687
  queryFn: () => unwrap(client.catalog.getProductPromotions(productSlug)),
4648
4688
  enabled: Boolean(productSlug) && (options?.enabled ?? true),
@@ -4651,11 +4691,11 @@ function useProductPromotions(productSlug, options) {
4651
4691
  }
4652
4692
 
4653
4693
  // src/react/hooks/use-gift-card.ts
4654
- import { useQuery as useQuery41 } from "@tanstack/react-query";
4694
+ import { useQuery as useQuery42 } from "@tanstack/react-query";
4655
4695
  function useGiftCardBalance(code, options) {
4656
4696
  const { client } = useBehio();
4657
4697
  const trimmed = code?.trim();
4658
- return useQuery41({
4698
+ return useQuery42({
4659
4699
  queryKey: ["behio", "gift-card-balance", trimmed],
4660
4700
  queryFn: () => unwrap(client.catalog.checkGiftCard(trimmed)),
4661
4701
  enabled: Boolean(trimmed && trimmed.length >= 6) && (options?.enabled ?? true)
@@ -4663,11 +4703,11 @@ function useGiftCardBalance(code, options) {
4663
4703
  }
4664
4704
 
4665
4705
  // src/react/hooks/use-wishlist.ts
4666
- import { useQuery as useQuery42, useMutation as useMutation17, useQueryClient as useQueryClient17 } from "@tanstack/react-query";
4706
+ import { useQuery as useQuery43, useMutation as useMutation17, useQueryClient as useQueryClient17 } from "@tanstack/react-query";
4667
4707
  function useWishlist(options) {
4668
4708
  const { client } = useBehio();
4669
4709
  const qc = useQueryClient17();
4670
- const query = useQuery42({
4710
+ const query = useQuery43({
4671
4711
  queryKey: ["behio", "wishlist"],
4672
4712
  queryFn: () => unwrap(client.wishlist.get()),
4673
4713
  enabled: options?.enabled ?? true
@@ -4690,7 +4730,7 @@ function useWishlist(options) {
4690
4730
  }
4691
4731
  function useIsInWishlist(productId) {
4692
4732
  const { client } = useBehio();
4693
- return useQuery42({
4733
+ return useQuery43({
4694
4734
  queryKey: ["behio", "wishlist-check", productId],
4695
4735
  queryFn: () => unwrap(client.wishlist.isInWishlist(productId)),
4696
4736
  enabled: Boolean(productId)
@@ -4698,10 +4738,10 @@ function useIsInWishlist(productId) {
4698
4738
  }
4699
4739
 
4700
4740
  // src/react/hooks/use-reviews.ts
4701
- import { useQuery as useQuery43, useMutation as useMutation18, useQueryClient as useQueryClient18 } from "@tanstack/react-query";
4741
+ import { useQuery as useQuery44, useMutation as useMutation18, useQueryClient as useQueryClient18 } from "@tanstack/react-query";
4702
4742
  function useProductReviews(productId, options) {
4703
4743
  const { client } = useBehio();
4704
- return useQuery43({
4744
+ return useQuery44({
4705
4745
  queryKey: ["behio", "reviews", productId, options?.page ?? 1, options?.limit ?? 20],
4706
4746
  queryFn: () => unwrap(client.reviews.getProductReviews(productId, options?.page, options?.limit)),
4707
4747
  initialData: options?.initialData,
@@ -4719,7 +4759,7 @@ function useSubmitReview() {
4719
4759
  }
4720
4760
 
4721
4761
  // src/react/hooks/use-returns.ts
4722
- import { useQuery as useQuery44, useMutation as useMutation19 } from "@tanstack/react-query";
4762
+ import { useQuery as useQuery45, useMutation as useMutation19 } from "@tanstack/react-query";
4723
4763
  function useLookupReturnableOrder() {
4724
4764
  const { client } = useBehio();
4725
4765
  return useMutation19({
@@ -4734,7 +4774,7 @@ function useSubmitReturn() {
4734
4774
  }
4735
4775
  function useReturnStatus(returnId, email) {
4736
4776
  const { client } = useBehio();
4737
- return useQuery44({
4777
+ return useQuery45({
4738
4778
  queryKey: ["behio", "return-status", returnId],
4739
4779
  queryFn: () => unwrap(client.returns.getStatus(returnId, email)),
4740
4780
  enabled: Boolean(returnId && email)
@@ -4742,7 +4782,7 @@ function useReturnStatus(returnId, email) {
4742
4782
  }
4743
4783
 
4744
4784
  // src/react/hooks/use-quotes.ts
4745
- import { useMutation as useMutation20, useQuery as useQuery45 } from "@tanstack/react-query";
4785
+ import { useMutation as useMutation20, useQuery as useQuery46 } from "@tanstack/react-query";
4746
4786
  function useSubmitQuote() {
4747
4787
  const { client } = useBehio();
4748
4788
  return useMutation20({
@@ -4751,7 +4791,7 @@ function useSubmitQuote() {
4751
4791
  }
4752
4792
  function useQuoteStatus(quoteId, email) {
4753
4793
  const { client } = useBehio();
4754
- return useQuery45({
4794
+ return useQuery46({
4755
4795
  queryKey: ["behio", "quote-status", quoteId],
4756
4796
  queryFn: () => unwrap(client.quotes.getStatus(quoteId, email)),
4757
4797
  enabled: Boolean(quoteId && email)
@@ -4929,6 +4969,8 @@ export {
4929
4969
  useCurrency,
4930
4970
  useCustomer,
4931
4971
  useFacets,
4972
+ useFaqGroup,
4973
+ useFaqGroups,
4932
4974
  useFeatured,
4933
4975
  useFilters,
4934
4976
  useGiftCardBalance,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@behio/storefront-sdk",
3
- "version": "2.20.0",
3
+ "version": "2.21.0",
4
4
  "description": "TypeScript SDK for Behio headless e-commerce: core client + React hooks",
5
5
  "author": "Behio",
6
6
  "license": "MIT",