@behio/storefront-sdk 0.1.4 → 0.1.6
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 +71 -6
- package/dist/{chunk-SNODOM7L.js → chunk-GGAO5T5P.js} +17 -1
- package/dist/{chunk-DBZPF3IR.mjs → chunk-S4DOL3OV.mjs} +17 -1
- package/dist/index.d.mts +21 -1
- package/dist/index.d.ts +21 -1
- package/dist/index.js +2 -2
- package/dist/index.mjs +1 -1
- package/dist/react.d.mts +136 -16
- package/dist/react.d.ts +136 -16
- package/dist/react.js +169 -59
- package/dist/react.mjs +215 -105
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -480,7 +480,12 @@ Every API method returns a Promise. Types are fully auto-completed.
|
|
|
480
480
|
|
|
481
481
|
```typescript
|
|
482
482
|
// Catalog
|
|
483
|
-
const products = await shop.catalog.getProducts({
|
|
483
|
+
const products = await shop.catalog.getProducts({
|
|
484
|
+
limit: 20,
|
|
485
|
+
sort: 'newest',
|
|
486
|
+
categories: ['electronics', 'books'], // array filters sent as repeated query params
|
|
487
|
+
hasDiscount: true,
|
|
488
|
+
});
|
|
484
489
|
const product = await shop.catalog.getProduct('my-product-slug');
|
|
485
490
|
const { categories } = await shop.catalog.getCategories();
|
|
486
491
|
|
|
@@ -545,20 +550,80 @@ const { data, isLoading, error } = useShopInfo();
|
|
|
545
550
|
```
|
|
546
551
|
|
|
547
552
|
### useProducts
|
|
553
|
+
|
|
554
|
+
Supports **both** traditional pagination and infinite scroll from one hook.
|
|
555
|
+
|
|
548
556
|
```typescript
|
|
549
|
-
const {
|
|
557
|
+
const {
|
|
558
|
+
items, // flat array (all pages merged) — for infinite scroll
|
|
559
|
+
data, // PaginatedResponse (current page) — for traditional pagination
|
|
560
|
+
total, totalPages, currentPage, limit,
|
|
561
|
+
|
|
562
|
+
// Traditional pagination
|
|
563
|
+
page, setPage,
|
|
564
|
+
|
|
565
|
+
// Infinite scroll
|
|
566
|
+
loadMore, hasMore, isLoadingMore,
|
|
567
|
+
|
|
568
|
+
// State
|
|
569
|
+
isLoading, isFetching, error, isError, refetch,
|
|
570
|
+
} = useProducts({
|
|
550
571
|
page: 1,
|
|
551
572
|
limit: 24,
|
|
552
|
-
|
|
553
|
-
|
|
573
|
+
|
|
574
|
+
// Scalar filters
|
|
575
|
+
category: 'electronics', // single category slug
|
|
576
|
+
label: 'new', // single label slug
|
|
554
577
|
priceMin: 100,
|
|
555
578
|
priceMax: 5000,
|
|
556
|
-
|
|
579
|
+
currency: 'CZK',
|
|
580
|
+
locale: 'cs',
|
|
581
|
+
sort: 'price_asc', // or ProductSort.PRICE_ASC
|
|
557
582
|
inStock: true,
|
|
558
583
|
search: 'keyboard',
|
|
559
584
|
customFields: { material: 'aluminum' },
|
|
585
|
+
|
|
586
|
+
// Array filters — sent as repeated query params (?ids=a&ids=b)
|
|
587
|
+
ids: ['prod_1', 'prod_2'], // filter to specific IDs
|
|
588
|
+
slugs: ['red-shoes', 'blue-hat'], // filter to specific slugs
|
|
589
|
+
categories: ['electronics', 'books'], // OR logic (in ANY of these)
|
|
590
|
+
labels: ['sale', 'new'], // AND logic (must have ALL)
|
|
591
|
+
excludeIds: ['prod_999'], // exclude specific IDs (e.g. related products)
|
|
592
|
+
excludeCategories: ['archive'], // exclude products in these categories
|
|
593
|
+
|
|
594
|
+
// Boolean / time filters
|
|
595
|
+
hasDiscount: true, // only products with compareAtPrice
|
|
596
|
+
isFeatured: true, // only featured products
|
|
597
|
+
createdAfter: Date.now() - 7 * 864e5, // created in last 7 days (epoch ms)
|
|
598
|
+
|
|
599
|
+
// Hook options
|
|
600
|
+
enabled: true, // skip fetch until true
|
|
601
|
+
initialData: prefetchedData, // SSR hydration
|
|
560
602
|
});
|
|
561
|
-
|
|
603
|
+
```
|
|
604
|
+
|
|
605
|
+
**Infinite scroll example:**
|
|
606
|
+
```tsx
|
|
607
|
+
const { items, loadMore, hasMore, isLoadingMore } = useProducts({ limit: 24 });
|
|
608
|
+
|
|
609
|
+
return (
|
|
610
|
+
<>
|
|
611
|
+
{items.map(p => <ProductCard key={p.id} product={p} />)}
|
|
612
|
+
{hasMore && <button onClick={loadMore} disabled={isLoadingMore}>Load more</button>}
|
|
613
|
+
</>
|
|
614
|
+
);
|
|
615
|
+
```
|
|
616
|
+
|
|
617
|
+
**Traditional pagination example:**
|
|
618
|
+
```tsx
|
|
619
|
+
const { data, page, setPage, totalPages } = useProducts({ limit: 24 });
|
|
620
|
+
|
|
621
|
+
return (
|
|
622
|
+
<>
|
|
623
|
+
{data?.items.map(p => <ProductCard key={p.id} product={p} />)}
|
|
624
|
+
<Pagination page={page} total={totalPages} onChange={setPage} />
|
|
625
|
+
</>
|
|
626
|
+
);
|
|
562
627
|
```
|
|
563
628
|
|
|
564
629
|
### useProduct
|
|
@@ -204,7 +204,14 @@ var BehioStorefront = class {
|
|
|
204
204
|
const params = new URLSearchParams();
|
|
205
205
|
if (_optionalChain([options, 'optionalAccess', _12 => _12.query])) {
|
|
206
206
|
for (const [key, value] of Object.entries(options.query)) {
|
|
207
|
-
if (value
|
|
207
|
+
if (value === void 0 || value === null || value === "") continue;
|
|
208
|
+
if (Array.isArray(value)) {
|
|
209
|
+
for (const v of value) {
|
|
210
|
+
if (v !== void 0 && v !== null && v !== "") {
|
|
211
|
+
params.append(key, String(v));
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
} else {
|
|
208
215
|
params.set(key, String(value));
|
|
209
216
|
}
|
|
210
217
|
}
|
|
@@ -331,6 +338,15 @@ var CatalogModule = class {
|
|
|
331
338
|
if (query.inStock !== void 0) q.inStock = query.inStock;
|
|
332
339
|
if (query.search) q.search = query.search;
|
|
333
340
|
if (query.customFields) q.customFields = JSON.stringify(query.customFields);
|
|
341
|
+
if (query.ids && query.ids.length > 0) q.ids = query.ids;
|
|
342
|
+
if (query.slugs && query.slugs.length > 0) q.slugs = query.slugs;
|
|
343
|
+
if (query.labels && query.labels.length > 0) q.labels = query.labels;
|
|
344
|
+
if (query.categories && query.categories.length > 0) q.categories = query.categories;
|
|
345
|
+
if (query.excludeIds && query.excludeIds.length > 0) q.excludeIds = query.excludeIds;
|
|
346
|
+
if (query.excludeCategories && query.excludeCategories.length > 0) q.excludeCategories = query.excludeCategories;
|
|
347
|
+
if (query.hasDiscount !== void 0) q.hasDiscount = query.hasDiscount;
|
|
348
|
+
if (query.isFeatured !== void 0) q.isFeatured = query.isFeatured;
|
|
349
|
+
if (query.createdAfter !== void 0) q.createdAfter = query.createdAfter;
|
|
334
350
|
}
|
|
335
351
|
return this.client.request("GET", "/catalog/products", { query: q });
|
|
336
352
|
}
|
|
@@ -204,7 +204,14 @@ var BehioStorefront = class {
|
|
|
204
204
|
const params = new URLSearchParams();
|
|
205
205
|
if (options?.query) {
|
|
206
206
|
for (const [key, value] of Object.entries(options.query)) {
|
|
207
|
-
if (value
|
|
207
|
+
if (value === void 0 || value === null || value === "") continue;
|
|
208
|
+
if (Array.isArray(value)) {
|
|
209
|
+
for (const v of value) {
|
|
210
|
+
if (v !== void 0 && v !== null && v !== "") {
|
|
211
|
+
params.append(key, String(v));
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
} else {
|
|
208
215
|
params.set(key, String(value));
|
|
209
216
|
}
|
|
210
217
|
}
|
|
@@ -331,6 +338,15 @@ var CatalogModule = class {
|
|
|
331
338
|
if (query.inStock !== void 0) q.inStock = query.inStock;
|
|
332
339
|
if (query.search) q.search = query.search;
|
|
333
340
|
if (query.customFields) q.customFields = JSON.stringify(query.customFields);
|
|
341
|
+
if (query.ids && query.ids.length > 0) q.ids = query.ids;
|
|
342
|
+
if (query.slugs && query.slugs.length > 0) q.slugs = query.slugs;
|
|
343
|
+
if (query.labels && query.labels.length > 0) q.labels = query.labels;
|
|
344
|
+
if (query.categories && query.categories.length > 0) q.categories = query.categories;
|
|
345
|
+
if (query.excludeIds && query.excludeIds.length > 0) q.excludeIds = query.excludeIds;
|
|
346
|
+
if (query.excludeCategories && query.excludeCategories.length > 0) q.excludeCategories = query.excludeCategories;
|
|
347
|
+
if (query.hasDiscount !== void 0) q.hasDiscount = query.hasDiscount;
|
|
348
|
+
if (query.isFeatured !== void 0) q.isFeatured = query.isFeatured;
|
|
349
|
+
if (query.createdAfter !== void 0) q.createdAfter = query.createdAfter;
|
|
334
350
|
}
|
|
335
351
|
return this.client.request("GET", "/catalog/products", { query: q });
|
|
336
352
|
}
|
package/dist/index.d.mts
CHANGED
|
@@ -169,7 +169,11 @@ type AddressType = (typeof AddressTypes)[keyof typeof AddressTypes];
|
|
|
169
169
|
interface ProductsQuery {
|
|
170
170
|
page?: number;
|
|
171
171
|
limit?: number;
|
|
172
|
+
/** Single category slug (OR logic with categories array) */
|
|
172
173
|
category?: string;
|
|
174
|
+
/** Multiple category slugs (OR logic — product in ANY of these categories) */
|
|
175
|
+
categories?: string[];
|
|
176
|
+
/** Single label slug */
|
|
173
177
|
label?: string;
|
|
174
178
|
priceMin?: number;
|
|
175
179
|
priceMax?: number;
|
|
@@ -179,6 +183,22 @@ interface ProductsQuery {
|
|
|
179
183
|
inStock?: boolean;
|
|
180
184
|
search?: string;
|
|
181
185
|
customFields?: Record<string, unknown>;
|
|
186
|
+
/** Filter by specific product IDs (comma-separated in URL) */
|
|
187
|
+
ids?: string[];
|
|
188
|
+
/** Filter by specific product slugs */
|
|
189
|
+
slugs?: string[];
|
|
190
|
+
/** Multiple labels (AND logic — product must have ALL) */
|
|
191
|
+
labels?: string[];
|
|
192
|
+
/** Exclude specific product IDs (e.g. for "related products" excluding current) */
|
|
193
|
+
excludeIds?: string[];
|
|
194
|
+
/** Exclude products in specific categories */
|
|
195
|
+
excludeCategories?: string[];
|
|
196
|
+
/** Only products with compareAtPrice (on sale) */
|
|
197
|
+
hasDiscount?: boolean;
|
|
198
|
+
/** Only featured products */
|
|
199
|
+
isFeatured?: boolean;
|
|
200
|
+
/** Products created after timestamp (epoch ms) */
|
|
201
|
+
createdAfter?: number;
|
|
182
202
|
}
|
|
183
203
|
interface AuthTokens {
|
|
184
204
|
accessToken: string;
|
|
@@ -425,7 +445,7 @@ declare class BehioStorefront {
|
|
|
425
445
|
/** @internal */
|
|
426
446
|
request<T>(method: string, path: string, options?: {
|
|
427
447
|
body?: unknown;
|
|
428
|
-
query?: Record<string, string | number | boolean | undefined>;
|
|
448
|
+
query?: Record<string, string | number | boolean | undefined | string[] | number[]>;
|
|
429
449
|
auth?: boolean;
|
|
430
450
|
signal?: AbortSignal;
|
|
431
451
|
/** @internal Prevents infinite refresh loops */
|
package/dist/index.d.ts
CHANGED
|
@@ -169,7 +169,11 @@ type AddressType = (typeof AddressTypes)[keyof typeof AddressTypes];
|
|
|
169
169
|
interface ProductsQuery {
|
|
170
170
|
page?: number;
|
|
171
171
|
limit?: number;
|
|
172
|
+
/** Single category slug (OR logic with categories array) */
|
|
172
173
|
category?: string;
|
|
174
|
+
/** Multiple category slugs (OR logic — product in ANY of these categories) */
|
|
175
|
+
categories?: string[];
|
|
176
|
+
/** Single label slug */
|
|
173
177
|
label?: string;
|
|
174
178
|
priceMin?: number;
|
|
175
179
|
priceMax?: number;
|
|
@@ -179,6 +183,22 @@ interface ProductsQuery {
|
|
|
179
183
|
inStock?: boolean;
|
|
180
184
|
search?: string;
|
|
181
185
|
customFields?: Record<string, unknown>;
|
|
186
|
+
/** Filter by specific product IDs (comma-separated in URL) */
|
|
187
|
+
ids?: string[];
|
|
188
|
+
/** Filter by specific product slugs */
|
|
189
|
+
slugs?: string[];
|
|
190
|
+
/** Multiple labels (AND logic — product must have ALL) */
|
|
191
|
+
labels?: string[];
|
|
192
|
+
/** Exclude specific product IDs (e.g. for "related products" excluding current) */
|
|
193
|
+
excludeIds?: string[];
|
|
194
|
+
/** Exclude products in specific categories */
|
|
195
|
+
excludeCategories?: string[];
|
|
196
|
+
/** Only products with compareAtPrice (on sale) */
|
|
197
|
+
hasDiscount?: boolean;
|
|
198
|
+
/** Only featured products */
|
|
199
|
+
isFeatured?: boolean;
|
|
200
|
+
/** Products created after timestamp (epoch ms) */
|
|
201
|
+
createdAfter?: number;
|
|
182
202
|
}
|
|
183
203
|
interface AuthTokens {
|
|
184
204
|
accessToken: string;
|
|
@@ -425,7 +445,7 @@ declare class BehioStorefront {
|
|
|
425
445
|
/** @internal */
|
|
426
446
|
request<T>(method: string, path: string, options?: {
|
|
427
447
|
body?: unknown;
|
|
428
|
-
query?: Record<string, string | number | boolean | undefined>;
|
|
448
|
+
query?: Record<string, string | number | boolean | undefined | string[] | number[]>;
|
|
429
449
|
auth?: boolean;
|
|
430
450
|
signal?: AbortSignal;
|
|
431
451
|
/** @internal Prevents infinite refresh loops */
|
package/dist/index.js
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _chunkGGAO5T5Pjs = require('./chunk-GGAO5T5P.js');
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
|
|
@@ -17,4 +17,4 @@ var _chunkSNODOM7Ljs = require('./chunk-SNODOM7L.js');
|
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
|
|
20
|
-
exports.AddressTypes =
|
|
20
|
+
exports.AddressTypes = _chunkGGAO5T5Pjs.AddressTypes; exports.BehioApiError = _chunkGGAO5T5Pjs.BehioApiError; exports.BehioNetworkError = _chunkGGAO5T5Pjs.BehioNetworkError; exports.BehioStorefront = _chunkGGAO5T5Pjs.BehioStorefront; exports.FulfillmentStatuses = _chunkGGAO5T5Pjs.FulfillmentStatuses; exports.OrderStatuses = _chunkGGAO5T5Pjs.OrderStatuses; exports.PaymentStatuses = _chunkGGAO5T5Pjs.PaymentStatuses; exports.ProductSort = _chunkGGAO5T5Pjs.ProductSort;
|
package/dist/index.mjs
CHANGED
package/dist/react.d.mts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import * as _tanstack_react_query from '@tanstack/react-query';
|
|
3
3
|
import { QueryClient } from '@tanstack/react-query';
|
|
4
|
-
import { BehioStorefront, ProductsQuery, PaginatedResponse, ProductListItem, ProductDetail, Category, ProductLabel, FilterField, Cart, CustomerProfile, RegisterInput, CustomerAddress, OrderListItem, OrderDetail, CheckoutInput, PageDetail, Page, ShopInfo } from './index.mjs';
|
|
5
|
-
export { AddToCartInput, AuthTokens, BehioApiError, CartDiscount, CartItem,
|
|
4
|
+
import { BehioStorefront, ProductsQuery, PaginatedResponse, ProductListItem, ProductDetail, Category, CategoryDetail, ProductLabel, FilterField, Cart, CustomerProfile, RegisterInput, CustomerAddress, OrderListItem, OrderDetail, CheckoutInput, PageDetail, Page, ShopInfo } from './index.mjs';
|
|
5
|
+
export { AddToCartInput, AuthTokens, BehioApiError, CartDiscount, CartItem, CheckoutAddress, FulfillmentStatus, LoginInput, MessageResponse, OrderItem, OrderStatus, PaymentStatus, ProductPrice, ProductVariant } from './index.mjs';
|
|
6
|
+
import * as _tanstack_query_core from '@tanstack/query-core';
|
|
6
7
|
|
|
7
8
|
interface StorageAdapter {
|
|
8
9
|
get(key: string): string | null;
|
|
@@ -36,7 +37,51 @@ interface UseProductsOptions extends ProductsQuery {
|
|
|
36
37
|
initialData?: PaginatedResponse<ProductListItem>;
|
|
37
38
|
enabled?: boolean;
|
|
38
39
|
}
|
|
39
|
-
|
|
40
|
+
/**
|
|
41
|
+
* Products hook with built-in pagination helpers.
|
|
42
|
+
*
|
|
43
|
+
* Supports both **paginated** (replace items per page) and **load more** (append items) patterns.
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* ```tsx
|
|
47
|
+
* const { items, loadMore, hasMore, setPage, page, totalPages } = useProducts({ page: 1, limit: 30 });
|
|
48
|
+
*
|
|
49
|
+
* // Infinite scroll pattern
|
|
50
|
+
* <button onClick={loadMore} disabled={!hasMore}>Load more</button>
|
|
51
|
+
*
|
|
52
|
+
* // Traditional pagination
|
|
53
|
+
* <button onClick={() => setPage(2)}>Go to page 2</button>
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
56
|
+
declare function useProducts(query?: UseProductsOptions): {
|
|
57
|
+
/** All items from all loaded pages (flat array) — for infinite scroll */
|
|
58
|
+
items: ProductListItem[];
|
|
59
|
+
/** Raw React Query data with all pages */
|
|
60
|
+
data: _tanstack_query_core.InfiniteData<PaginatedResponse<ProductListItem>, unknown>;
|
|
61
|
+
/** Last loaded page meta */
|
|
62
|
+
total: number;
|
|
63
|
+
totalPages: number;
|
|
64
|
+
currentPage: number;
|
|
65
|
+
limit: number;
|
|
66
|
+
/** Current page (manual pagination) */
|
|
67
|
+
page: number;
|
|
68
|
+
/** Change page (traditional pagination — replaces items) */
|
|
69
|
+
setPage: (newPage: number) => void;
|
|
70
|
+
/** Load next page (append to items — for infinite scroll / load more button) */
|
|
71
|
+
loadMore: () => Promise<void> | Promise<_tanstack_query_core.InfiniteQueryObserverResult<_tanstack_query_core.InfiniteData<PaginatedResponse<ProductListItem>, unknown>, Error>>;
|
|
72
|
+
/** Fetch previous page */
|
|
73
|
+
loadPrevious: (options?: _tanstack_query_core.FetchPreviousPageOptions) => Promise<_tanstack_query_core.InfiniteQueryObserverResult<_tanstack_query_core.InfiniteData<PaginatedResponse<ProductListItem>, unknown>, Error>>;
|
|
74
|
+
/** Can load more? */
|
|
75
|
+
hasMore: boolean;
|
|
76
|
+
hasPrevious: boolean;
|
|
77
|
+
isLoading: false;
|
|
78
|
+
isFetching: boolean;
|
|
79
|
+
isLoadingMore: boolean;
|
|
80
|
+
error: Error | null;
|
|
81
|
+
isError: boolean;
|
|
82
|
+
/** Force refetch all loaded pages */
|
|
83
|
+
refetch: (options?: _tanstack_query_core.RefetchOptions) => Promise<_tanstack_query_core.QueryObserverResult<_tanstack_query_core.InfiniteData<PaginatedResponse<ProductListItem>, unknown>, Error>>;
|
|
84
|
+
};
|
|
40
85
|
|
|
41
86
|
interface UseProductOptions {
|
|
42
87
|
locale?: string;
|
|
@@ -46,9 +91,20 @@ interface UseProductOptions {
|
|
|
46
91
|
}
|
|
47
92
|
declare function useProduct(slug: string, options?: UseProductOptions): _tanstack_react_query.UseQueryResult<ProductDetail, Error>;
|
|
48
93
|
|
|
49
|
-
|
|
94
|
+
interface UseCategoriesOptions {
|
|
95
|
+
enabled?: boolean;
|
|
96
|
+
}
|
|
97
|
+
declare function useCategories(locale?: string, options?: UseCategoriesOptions): _tanstack_react_query.UseQueryResult<Category[], Error>;
|
|
98
|
+
interface UseCategoryOptions {
|
|
99
|
+
locale?: string;
|
|
100
|
+
enabled?: boolean;
|
|
101
|
+
}
|
|
102
|
+
declare function useCategory(slug: string, options?: UseCategoryOptions): _tanstack_react_query.UseQueryResult<CategoryDetail, Error>;
|
|
50
103
|
|
|
51
|
-
|
|
104
|
+
interface UseLabelsOptions {
|
|
105
|
+
enabled?: boolean;
|
|
106
|
+
}
|
|
107
|
+
declare function useLabels(locale?: string, options?: UseLabelsOptions): _tanstack_react_query.UseQueryResult<ProductLabel[], Error>;
|
|
52
108
|
|
|
53
109
|
interface UseFeaturedOptions {
|
|
54
110
|
locale?: string;
|
|
@@ -58,7 +114,10 @@ interface UseFeaturedOptions {
|
|
|
58
114
|
}
|
|
59
115
|
declare function useFeatured(options?: UseFeaturedOptions): _tanstack_react_query.UseQueryResult<PaginatedResponse<ProductListItem>, Error>;
|
|
60
116
|
|
|
61
|
-
|
|
117
|
+
interface UseFiltersOptions {
|
|
118
|
+
enabled?: boolean;
|
|
119
|
+
}
|
|
120
|
+
declare function useFilters(options?: UseFiltersOptions): _tanstack_react_query.UseQueryResult<FilterField[], Error>;
|
|
62
121
|
|
|
63
122
|
interface UseSearchOptions {
|
|
64
123
|
page?: number;
|
|
@@ -68,7 +127,10 @@ interface UseSearchOptions {
|
|
|
68
127
|
}
|
|
69
128
|
declare function useSearch(query: string, options?: UseSearchOptions): _tanstack_react_query.UseQueryResult<PaginatedResponse<ProductListItem>, Error>;
|
|
70
129
|
|
|
71
|
-
|
|
130
|
+
interface UseCartOptions {
|
|
131
|
+
enabled?: boolean;
|
|
132
|
+
}
|
|
133
|
+
declare function useCart(options?: UseCartOptions): {
|
|
72
134
|
cart: Cart | null;
|
|
73
135
|
isLoading: boolean;
|
|
74
136
|
error: Error | null;
|
|
@@ -88,7 +150,10 @@ declare function useCart(): {
|
|
|
88
150
|
isRemoving: boolean;
|
|
89
151
|
};
|
|
90
152
|
|
|
91
|
-
|
|
153
|
+
interface UseCartCountOptions {
|
|
154
|
+
enabled?: boolean;
|
|
155
|
+
}
|
|
156
|
+
declare function useCartCount(options?: UseCartCountOptions): number;
|
|
92
157
|
|
|
93
158
|
declare function useAuth(): {
|
|
94
159
|
isLoggedIn: boolean;
|
|
@@ -106,7 +171,10 @@ declare function useAuth(): {
|
|
|
106
171
|
registerError: Error | null;
|
|
107
172
|
};
|
|
108
173
|
|
|
109
|
-
|
|
174
|
+
interface UseCustomerOptions {
|
|
175
|
+
enabled?: boolean;
|
|
176
|
+
}
|
|
177
|
+
declare function useCustomer(options?: UseCustomerOptions): {
|
|
110
178
|
data: CustomerProfile | null;
|
|
111
179
|
isLoading: boolean;
|
|
112
180
|
error: Error | null;
|
|
@@ -114,7 +182,10 @@ declare function useCustomer(): {
|
|
|
114
182
|
isUpdating: boolean;
|
|
115
183
|
};
|
|
116
184
|
|
|
117
|
-
|
|
185
|
+
interface UseAddressesOptions {
|
|
186
|
+
enabled?: boolean;
|
|
187
|
+
}
|
|
188
|
+
declare function useAddresses(options?: UseAddressesOptions): {
|
|
118
189
|
addresses: CustomerAddress[];
|
|
119
190
|
isLoading: boolean;
|
|
120
191
|
error: Error | null;
|
|
@@ -130,9 +201,41 @@ interface UseOrdersOptions {
|
|
|
130
201
|
limit?: number;
|
|
131
202
|
enabled?: boolean;
|
|
132
203
|
}
|
|
133
|
-
|
|
204
|
+
/**
|
|
205
|
+
* Orders hook with built-in pagination helpers.
|
|
206
|
+
*
|
|
207
|
+
* Supports both paginated (setPage) and load-more patterns.
|
|
208
|
+
*
|
|
209
|
+
* @example
|
|
210
|
+
* ```tsx
|
|
211
|
+
* const { items, loadMore, hasMore, isLoadingMore } = useOrders({ page: 1, limit: 20 });
|
|
212
|
+
* ```
|
|
213
|
+
*/
|
|
214
|
+
declare function useOrders(options?: UseOrdersOptions): {
|
|
215
|
+
items: OrderListItem[];
|
|
216
|
+
data: _tanstack_query_core.InfiniteData<PaginatedResponse<OrderListItem>, unknown> | undefined;
|
|
217
|
+
total: number;
|
|
218
|
+
totalPages: number;
|
|
219
|
+
currentPage: number;
|
|
220
|
+
limit: number;
|
|
221
|
+
page: number;
|
|
222
|
+
setPage: (newPage: number) => void;
|
|
223
|
+
loadMore: () => Promise<void> | Promise<_tanstack_query_core.InfiniteQueryObserverResult<_tanstack_query_core.InfiniteData<PaginatedResponse<OrderListItem>, unknown>, Error>>;
|
|
224
|
+
loadPrevious: (options?: _tanstack_query_core.FetchPreviousPageOptions) => Promise<_tanstack_query_core.InfiniteQueryObserverResult<_tanstack_query_core.InfiniteData<PaginatedResponse<OrderListItem>, unknown>, Error>>;
|
|
225
|
+
hasMore: boolean;
|
|
226
|
+
hasPrevious: boolean;
|
|
227
|
+
isLoading: boolean;
|
|
228
|
+
isFetching: boolean;
|
|
229
|
+
isLoadingMore: boolean;
|
|
230
|
+
error: Error | null;
|
|
231
|
+
isError: boolean;
|
|
232
|
+
refetch: (options?: _tanstack_query_core.RefetchOptions) => Promise<_tanstack_query_core.QueryObserverResult<_tanstack_query_core.InfiniteData<PaginatedResponse<OrderListItem>, unknown>, Error>>;
|
|
233
|
+
};
|
|
134
234
|
|
|
135
|
-
|
|
235
|
+
interface UseOrderOptions {
|
|
236
|
+
enabled?: boolean;
|
|
237
|
+
}
|
|
238
|
+
declare function useOrder(orderNumber: string, options?: UseOrderOptions): {
|
|
136
239
|
data: OrderDetail | null;
|
|
137
240
|
isLoading: boolean;
|
|
138
241
|
error: Error | null;
|
|
@@ -148,10 +251,27 @@ declare function useCheckout(): {
|
|
|
148
251
|
reset: () => void;
|
|
149
252
|
};
|
|
150
253
|
|
|
151
|
-
|
|
152
|
-
|
|
254
|
+
interface UsePagesOptions {
|
|
255
|
+
enabled?: boolean;
|
|
256
|
+
}
|
|
257
|
+
declare function usePages(locale?: string, options?: UsePagesOptions): _tanstack_react_query.UseQueryResult<Page[], Error>;
|
|
258
|
+
interface UsePageOptions {
|
|
259
|
+
enabled?: boolean;
|
|
260
|
+
}
|
|
261
|
+
declare function usePage(slug: string, locale?: string, options?: UsePageOptions): _tanstack_react_query.UseQueryResult<PageDetail, Error>;
|
|
153
262
|
|
|
154
|
-
|
|
263
|
+
interface UseShopInfoOptions {
|
|
264
|
+
enabled?: boolean;
|
|
265
|
+
}
|
|
266
|
+
declare function useShopInfo(options?: UseShopInfoOptions): _tanstack_react_query.UseQueryResult<ShopInfo, Error>;
|
|
267
|
+
|
|
268
|
+
/**
|
|
269
|
+
* Returns the raw BehioStorefront client instance.
|
|
270
|
+
*
|
|
271
|
+
* Useful for one-off fetches outside of React Query, listening to SDK events,
|
|
272
|
+
* or any advanced use case that needs direct access to the client.
|
|
273
|
+
*/
|
|
274
|
+
declare function useBehioClient(): BehioStorefront;
|
|
155
275
|
|
|
156
276
|
/**
|
|
157
277
|
* Format a price amount with currency using Intl.NumberFormat.
|
|
@@ -163,4 +283,4 @@ declare function useShopInfo(): _tanstack_react_query.UseQueryResult<ShopInfo, E
|
|
|
163
283
|
*/
|
|
164
284
|
declare function formatPrice(amount: number, currency: string, locale?: string): string;
|
|
165
285
|
|
|
166
|
-
export { BehioProvider, type BehioProviderProps, Cart, Category, CheckoutInput, CustomerAddress, CustomerProfile, FilterField, OrderDetail, OrderListItem, Page, PageDetail, PaginatedResponse, ProductDetail, ProductLabel, ProductListItem, ProductsQuery, RegisterInput, ShopInfo, type StorageAdapter, type UseFeaturedOptions, type UseOrdersOptions, type UseProductOptions, type UseProductsOptions, type UseSearchOptions, cookieStorage, createMemoryStorage, detectStorage, formatPrice, localStorageAdapter, memoryStorage, useAddresses, useAuth, useBehio, useCart, useCartCount, useCategories, useCheckout, useCustomer, useFeatured, useFilters, useLabels, useOrder, useOrders, usePage, usePages, useProduct, useProducts, useSearch, useShopInfo };
|
|
286
|
+
export { BehioProvider, type BehioProviderProps, Cart, Category, CategoryDetail, CheckoutInput, CustomerAddress, CustomerProfile, FilterField, OrderDetail, OrderListItem, Page, PageDetail, PaginatedResponse, ProductDetail, ProductLabel, ProductListItem, ProductsQuery, RegisterInput, ShopInfo, type StorageAdapter, type UseAddressesOptions, type UseCartCountOptions, type UseCartOptions, type UseCategoriesOptions, type UseCategoryOptions, type UseCustomerOptions, type UseFeaturedOptions, type UseFiltersOptions, type UseLabelsOptions, type UseOrderOptions, type UseOrdersOptions, type UsePageOptions, type UsePagesOptions, type UseProductOptions, type UseProductsOptions, type UseSearchOptions, type UseShopInfoOptions, cookieStorage, createMemoryStorage, detectStorage, formatPrice, localStorageAdapter, memoryStorage, useAddresses, useAuth, useBehio, useBehioClient, useCart, useCartCount, useCategories, useCategory, useCheckout, useCustomer, useFeatured, useFilters, useLabels, useOrder, useOrders, usePage, usePages, useProduct, useProducts, useSearch, useShopInfo };
|