@behio/storefront-sdk 2.16.0 → 2.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-AUH7KNL6.mjs → chunk-N6YG4AJ4.mjs} +29 -0
- package/dist/{chunk-AOUXSMSR.js → chunk-NBYEO5KC.js} +34 -5
- package/dist/{client-Ddk-DIHi.d.mts → client-CKg4F98v.d.mts} +62 -1
- package/dist/{client-Ddk-DIHi.d.ts → client-CKg4F98v.d.ts} +62 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +9 -3
- package/dist/index.mjs +7 -1
- package/dist/next.d.mts +1 -1
- package/dist/next.d.ts +1 -1
- package/dist/next.js +2 -2
- package/dist/next.mjs +1 -1
- package/dist/react.d.mts +70 -1
- package/dist/react.d.ts +70 -1
- package/dist/react.js +96 -44
- package/dist/react.mjs +80 -30
- package/package.json +1 -1
package/dist/react.mjs
CHANGED
|
@@ -171,6 +171,7 @@ var BehioStorefront = class {
|
|
|
171
171
|
this.pages = new PagesModule(this);
|
|
172
172
|
this.blog = new BlogModule(this);
|
|
173
173
|
this.forms = new FormsModule(this);
|
|
174
|
+
this.collections = new CollectionsModule(this);
|
|
174
175
|
this.wishlist = new WishlistModule(this);
|
|
175
176
|
this.reviews = new ReviewsModule(this);
|
|
176
177
|
this.returns = new ReturnsModule(this);
|
|
@@ -1799,6 +1800,34 @@ var BlogModule = class {
|
|
|
1799
1800
|
});
|
|
1800
1801
|
}
|
|
1801
1802
|
};
|
|
1803
|
+
var CollectionsModule = class {
|
|
1804
|
+
constructor(client) {
|
|
1805
|
+
this.client = client;
|
|
1806
|
+
}
|
|
1807
|
+
/**
|
|
1808
|
+
* One collection with its published items in the owner's order.
|
|
1809
|
+
* `limit` 1 to 200 (default 100), `offset` for paging; `total` is the
|
|
1810
|
+
* number of published items. 404 `be.collections.collectionNotFound` for an
|
|
1811
|
+
* unknown or private slug.
|
|
1812
|
+
*/
|
|
1813
|
+
async get(slug, query) {
|
|
1814
|
+
return this.client.request(
|
|
1815
|
+
"GET",
|
|
1816
|
+
`/collections/${encodeURIComponent(slug)}`,
|
|
1817
|
+
{ query: { limit: query?.limit, offset: query?.offset } }
|
|
1818
|
+
);
|
|
1819
|
+
}
|
|
1820
|
+
/**
|
|
1821
|
+
* One published item by its slug or id (detail page). 404
|
|
1822
|
+
* `be.collections.itemNotFound` for a draft or unknown item.
|
|
1823
|
+
*/
|
|
1824
|
+
async item(slug, itemSlugOrId) {
|
|
1825
|
+
return this.client.request(
|
|
1826
|
+
"GET",
|
|
1827
|
+
`/collections/${encodeURIComponent(slug)}/items/${encodeURIComponent(itemSlugOrId)}`
|
|
1828
|
+
);
|
|
1829
|
+
}
|
|
1830
|
+
};
|
|
1802
1831
|
var FormsModule = class {
|
|
1803
1832
|
constructor(client) {
|
|
1804
1833
|
this.client = client;
|
|
@@ -3955,9 +3984,28 @@ function useBlogPost(handle, slug, locale, options) {
|
|
|
3955
3984
|
});
|
|
3956
3985
|
}
|
|
3957
3986
|
|
|
3987
|
+
// src/react/hooks/use-collection.ts
|
|
3988
|
+
import { useQuery as useQuery31 } from "@tanstack/react-query";
|
|
3989
|
+
function useCollection(slug, query, options) {
|
|
3990
|
+
const { client } = useBehio();
|
|
3991
|
+
return useQuery31({
|
|
3992
|
+
queryKey: ["behio", "collection", slug, query?.limit, query?.offset],
|
|
3993
|
+
queryFn: () => unwrap(client.collections.get(slug, query)),
|
|
3994
|
+
enabled: options?.enabled !== false && !!slug
|
|
3995
|
+
});
|
|
3996
|
+
}
|
|
3997
|
+
function useCollectionItem(slug, itemSlugOrId, options) {
|
|
3998
|
+
const { client } = useBehio();
|
|
3999
|
+
return useQuery31({
|
|
4000
|
+
queryKey: ["behio", "collection", slug, "item", itemSlugOrId],
|
|
4001
|
+
queryFn: () => unwrap(client.collections.item(slug, itemSlugOrId)),
|
|
4002
|
+
enabled: options?.enabled !== false && !!slug && !!itemSlugOrId
|
|
4003
|
+
});
|
|
4004
|
+
}
|
|
4005
|
+
|
|
3958
4006
|
// src/react/hooks/use-site-form.ts
|
|
3959
4007
|
import { useCallback as useCallback15, useMemo as useMemo4 } from "react";
|
|
3960
|
-
import { useMutation as useMutation15, useQuery as
|
|
4008
|
+
import { useMutation as useMutation15, useQuery as useQuery32 } from "@tanstack/react-query";
|
|
3961
4009
|
|
|
3962
4010
|
// src/errors.ts
|
|
3963
4011
|
function bodyOf(err) {
|
|
@@ -4008,7 +4056,7 @@ function formFieldErrors(err) {
|
|
|
4008
4056
|
// src/react/hooks/use-site-form.ts
|
|
4009
4057
|
function useSiteForm(slug, options) {
|
|
4010
4058
|
const { client } = useBehio();
|
|
4011
|
-
return
|
|
4059
|
+
return useQuery32({
|
|
4012
4060
|
queryKey: ["behio", "form", slug],
|
|
4013
4061
|
queryFn: () => unwrap(client.forms.get(slug)),
|
|
4014
4062
|
enabled: options?.enabled !== false && !!slug
|
|
@@ -4052,10 +4100,10 @@ function useSiteFormSubmit(slug) {
|
|
|
4052
4100
|
}
|
|
4053
4101
|
|
|
4054
4102
|
// src/react/hooks/use-shop-info.ts
|
|
4055
|
-
import { useQuery as
|
|
4103
|
+
import { useQuery as useQuery33 } from "@tanstack/react-query";
|
|
4056
4104
|
function useShopInfo(options) {
|
|
4057
4105
|
const { client } = useBehio();
|
|
4058
|
-
return
|
|
4106
|
+
return useQuery33({
|
|
4059
4107
|
queryKey: ["behio", "shop-info"],
|
|
4060
4108
|
queryFn: () => unwrap(client.getShopInfo()),
|
|
4061
4109
|
enabled: options?.enabled !== false
|
|
@@ -4063,10 +4111,10 @@ function useShopInfo(options) {
|
|
|
4063
4111
|
}
|
|
4064
4112
|
|
|
4065
4113
|
// src/react/hooks/use-shop-scripts.ts
|
|
4066
|
-
import { useQuery as
|
|
4114
|
+
import { useQuery as useQuery34 } from "@tanstack/react-query";
|
|
4067
4115
|
function useShopScripts(options) {
|
|
4068
4116
|
const { client } = useBehio();
|
|
4069
|
-
return
|
|
4117
|
+
return useQuery34({
|
|
4070
4118
|
queryKey: ["behio", "shop-scripts"],
|
|
4071
4119
|
queryFn: () => unwrap(client.getShopScripts()),
|
|
4072
4120
|
enabled: options?.enabled !== false,
|
|
@@ -4075,11 +4123,11 @@ function useShopScripts(options) {
|
|
|
4075
4123
|
}
|
|
4076
4124
|
|
|
4077
4125
|
// src/react/hooks/use-shop-seo.ts
|
|
4078
|
-
import { useQuery as
|
|
4126
|
+
import { useQuery as useQuery35 } from "@tanstack/react-query";
|
|
4079
4127
|
function useShopSeo(options) {
|
|
4080
4128
|
const { client } = useBehio();
|
|
4081
4129
|
const { locale, initialData, enabled = true } = options ?? {};
|
|
4082
|
-
return
|
|
4130
|
+
return useQuery35({
|
|
4083
4131
|
queryKey: ["behio", "shop-seo", locale ?? "_default"],
|
|
4084
4132
|
queryFn: () => unwrap(client.getShopSeo(locale)),
|
|
4085
4133
|
initialData,
|
|
@@ -4142,11 +4190,11 @@ function CurrencySwitcher({
|
|
|
4142
4190
|
import { useEffect as useEffect7, useMemo as useMemo5, useRef as useRef4, useState as useState10 } from "react";
|
|
4143
4191
|
|
|
4144
4192
|
// src/react/hooks/use-consent.ts
|
|
4145
|
-
import { useQuery as
|
|
4193
|
+
import { useQuery as useQuery36, useMutation as useMutation16, useQueryClient as useQueryClient16 } from "@tanstack/react-query";
|
|
4146
4194
|
function useCookieConsent(visitorId) {
|
|
4147
4195
|
const { client } = useBehio();
|
|
4148
4196
|
const qc = useQueryClient16();
|
|
4149
|
-
const query =
|
|
4197
|
+
const query = useQuery36({
|
|
4150
4198
|
queryKey: ["behio", "consent", visitorId],
|
|
4151
4199
|
queryFn: () => unwrap(client.consent.get(visitorId)),
|
|
4152
4200
|
enabled: Boolean(visitorId)
|
|
@@ -4524,11 +4572,11 @@ function utmFromSearch(search) {
|
|
|
4524
4572
|
}
|
|
4525
4573
|
|
|
4526
4574
|
// src/react/hooks/use-bundles.ts
|
|
4527
|
-
import { useQuery as
|
|
4575
|
+
import { useQuery as useQuery37 } from "@tanstack/react-query";
|
|
4528
4576
|
function useBundles(options) {
|
|
4529
4577
|
const { client, sessionRestored } = useBehio();
|
|
4530
4578
|
const query = { locale: options?.locale ?? client.getLocale(), currency: options?.currency ?? client.getCurrency(), country: options?.country ?? client.getCountry() };
|
|
4531
|
-
return
|
|
4579
|
+
return useQuery37({
|
|
4532
4580
|
queryKey: ["behio", "bundles", query],
|
|
4533
4581
|
queryFn: () => unwrap(client.catalog.getBundles(query)),
|
|
4534
4582
|
enabled: sessionRestored && (options?.enabled ?? true),
|
|
@@ -4538,7 +4586,7 @@ function useBundles(options) {
|
|
|
4538
4586
|
function useBundle(slug, options) {
|
|
4539
4587
|
const { client, sessionRestored } = useBehio();
|
|
4540
4588
|
const query = { locale: options?.locale ?? client.getLocale(), currency: options?.currency ?? client.getCurrency(), country: options?.country ?? client.getCountry() };
|
|
4541
|
-
return
|
|
4589
|
+
return useQuery37({
|
|
4542
4590
|
queryKey: ["behio", "bundle", slug, query],
|
|
4543
4591
|
queryFn: () => unwrap(client.catalog.getBundle(slug, query)),
|
|
4544
4592
|
enabled: sessionRestored && Boolean(slug) && (options?.enabled ?? true),
|
|
@@ -4547,10 +4595,10 @@ function useBundle(slug, options) {
|
|
|
4547
4595
|
}
|
|
4548
4596
|
|
|
4549
4597
|
// src/react/hooks/use-product-group.ts
|
|
4550
|
-
import { useQuery as
|
|
4598
|
+
import { useQuery as useQuery38 } from "@tanstack/react-query";
|
|
4551
4599
|
function useProductGroup(slug, options) {
|
|
4552
4600
|
const { client } = useBehio();
|
|
4553
|
-
return
|
|
4601
|
+
return useQuery38({
|
|
4554
4602
|
queryKey: ["behio", "product-group", slug, options?.locale, options?.currency],
|
|
4555
4603
|
queryFn: () => unwrap(
|
|
4556
4604
|
client.catalog.getProductGroup(slug, {
|
|
@@ -4564,10 +4612,10 @@ function useProductGroup(slug, options) {
|
|
|
4564
4612
|
}
|
|
4565
4613
|
|
|
4566
4614
|
// src/react/hooks/use-cross-sell.ts
|
|
4567
|
-
import { useQuery as
|
|
4615
|
+
import { useQuery as useQuery39 } from "@tanstack/react-query";
|
|
4568
4616
|
function useCrossSell(productSlug, options) {
|
|
4569
4617
|
const { client } = useBehio();
|
|
4570
|
-
return
|
|
4618
|
+
return useQuery39({
|
|
4571
4619
|
queryKey: ["behio", "cross-sell", productSlug, options?.locale, options?.currency],
|
|
4572
4620
|
queryFn: () => unwrap(
|
|
4573
4621
|
client.catalog.getCrossSell(productSlug, {
|
|
@@ -4581,10 +4629,10 @@ function useCrossSell(productSlug, options) {
|
|
|
4581
4629
|
}
|
|
4582
4630
|
|
|
4583
4631
|
// src/react/hooks/use-product-promotions.ts
|
|
4584
|
-
import { useQuery as
|
|
4632
|
+
import { useQuery as useQuery40 } from "@tanstack/react-query";
|
|
4585
4633
|
function useProductPromotions(productSlug, options) {
|
|
4586
4634
|
const { client } = useBehio();
|
|
4587
|
-
return
|
|
4635
|
+
return useQuery40({
|
|
4588
4636
|
queryKey: ["behio", "product-promotions", productSlug],
|
|
4589
4637
|
queryFn: () => unwrap(client.catalog.getProductPromotions(productSlug)),
|
|
4590
4638
|
enabled: Boolean(productSlug) && (options?.enabled ?? true),
|
|
@@ -4593,11 +4641,11 @@ function useProductPromotions(productSlug, options) {
|
|
|
4593
4641
|
}
|
|
4594
4642
|
|
|
4595
4643
|
// src/react/hooks/use-gift-card.ts
|
|
4596
|
-
import { useQuery as
|
|
4644
|
+
import { useQuery as useQuery41 } from "@tanstack/react-query";
|
|
4597
4645
|
function useGiftCardBalance(code, options) {
|
|
4598
4646
|
const { client } = useBehio();
|
|
4599
4647
|
const trimmed = code?.trim();
|
|
4600
|
-
return
|
|
4648
|
+
return useQuery41({
|
|
4601
4649
|
queryKey: ["behio", "gift-card-balance", trimmed],
|
|
4602
4650
|
queryFn: () => unwrap(client.catalog.checkGiftCard(trimmed)),
|
|
4603
4651
|
enabled: Boolean(trimmed && trimmed.length >= 6) && (options?.enabled ?? true)
|
|
@@ -4605,11 +4653,11 @@ function useGiftCardBalance(code, options) {
|
|
|
4605
4653
|
}
|
|
4606
4654
|
|
|
4607
4655
|
// src/react/hooks/use-wishlist.ts
|
|
4608
|
-
import { useQuery as
|
|
4656
|
+
import { useQuery as useQuery42, useMutation as useMutation17, useQueryClient as useQueryClient17 } from "@tanstack/react-query";
|
|
4609
4657
|
function useWishlist(options) {
|
|
4610
4658
|
const { client } = useBehio();
|
|
4611
4659
|
const qc = useQueryClient17();
|
|
4612
|
-
const query =
|
|
4660
|
+
const query = useQuery42({
|
|
4613
4661
|
queryKey: ["behio", "wishlist"],
|
|
4614
4662
|
queryFn: () => unwrap(client.wishlist.get()),
|
|
4615
4663
|
enabled: options?.enabled ?? true
|
|
@@ -4632,7 +4680,7 @@ function useWishlist(options) {
|
|
|
4632
4680
|
}
|
|
4633
4681
|
function useIsInWishlist(productId) {
|
|
4634
4682
|
const { client } = useBehio();
|
|
4635
|
-
return
|
|
4683
|
+
return useQuery42({
|
|
4636
4684
|
queryKey: ["behio", "wishlist-check", productId],
|
|
4637
4685
|
queryFn: () => unwrap(client.wishlist.isInWishlist(productId)),
|
|
4638
4686
|
enabled: Boolean(productId)
|
|
@@ -4640,10 +4688,10 @@ function useIsInWishlist(productId) {
|
|
|
4640
4688
|
}
|
|
4641
4689
|
|
|
4642
4690
|
// src/react/hooks/use-reviews.ts
|
|
4643
|
-
import { useQuery as
|
|
4691
|
+
import { useQuery as useQuery43, useMutation as useMutation18, useQueryClient as useQueryClient18 } from "@tanstack/react-query";
|
|
4644
4692
|
function useProductReviews(productId, options) {
|
|
4645
4693
|
const { client } = useBehio();
|
|
4646
|
-
return
|
|
4694
|
+
return useQuery43({
|
|
4647
4695
|
queryKey: ["behio", "reviews", productId, options?.page ?? 1, options?.limit ?? 20],
|
|
4648
4696
|
queryFn: () => unwrap(client.reviews.getProductReviews(productId, options?.page, options?.limit)),
|
|
4649
4697
|
initialData: options?.initialData,
|
|
@@ -4661,7 +4709,7 @@ function useSubmitReview() {
|
|
|
4661
4709
|
}
|
|
4662
4710
|
|
|
4663
4711
|
// src/react/hooks/use-returns.ts
|
|
4664
|
-
import { useQuery as
|
|
4712
|
+
import { useQuery as useQuery44, useMutation as useMutation19 } from "@tanstack/react-query";
|
|
4665
4713
|
function useLookupReturnableOrder() {
|
|
4666
4714
|
const { client } = useBehio();
|
|
4667
4715
|
return useMutation19({
|
|
@@ -4676,7 +4724,7 @@ function useSubmitReturn() {
|
|
|
4676
4724
|
}
|
|
4677
4725
|
function useReturnStatus(returnId, email) {
|
|
4678
4726
|
const { client } = useBehio();
|
|
4679
|
-
return
|
|
4727
|
+
return useQuery44({
|
|
4680
4728
|
queryKey: ["behio", "return-status", returnId],
|
|
4681
4729
|
queryFn: () => unwrap(client.returns.getStatus(returnId, email)),
|
|
4682
4730
|
enabled: Boolean(returnId && email)
|
|
@@ -4684,7 +4732,7 @@ function useReturnStatus(returnId, email) {
|
|
|
4684
4732
|
}
|
|
4685
4733
|
|
|
4686
4734
|
// src/react/hooks/use-quotes.ts
|
|
4687
|
-
import { useMutation as useMutation20, useQuery as
|
|
4735
|
+
import { useMutation as useMutation20, useQuery as useQuery45 } from "@tanstack/react-query";
|
|
4688
4736
|
function useSubmitQuote() {
|
|
4689
4737
|
const { client } = useBehio();
|
|
4690
4738
|
return useMutation20({
|
|
@@ -4693,7 +4741,7 @@ function useSubmitQuote() {
|
|
|
4693
4741
|
}
|
|
4694
4742
|
function useQuoteStatus(quoteId, email) {
|
|
4695
4743
|
const { client } = useBehio();
|
|
4696
|
-
return
|
|
4744
|
+
return useQuery45({
|
|
4697
4745
|
queryKey: ["behio", "quote-status", quoteId],
|
|
4698
4746
|
queryFn: () => unwrap(client.quotes.getStatus(quoteId, email)),
|
|
4699
4747
|
enabled: Boolean(quoteId && email)
|
|
@@ -4860,6 +4908,8 @@ export {
|
|
|
4860
4908
|
useCertificateVerification,
|
|
4861
4909
|
useCheckout,
|
|
4862
4910
|
useCheckoutPreview,
|
|
4911
|
+
useCollection,
|
|
4912
|
+
useCollectionItem,
|
|
4863
4913
|
useCookieConsent,
|
|
4864
4914
|
useCourse,
|
|
4865
4915
|
useCourseCertificates,
|