@behio/storefront-sdk 0.1.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.
@@ -0,0 +1,166 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import * as _tanstack_react_query from '@tanstack/react-query';
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, CategoryDetail, CheckoutAddress, FulfillmentStatus, LoginInput, MessageResponse, OrderItem, OrderStatus, PaymentStatus, ProductPrice, ProductVariant } from './index.mjs';
6
+
7
+ interface StorageAdapter {
8
+ get(key: string): string | null;
9
+ set(key: string, value: string): void;
10
+ remove(key: string): void;
11
+ }
12
+ declare const cookieStorage: StorageAdapter;
13
+ declare const localStorageAdapter: StorageAdapter;
14
+ declare function createMemoryStorage(): StorageAdapter;
15
+ declare const memoryStorage: StorageAdapter;
16
+ declare function detectStorage(): StorageAdapter;
17
+
18
+ interface BehioProviderProps {
19
+ apiKey: string;
20
+ baseUrl?: string;
21
+ locale?: string;
22
+ currency?: string;
23
+ storage?: "cookies" | "localStorage" | "memory" | StorageAdapter;
24
+ queryClient?: QueryClient;
25
+ children: React.ReactNode;
26
+ }
27
+ declare function BehioProvider({ apiKey, baseUrl, locale, currency, storage: storageOption, queryClient: externalQueryClient, children, }: BehioProviderProps): react_jsx_runtime.JSX.Element;
28
+
29
+ interface BehioContextValue {
30
+ client: BehioStorefront;
31
+ storage: StorageAdapter;
32
+ }
33
+ declare function useBehio(): BehioContextValue;
34
+
35
+ interface UseProductsOptions extends ProductsQuery {
36
+ initialData?: PaginatedResponse<ProductListItem>;
37
+ enabled?: boolean;
38
+ }
39
+ declare function useProducts(query?: UseProductsOptions): _tanstack_react_query.UseQueryResult<PaginatedResponse<ProductListItem>, Error>;
40
+
41
+ interface UseProductOptions {
42
+ locale?: string;
43
+ currency?: string;
44
+ initialData?: ProductDetail;
45
+ enabled?: boolean;
46
+ }
47
+ declare function useProduct(slug: string, options?: UseProductOptions): _tanstack_react_query.UseQueryResult<ProductDetail, Error>;
48
+
49
+ declare function useCategories(locale?: string): _tanstack_react_query.UseQueryResult<Category[], Error>;
50
+
51
+ declare function useLabels(locale?: string): _tanstack_react_query.UseQueryResult<ProductLabel[], Error>;
52
+
53
+ interface UseFeaturedOptions {
54
+ locale?: string;
55
+ currency?: string;
56
+ initialData?: PaginatedResponse<ProductListItem>;
57
+ enabled?: boolean;
58
+ }
59
+ declare function useFeatured(options?: UseFeaturedOptions): _tanstack_react_query.UseQueryResult<PaginatedResponse<ProductListItem>, Error>;
60
+
61
+ declare function useFilters(): _tanstack_react_query.UseQueryResult<FilterField[], Error>;
62
+
63
+ interface UseSearchOptions {
64
+ page?: number;
65
+ limit?: number;
66
+ debounceMs?: number;
67
+ enabled?: boolean;
68
+ }
69
+ declare function useSearch(query: string, options?: UseSearchOptions): _tanstack_react_query.UseQueryResult<PaginatedResponse<ProductListItem>, Error>;
70
+
71
+ declare function useCart(): {
72
+ cart: Cart | null;
73
+ isLoading: boolean;
74
+ error: Error | null;
75
+ addItem: (productId: string, quantity?: number) => Promise<Cart & {
76
+ newSessionToken?: string;
77
+ }>;
78
+ updateQuantity: (itemId: string, quantity: number) => Promise<Cart>;
79
+ removeItem: (itemId: string) => Promise<Cart>;
80
+ clear: () => Promise<void>;
81
+ applyDiscount: (code: string) => Promise<Cart>;
82
+ removeDiscount: () => Promise<Cart>;
83
+ merge: () => Promise<Cart>;
84
+ itemCount: number;
85
+ isEmpty: boolean;
86
+ isAdding: boolean;
87
+ isUpdating: boolean;
88
+ isRemoving: boolean;
89
+ };
90
+
91
+ declare function useCartCount(): number;
92
+
93
+ declare function useAuth(): {
94
+ isLoggedIn: boolean;
95
+ customer: CustomerProfile | null;
96
+ isLoading: boolean;
97
+ login: (email: string, password: string) => Promise<undefined>;
98
+ register: (input: RegisterInput) => Promise<undefined>;
99
+ logout: () => Promise<undefined>;
100
+ forgotPassword: (email: string) => Promise<undefined>;
101
+ resetPassword: (token: string, newPassword: string) => Promise<undefined>;
102
+ verifyEmail: (token: string) => Promise<undefined>;
103
+ isLoggingIn: boolean;
104
+ isRegistering: boolean;
105
+ loginError: Error | null;
106
+ registerError: Error | null;
107
+ };
108
+
109
+ declare function useCustomer(): {
110
+ data: CustomerProfile | null;
111
+ isLoading: boolean;
112
+ error: Error | null;
113
+ updateProfile: (profileData: Partial<Pick<CustomerProfile, "firstName" | "lastName" | "phone">>) => Promise<CustomerProfile>;
114
+ isUpdating: boolean;
115
+ };
116
+
117
+ declare function useAddresses(): {
118
+ addresses: CustomerAddress[];
119
+ isLoading: boolean;
120
+ error: Error | null;
121
+ createAddress: (address: Omit<CustomerAddress, "id">) => Promise<CustomerAddress>;
122
+ updateAddress: (addressId: string, addressData: Partial<CustomerAddress>) => Promise<CustomerAddress>;
123
+ deleteAddress: (addressId: string) => Promise<void>;
124
+ isCreating: boolean;
125
+ isDeleting: boolean;
126
+ };
127
+
128
+ interface UseOrdersOptions {
129
+ page?: number;
130
+ limit?: number;
131
+ enabled?: boolean;
132
+ }
133
+ declare function useOrders(options?: UseOrdersOptions): _tanstack_react_query.UseQueryResult<PaginatedResponse<OrderListItem>, Error>;
134
+
135
+ declare function useOrder(orderNumber: string): {
136
+ data: OrderDetail | null;
137
+ isLoading: boolean;
138
+ error: Error | null;
139
+ cancel: () => Promise<OrderDetail>;
140
+ isCancelling: boolean;
141
+ };
142
+
143
+ declare function useCheckout(): {
144
+ createOrder: (input: CheckoutInput) => Promise<OrderDetail>;
145
+ isCreating: boolean;
146
+ error: Error | null;
147
+ order: OrderDetail | null;
148
+ reset: () => void;
149
+ };
150
+
151
+ declare function usePages(locale?: string): _tanstack_react_query.UseQueryResult<Page[], Error>;
152
+ declare function usePage(slug: string, locale?: string): _tanstack_react_query.UseQueryResult<PageDetail, Error>;
153
+
154
+ declare function useShopInfo(): _tanstack_react_query.UseQueryResult<ShopInfo, Error>;
155
+
156
+ /**
157
+ * Format a price amount with currency using Intl.NumberFormat.
158
+ *
159
+ * @param amount - The price amount (e.g. 1499, 24.99)
160
+ * @param currency - ISO 4217 currency code (e.g. "CZK", "EUR", "USD")
161
+ * @param locale - BCP 47 locale string (e.g. "cs", "en", "de"). Defaults to "cs".
162
+ * @returns Formatted price string (e.g. "1 499 Kč", "24,99 €")
163
+ */
164
+ declare function formatPrice(amount: number, currency: string, locale?: string): string;
165
+
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 };
@@ -0,0 +1,166 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import * as _tanstack_react_query from '@tanstack/react-query';
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.js';
5
+ export { AddToCartInput, AuthTokens, BehioApiError, CartDiscount, CartItem, CategoryDetail, CheckoutAddress, FulfillmentStatus, LoginInput, MessageResponse, OrderItem, OrderStatus, PaymentStatus, ProductPrice, ProductVariant } from './index.js';
6
+
7
+ interface StorageAdapter {
8
+ get(key: string): string | null;
9
+ set(key: string, value: string): void;
10
+ remove(key: string): void;
11
+ }
12
+ declare const cookieStorage: StorageAdapter;
13
+ declare const localStorageAdapter: StorageAdapter;
14
+ declare function createMemoryStorage(): StorageAdapter;
15
+ declare const memoryStorage: StorageAdapter;
16
+ declare function detectStorage(): StorageAdapter;
17
+
18
+ interface BehioProviderProps {
19
+ apiKey: string;
20
+ baseUrl?: string;
21
+ locale?: string;
22
+ currency?: string;
23
+ storage?: "cookies" | "localStorage" | "memory" | StorageAdapter;
24
+ queryClient?: QueryClient;
25
+ children: React.ReactNode;
26
+ }
27
+ declare function BehioProvider({ apiKey, baseUrl, locale, currency, storage: storageOption, queryClient: externalQueryClient, children, }: BehioProviderProps): react_jsx_runtime.JSX.Element;
28
+
29
+ interface BehioContextValue {
30
+ client: BehioStorefront;
31
+ storage: StorageAdapter;
32
+ }
33
+ declare function useBehio(): BehioContextValue;
34
+
35
+ interface UseProductsOptions extends ProductsQuery {
36
+ initialData?: PaginatedResponse<ProductListItem>;
37
+ enabled?: boolean;
38
+ }
39
+ declare function useProducts(query?: UseProductsOptions): _tanstack_react_query.UseQueryResult<PaginatedResponse<ProductListItem>, Error>;
40
+
41
+ interface UseProductOptions {
42
+ locale?: string;
43
+ currency?: string;
44
+ initialData?: ProductDetail;
45
+ enabled?: boolean;
46
+ }
47
+ declare function useProduct(slug: string, options?: UseProductOptions): _tanstack_react_query.UseQueryResult<ProductDetail, Error>;
48
+
49
+ declare function useCategories(locale?: string): _tanstack_react_query.UseQueryResult<Category[], Error>;
50
+
51
+ declare function useLabels(locale?: string): _tanstack_react_query.UseQueryResult<ProductLabel[], Error>;
52
+
53
+ interface UseFeaturedOptions {
54
+ locale?: string;
55
+ currency?: string;
56
+ initialData?: PaginatedResponse<ProductListItem>;
57
+ enabled?: boolean;
58
+ }
59
+ declare function useFeatured(options?: UseFeaturedOptions): _tanstack_react_query.UseQueryResult<PaginatedResponse<ProductListItem>, Error>;
60
+
61
+ declare function useFilters(): _tanstack_react_query.UseQueryResult<FilterField[], Error>;
62
+
63
+ interface UseSearchOptions {
64
+ page?: number;
65
+ limit?: number;
66
+ debounceMs?: number;
67
+ enabled?: boolean;
68
+ }
69
+ declare function useSearch(query: string, options?: UseSearchOptions): _tanstack_react_query.UseQueryResult<PaginatedResponse<ProductListItem>, Error>;
70
+
71
+ declare function useCart(): {
72
+ cart: Cart | null;
73
+ isLoading: boolean;
74
+ error: Error | null;
75
+ addItem: (productId: string, quantity?: number) => Promise<Cart & {
76
+ newSessionToken?: string;
77
+ }>;
78
+ updateQuantity: (itemId: string, quantity: number) => Promise<Cart>;
79
+ removeItem: (itemId: string) => Promise<Cart>;
80
+ clear: () => Promise<void>;
81
+ applyDiscount: (code: string) => Promise<Cart>;
82
+ removeDiscount: () => Promise<Cart>;
83
+ merge: () => Promise<Cart>;
84
+ itemCount: number;
85
+ isEmpty: boolean;
86
+ isAdding: boolean;
87
+ isUpdating: boolean;
88
+ isRemoving: boolean;
89
+ };
90
+
91
+ declare function useCartCount(): number;
92
+
93
+ declare function useAuth(): {
94
+ isLoggedIn: boolean;
95
+ customer: CustomerProfile | null;
96
+ isLoading: boolean;
97
+ login: (email: string, password: string) => Promise<undefined>;
98
+ register: (input: RegisterInput) => Promise<undefined>;
99
+ logout: () => Promise<undefined>;
100
+ forgotPassword: (email: string) => Promise<undefined>;
101
+ resetPassword: (token: string, newPassword: string) => Promise<undefined>;
102
+ verifyEmail: (token: string) => Promise<undefined>;
103
+ isLoggingIn: boolean;
104
+ isRegistering: boolean;
105
+ loginError: Error | null;
106
+ registerError: Error | null;
107
+ };
108
+
109
+ declare function useCustomer(): {
110
+ data: CustomerProfile | null;
111
+ isLoading: boolean;
112
+ error: Error | null;
113
+ updateProfile: (profileData: Partial<Pick<CustomerProfile, "firstName" | "lastName" | "phone">>) => Promise<CustomerProfile>;
114
+ isUpdating: boolean;
115
+ };
116
+
117
+ declare function useAddresses(): {
118
+ addresses: CustomerAddress[];
119
+ isLoading: boolean;
120
+ error: Error | null;
121
+ createAddress: (address: Omit<CustomerAddress, "id">) => Promise<CustomerAddress>;
122
+ updateAddress: (addressId: string, addressData: Partial<CustomerAddress>) => Promise<CustomerAddress>;
123
+ deleteAddress: (addressId: string) => Promise<void>;
124
+ isCreating: boolean;
125
+ isDeleting: boolean;
126
+ };
127
+
128
+ interface UseOrdersOptions {
129
+ page?: number;
130
+ limit?: number;
131
+ enabled?: boolean;
132
+ }
133
+ declare function useOrders(options?: UseOrdersOptions): _tanstack_react_query.UseQueryResult<PaginatedResponse<OrderListItem>, Error>;
134
+
135
+ declare function useOrder(orderNumber: string): {
136
+ data: OrderDetail | null;
137
+ isLoading: boolean;
138
+ error: Error | null;
139
+ cancel: () => Promise<OrderDetail>;
140
+ isCancelling: boolean;
141
+ };
142
+
143
+ declare function useCheckout(): {
144
+ createOrder: (input: CheckoutInput) => Promise<OrderDetail>;
145
+ isCreating: boolean;
146
+ error: Error | null;
147
+ order: OrderDetail | null;
148
+ reset: () => void;
149
+ };
150
+
151
+ declare function usePages(locale?: string): _tanstack_react_query.UseQueryResult<Page[], Error>;
152
+ declare function usePage(slug: string, locale?: string): _tanstack_react_query.UseQueryResult<PageDetail, Error>;
153
+
154
+ declare function useShopInfo(): _tanstack_react_query.UseQueryResult<ShopInfo, Error>;
155
+
156
+ /**
157
+ * Format a price amount with currency using Intl.NumberFormat.
158
+ *
159
+ * @param amount - The price amount (e.g. 1499, 24.99)
160
+ * @param currency - ISO 4217 currency code (e.g. "CZK", "EUR", "USD")
161
+ * @param locale - BCP 47 locale string (e.g. "cs", "en", "de"). Defaults to "cs".
162
+ * @returns Formatted price string (e.g. "1 499 Kč", "24,99 €")
163
+ */
164
+ declare function formatPrice(amount: number, currency: string, locale?: string): string;
165
+
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 };