@behio/storefront-sdk 2.16.0 → 2.18.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/README.md +23 -0
- 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-CBNbEn0x.d.mts} +76 -1
- package/dist/{client-Ddk-DIHi.d.ts → client-CBNbEn0x.d.ts} +76 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +15 -6
- package/dist/index.mjs +13 -4
- 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 +84 -1
- package/dist/react.d.ts +84 -1
- package/dist/react.js +96 -44
- package/dist/react.mjs +80 -30
- package/package.json +1 -1
package/dist/react.js
CHANGED
|
@@ -54,6 +54,8 @@ __export(react_exports, {
|
|
|
54
54
|
useCertificateVerification: () => useCertificateVerification,
|
|
55
55
|
useCheckout: () => useCheckout,
|
|
56
56
|
useCheckoutPreview: () => useCheckoutPreview,
|
|
57
|
+
useCollection: () => useCollection,
|
|
58
|
+
useCollectionItem: () => useCollectionItem,
|
|
57
59
|
useCookieConsent: () => useCookieConsent,
|
|
58
60
|
useCourse: () => useCourse,
|
|
59
61
|
useCourseCertificates: () => useCourseCertificates,
|
|
@@ -281,6 +283,7 @@ var BehioStorefront = class {
|
|
|
281
283
|
this.pages = new PagesModule(this);
|
|
282
284
|
this.blog = new BlogModule(this);
|
|
283
285
|
this.forms = new FormsModule(this);
|
|
286
|
+
this.collections = new CollectionsModule(this);
|
|
284
287
|
this.wishlist = new WishlistModule(this);
|
|
285
288
|
this.reviews = new ReviewsModule(this);
|
|
286
289
|
this.returns = new ReturnsModule(this);
|
|
@@ -1909,6 +1912,34 @@ var BlogModule = class {
|
|
|
1909
1912
|
});
|
|
1910
1913
|
}
|
|
1911
1914
|
};
|
|
1915
|
+
var CollectionsModule = class {
|
|
1916
|
+
constructor(client) {
|
|
1917
|
+
this.client = client;
|
|
1918
|
+
}
|
|
1919
|
+
/**
|
|
1920
|
+
* One collection with its published items in the owner's order.
|
|
1921
|
+
* `limit` 1 to 200 (default 100), `offset` for paging; `total` is the
|
|
1922
|
+
* number of published items. 404 `be.collections.collectionNotFound` for an
|
|
1923
|
+
* unknown or private slug.
|
|
1924
|
+
*/
|
|
1925
|
+
async get(slug, query) {
|
|
1926
|
+
return this.client.request(
|
|
1927
|
+
"GET",
|
|
1928
|
+
`/collections/${encodeURIComponent(slug)}`,
|
|
1929
|
+
{ query: { limit: query?.limit, offset: query?.offset } }
|
|
1930
|
+
);
|
|
1931
|
+
}
|
|
1932
|
+
/**
|
|
1933
|
+
* One published item by its slug or id (detail page). 404
|
|
1934
|
+
* `be.collections.itemNotFound` for a draft or unknown item.
|
|
1935
|
+
*/
|
|
1936
|
+
async item(slug, itemSlugOrId) {
|
|
1937
|
+
return this.client.request(
|
|
1938
|
+
"GET",
|
|
1939
|
+
`/collections/${encodeURIComponent(slug)}/items/${encodeURIComponent(itemSlugOrId)}`
|
|
1940
|
+
);
|
|
1941
|
+
}
|
|
1942
|
+
};
|
|
1912
1943
|
var FormsModule = class {
|
|
1913
1944
|
constructor(client) {
|
|
1914
1945
|
this.client = client;
|
|
@@ -4065,9 +4096,28 @@ function useBlogPost(handle, slug, locale, options) {
|
|
|
4065
4096
|
});
|
|
4066
4097
|
}
|
|
4067
4098
|
|
|
4099
|
+
// src/react/hooks/use-collection.ts
|
|
4100
|
+
var import_react_query37 = require("@tanstack/react-query");
|
|
4101
|
+
function useCollection(slug, query, options) {
|
|
4102
|
+
const { client } = useBehio();
|
|
4103
|
+
return (0, import_react_query37.useQuery)({
|
|
4104
|
+
queryKey: ["behio", "collection", slug, query?.limit, query?.offset],
|
|
4105
|
+
queryFn: () => unwrap(client.collections.get(slug, query)),
|
|
4106
|
+
enabled: options?.enabled !== false && !!slug
|
|
4107
|
+
});
|
|
4108
|
+
}
|
|
4109
|
+
function useCollectionItem(slug, itemSlugOrId, options) {
|
|
4110
|
+
const { client } = useBehio();
|
|
4111
|
+
return (0, import_react_query37.useQuery)({
|
|
4112
|
+
queryKey: ["behio", "collection", slug, "item", itemSlugOrId],
|
|
4113
|
+
queryFn: () => unwrap(client.collections.item(slug, itemSlugOrId)),
|
|
4114
|
+
enabled: options?.enabled !== false && !!slug && !!itemSlugOrId
|
|
4115
|
+
});
|
|
4116
|
+
}
|
|
4117
|
+
|
|
4068
4118
|
// src/react/hooks/use-site-form.ts
|
|
4069
4119
|
var import_react17 = require("react");
|
|
4070
|
-
var
|
|
4120
|
+
var import_react_query38 = require("@tanstack/react-query");
|
|
4071
4121
|
|
|
4072
4122
|
// src/errors.ts
|
|
4073
4123
|
function bodyOf(err) {
|
|
@@ -4118,7 +4168,7 @@ function formFieldErrors(err) {
|
|
|
4118
4168
|
// src/react/hooks/use-site-form.ts
|
|
4119
4169
|
function useSiteForm(slug, options) {
|
|
4120
4170
|
const { client } = useBehio();
|
|
4121
|
-
return (0,
|
|
4171
|
+
return (0, import_react_query38.useQuery)({
|
|
4122
4172
|
queryKey: ["behio", "form", slug],
|
|
4123
4173
|
queryFn: () => unwrap(client.forms.get(slug)),
|
|
4124
4174
|
enabled: options?.enabled !== false && !!slug
|
|
@@ -4126,7 +4176,7 @@ function useSiteForm(slug, options) {
|
|
|
4126
4176
|
}
|
|
4127
4177
|
function useSiteFormSubmit(slug) {
|
|
4128
4178
|
const { client } = useBehio();
|
|
4129
|
-
const mutation = (0,
|
|
4179
|
+
const mutation = (0, import_react_query38.useMutation)({
|
|
4130
4180
|
mutationFn: (input) => unwrap(client.forms.submit(slug, input))
|
|
4131
4181
|
});
|
|
4132
4182
|
const sdkError = mutation.error instanceof UnwrappedError ? mutation.error.sdkError : null;
|
|
@@ -4162,10 +4212,10 @@ function useSiteFormSubmit(slug) {
|
|
|
4162
4212
|
}
|
|
4163
4213
|
|
|
4164
4214
|
// src/react/hooks/use-shop-info.ts
|
|
4165
|
-
var
|
|
4215
|
+
var import_react_query39 = require("@tanstack/react-query");
|
|
4166
4216
|
function useShopInfo(options) {
|
|
4167
4217
|
const { client } = useBehio();
|
|
4168
|
-
return (0,
|
|
4218
|
+
return (0, import_react_query39.useQuery)({
|
|
4169
4219
|
queryKey: ["behio", "shop-info"],
|
|
4170
4220
|
queryFn: () => unwrap(client.getShopInfo()),
|
|
4171
4221
|
enabled: options?.enabled !== false
|
|
@@ -4173,10 +4223,10 @@ function useShopInfo(options) {
|
|
|
4173
4223
|
}
|
|
4174
4224
|
|
|
4175
4225
|
// src/react/hooks/use-shop-scripts.ts
|
|
4176
|
-
var
|
|
4226
|
+
var import_react_query40 = require("@tanstack/react-query");
|
|
4177
4227
|
function useShopScripts(options) {
|
|
4178
4228
|
const { client } = useBehio();
|
|
4179
|
-
return (0,
|
|
4229
|
+
return (0, import_react_query40.useQuery)({
|
|
4180
4230
|
queryKey: ["behio", "shop-scripts"],
|
|
4181
4231
|
queryFn: () => unwrap(client.getShopScripts()),
|
|
4182
4232
|
enabled: options?.enabled !== false,
|
|
@@ -4185,11 +4235,11 @@ function useShopScripts(options) {
|
|
|
4185
4235
|
}
|
|
4186
4236
|
|
|
4187
4237
|
// src/react/hooks/use-shop-seo.ts
|
|
4188
|
-
var
|
|
4238
|
+
var import_react_query41 = require("@tanstack/react-query");
|
|
4189
4239
|
function useShopSeo(options) {
|
|
4190
4240
|
const { client } = useBehio();
|
|
4191
4241
|
const { locale, initialData, enabled = true } = options ?? {};
|
|
4192
|
-
return (0,
|
|
4242
|
+
return (0, import_react_query41.useQuery)({
|
|
4193
4243
|
queryKey: ["behio", "shop-seo", locale ?? "_default"],
|
|
4194
4244
|
queryFn: () => unwrap(client.getShopSeo(locale)),
|
|
4195
4245
|
initialData,
|
|
@@ -4252,20 +4302,20 @@ function CurrencySwitcher({
|
|
|
4252
4302
|
var import_react18 = require("react");
|
|
4253
4303
|
|
|
4254
4304
|
// src/react/hooks/use-consent.ts
|
|
4255
|
-
var
|
|
4305
|
+
var import_react_query42 = require("@tanstack/react-query");
|
|
4256
4306
|
function useCookieConsent(visitorId) {
|
|
4257
4307
|
const { client } = useBehio();
|
|
4258
|
-
const qc = (0,
|
|
4259
|
-
const query = (0,
|
|
4308
|
+
const qc = (0, import_react_query42.useQueryClient)();
|
|
4309
|
+
const query = (0, import_react_query42.useQuery)({
|
|
4260
4310
|
queryKey: ["behio", "consent", visitorId],
|
|
4261
4311
|
queryFn: () => unwrap(client.consent.get(visitorId)),
|
|
4262
4312
|
enabled: Boolean(visitorId)
|
|
4263
4313
|
});
|
|
4264
|
-
const recordMutation = (0,
|
|
4314
|
+
const recordMutation = (0, import_react_query42.useMutation)({
|
|
4265
4315
|
mutationFn: (input) => unwrap(client.consent.record(input)),
|
|
4266
4316
|
onSuccess: () => qc.invalidateQueries({ queryKey: ["behio", "consent"] })
|
|
4267
4317
|
});
|
|
4268
|
-
const revokeMutation = (0,
|
|
4318
|
+
const revokeMutation = (0, import_react_query42.useMutation)({
|
|
4269
4319
|
mutationFn: () => unwrap(client.consent.revoke(visitorId)),
|
|
4270
4320
|
onSuccess: () => qc.invalidateQueries({ queryKey: ["behio", "consent"] })
|
|
4271
4321
|
});
|
|
@@ -4634,11 +4684,11 @@ function utmFromSearch(search) {
|
|
|
4634
4684
|
}
|
|
4635
4685
|
|
|
4636
4686
|
// src/react/hooks/use-bundles.ts
|
|
4637
|
-
var
|
|
4687
|
+
var import_react_query43 = require("@tanstack/react-query");
|
|
4638
4688
|
function useBundles(options) {
|
|
4639
4689
|
const { client, sessionRestored } = useBehio();
|
|
4640
4690
|
const query = { locale: options?.locale ?? client.getLocale(), currency: options?.currency ?? client.getCurrency(), country: options?.country ?? client.getCountry() };
|
|
4641
|
-
return (0,
|
|
4691
|
+
return (0, import_react_query43.useQuery)({
|
|
4642
4692
|
queryKey: ["behio", "bundles", query],
|
|
4643
4693
|
queryFn: () => unwrap(client.catalog.getBundles(query)),
|
|
4644
4694
|
enabled: sessionRestored && (options?.enabled ?? true),
|
|
@@ -4648,7 +4698,7 @@ function useBundles(options) {
|
|
|
4648
4698
|
function useBundle(slug, options) {
|
|
4649
4699
|
const { client, sessionRestored } = useBehio();
|
|
4650
4700
|
const query = { locale: options?.locale ?? client.getLocale(), currency: options?.currency ?? client.getCurrency(), country: options?.country ?? client.getCountry() };
|
|
4651
|
-
return (0,
|
|
4701
|
+
return (0, import_react_query43.useQuery)({
|
|
4652
4702
|
queryKey: ["behio", "bundle", slug, query],
|
|
4653
4703
|
queryFn: () => unwrap(client.catalog.getBundle(slug, query)),
|
|
4654
4704
|
enabled: sessionRestored && Boolean(slug) && (options?.enabled ?? true),
|
|
@@ -4657,10 +4707,10 @@ function useBundle(slug, options) {
|
|
|
4657
4707
|
}
|
|
4658
4708
|
|
|
4659
4709
|
// src/react/hooks/use-product-group.ts
|
|
4660
|
-
var
|
|
4710
|
+
var import_react_query44 = require("@tanstack/react-query");
|
|
4661
4711
|
function useProductGroup(slug, options) {
|
|
4662
4712
|
const { client } = useBehio();
|
|
4663
|
-
return (0,
|
|
4713
|
+
return (0, import_react_query44.useQuery)({
|
|
4664
4714
|
queryKey: ["behio", "product-group", slug, options?.locale, options?.currency],
|
|
4665
4715
|
queryFn: () => unwrap(
|
|
4666
4716
|
client.catalog.getProductGroup(slug, {
|
|
@@ -4674,10 +4724,10 @@ function useProductGroup(slug, options) {
|
|
|
4674
4724
|
}
|
|
4675
4725
|
|
|
4676
4726
|
// src/react/hooks/use-cross-sell.ts
|
|
4677
|
-
var
|
|
4727
|
+
var import_react_query45 = require("@tanstack/react-query");
|
|
4678
4728
|
function useCrossSell(productSlug, options) {
|
|
4679
4729
|
const { client } = useBehio();
|
|
4680
|
-
return (0,
|
|
4730
|
+
return (0, import_react_query45.useQuery)({
|
|
4681
4731
|
queryKey: ["behio", "cross-sell", productSlug, options?.locale, options?.currency],
|
|
4682
4732
|
queryFn: () => unwrap(
|
|
4683
4733
|
client.catalog.getCrossSell(productSlug, {
|
|
@@ -4691,10 +4741,10 @@ function useCrossSell(productSlug, options) {
|
|
|
4691
4741
|
}
|
|
4692
4742
|
|
|
4693
4743
|
// src/react/hooks/use-product-promotions.ts
|
|
4694
|
-
var
|
|
4744
|
+
var import_react_query46 = require("@tanstack/react-query");
|
|
4695
4745
|
function useProductPromotions(productSlug, options) {
|
|
4696
4746
|
const { client } = useBehio();
|
|
4697
|
-
return (0,
|
|
4747
|
+
return (0, import_react_query46.useQuery)({
|
|
4698
4748
|
queryKey: ["behio", "product-promotions", productSlug],
|
|
4699
4749
|
queryFn: () => unwrap(client.catalog.getProductPromotions(productSlug)),
|
|
4700
4750
|
enabled: Boolean(productSlug) && (options?.enabled ?? true),
|
|
@@ -4703,11 +4753,11 @@ function useProductPromotions(productSlug, options) {
|
|
|
4703
4753
|
}
|
|
4704
4754
|
|
|
4705
4755
|
// src/react/hooks/use-gift-card.ts
|
|
4706
|
-
var
|
|
4756
|
+
var import_react_query47 = require("@tanstack/react-query");
|
|
4707
4757
|
function useGiftCardBalance(code, options) {
|
|
4708
4758
|
const { client } = useBehio();
|
|
4709
4759
|
const trimmed = code?.trim();
|
|
4710
|
-
return (0,
|
|
4760
|
+
return (0, import_react_query47.useQuery)({
|
|
4711
4761
|
queryKey: ["behio", "gift-card-balance", trimmed],
|
|
4712
4762
|
queryFn: () => unwrap(client.catalog.checkGiftCard(trimmed)),
|
|
4713
4763
|
enabled: Boolean(trimmed && trimmed.length >= 6) && (options?.enabled ?? true)
|
|
@@ -4715,20 +4765,20 @@ function useGiftCardBalance(code, options) {
|
|
|
4715
4765
|
}
|
|
4716
4766
|
|
|
4717
4767
|
// src/react/hooks/use-wishlist.ts
|
|
4718
|
-
var
|
|
4768
|
+
var import_react_query48 = require("@tanstack/react-query");
|
|
4719
4769
|
function useWishlist(options) {
|
|
4720
4770
|
const { client } = useBehio();
|
|
4721
|
-
const qc = (0,
|
|
4722
|
-
const query = (0,
|
|
4771
|
+
const qc = (0, import_react_query48.useQueryClient)();
|
|
4772
|
+
const query = (0, import_react_query48.useQuery)({
|
|
4723
4773
|
queryKey: ["behio", "wishlist"],
|
|
4724
4774
|
queryFn: () => unwrap(client.wishlist.get()),
|
|
4725
4775
|
enabled: options?.enabled ?? true
|
|
4726
4776
|
});
|
|
4727
|
-
const addMutation = (0,
|
|
4777
|
+
const addMutation = (0, import_react_query48.useMutation)({
|
|
4728
4778
|
mutationFn: (productId) => unwrap(client.wishlist.add(productId)),
|
|
4729
4779
|
onSuccess: () => qc.invalidateQueries({ queryKey: ["behio", "wishlist"] })
|
|
4730
4780
|
});
|
|
4731
|
-
const removeMutation = (0,
|
|
4781
|
+
const removeMutation = (0, import_react_query48.useMutation)({
|
|
4732
4782
|
mutationFn: (productId) => unwrap(client.wishlist.remove(productId)),
|
|
4733
4783
|
onSuccess: () => qc.invalidateQueries({ queryKey: ["behio", "wishlist"] })
|
|
4734
4784
|
});
|
|
@@ -4742,7 +4792,7 @@ function useWishlist(options) {
|
|
|
4742
4792
|
}
|
|
4743
4793
|
function useIsInWishlist(productId) {
|
|
4744
4794
|
const { client } = useBehio();
|
|
4745
|
-
return (0,
|
|
4795
|
+
return (0, import_react_query48.useQuery)({
|
|
4746
4796
|
queryKey: ["behio", "wishlist-check", productId],
|
|
4747
4797
|
queryFn: () => unwrap(client.wishlist.isInWishlist(productId)),
|
|
4748
4798
|
enabled: Boolean(productId)
|
|
@@ -4750,10 +4800,10 @@ function useIsInWishlist(productId) {
|
|
|
4750
4800
|
}
|
|
4751
4801
|
|
|
4752
4802
|
// src/react/hooks/use-reviews.ts
|
|
4753
|
-
var
|
|
4803
|
+
var import_react_query49 = require("@tanstack/react-query");
|
|
4754
4804
|
function useProductReviews(productId, options) {
|
|
4755
4805
|
const { client } = useBehio();
|
|
4756
|
-
return (0,
|
|
4806
|
+
return (0, import_react_query49.useQuery)({
|
|
4757
4807
|
queryKey: ["behio", "reviews", productId, options?.page ?? 1, options?.limit ?? 20],
|
|
4758
4808
|
queryFn: () => unwrap(client.reviews.getProductReviews(productId, options?.page, options?.limit)),
|
|
4759
4809
|
initialData: options?.initialData,
|
|
@@ -4763,30 +4813,30 @@ function useProductReviews(productId, options) {
|
|
|
4763
4813
|
}
|
|
4764
4814
|
function useSubmitReview() {
|
|
4765
4815
|
const { client } = useBehio();
|
|
4766
|
-
const qc = (0,
|
|
4767
|
-
return (0,
|
|
4816
|
+
const qc = (0, import_react_query49.useQueryClient)();
|
|
4817
|
+
return (0, import_react_query49.useMutation)({
|
|
4768
4818
|
mutationFn: (input) => unwrap(client.reviews.submit(input)),
|
|
4769
4819
|
onSuccess: (_, input) => qc.invalidateQueries({ queryKey: ["behio", "reviews", input.productId] })
|
|
4770
4820
|
});
|
|
4771
4821
|
}
|
|
4772
4822
|
|
|
4773
4823
|
// src/react/hooks/use-returns.ts
|
|
4774
|
-
var
|
|
4824
|
+
var import_react_query50 = require("@tanstack/react-query");
|
|
4775
4825
|
function useLookupReturnableOrder() {
|
|
4776
4826
|
const { client } = useBehio();
|
|
4777
|
-
return (0,
|
|
4827
|
+
return (0, import_react_query50.useMutation)({
|
|
4778
4828
|
mutationFn: ({ orderNumber, email }) => unwrap(client.returns.lookupOrder(orderNumber, email))
|
|
4779
4829
|
});
|
|
4780
4830
|
}
|
|
4781
4831
|
function useSubmitReturn() {
|
|
4782
4832
|
const { client } = useBehio();
|
|
4783
|
-
return (0,
|
|
4833
|
+
return (0, import_react_query50.useMutation)({
|
|
4784
4834
|
mutationFn: (input) => unwrap(client.returns.submit(input))
|
|
4785
4835
|
});
|
|
4786
4836
|
}
|
|
4787
4837
|
function useReturnStatus(returnId, email) {
|
|
4788
4838
|
const { client } = useBehio();
|
|
4789
|
-
return (0,
|
|
4839
|
+
return (0, import_react_query50.useQuery)({
|
|
4790
4840
|
queryKey: ["behio", "return-status", returnId],
|
|
4791
4841
|
queryFn: () => unwrap(client.returns.getStatus(returnId, email)),
|
|
4792
4842
|
enabled: Boolean(returnId && email)
|
|
@@ -4794,16 +4844,16 @@ function useReturnStatus(returnId, email) {
|
|
|
4794
4844
|
}
|
|
4795
4845
|
|
|
4796
4846
|
// src/react/hooks/use-quotes.ts
|
|
4797
|
-
var
|
|
4847
|
+
var import_react_query51 = require("@tanstack/react-query");
|
|
4798
4848
|
function useSubmitQuote() {
|
|
4799
4849
|
const { client } = useBehio();
|
|
4800
|
-
return (0,
|
|
4850
|
+
return (0, import_react_query51.useMutation)({
|
|
4801
4851
|
mutationFn: (input) => unwrap(client.quotes.submit(input))
|
|
4802
4852
|
});
|
|
4803
4853
|
}
|
|
4804
4854
|
function useQuoteStatus(quoteId, email) {
|
|
4805
4855
|
const { client } = useBehio();
|
|
4806
|
-
return (0,
|
|
4856
|
+
return (0, import_react_query51.useQuery)({
|
|
4807
4857
|
queryKey: ["behio", "quote-status", quoteId],
|
|
4808
4858
|
queryFn: () => unwrap(client.quotes.getStatus(quoteId, email)),
|
|
4809
4859
|
enabled: Boolean(quoteId && email)
|
|
@@ -4811,10 +4861,10 @@ function useQuoteStatus(quoteId, email) {
|
|
|
4811
4861
|
}
|
|
4812
4862
|
|
|
4813
4863
|
// src/react/hooks/use-back-in-stock.ts
|
|
4814
|
-
var
|
|
4864
|
+
var import_react_query52 = require("@tanstack/react-query");
|
|
4815
4865
|
function useNotifyWhenAvailable() {
|
|
4816
4866
|
const { client } = useBehio();
|
|
4817
|
-
return (0,
|
|
4867
|
+
return (0, import_react_query52.useMutation)({
|
|
4818
4868
|
mutationFn: ({ productId, email }) => unwrap(client.catalog.notifyWhenAvailable(productId, email))
|
|
4819
4869
|
});
|
|
4820
4870
|
}
|
|
@@ -4971,6 +5021,8 @@ async function revokeAnalyticsConsent(client) {
|
|
|
4971
5021
|
useCertificateVerification,
|
|
4972
5022
|
useCheckout,
|
|
4973
5023
|
useCheckoutPreview,
|
|
5024
|
+
useCollection,
|
|
5025
|
+
useCollectionItem,
|
|
4974
5026
|
useCookieConsent,
|
|
4975
5027
|
useCourse,
|
|
4976
5028
|
useCourseCertificates,
|
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,
|