@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.
- package/README.md +999 -0
- package/dist/chunk-26WZOAWP.js +609 -0
- package/dist/chunk-3OJEEMLI.mjs +609 -0
- package/dist/index.d.mts +566 -0
- package/dist/index.d.ts +566 -0
- package/dist/index.js +20 -0
- package/dist/index.mjs +20 -0
- package/dist/react.d.mts +166 -0
- package/dist/react.d.ts +166 -0
- package/dist/react.js +813 -0
- package/dist/react.mjs +813 -0
- package/package.json +61 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,566 @@
|
|
|
1
|
+
interface BehioStorefrontConfig {
|
|
2
|
+
/** API key (public: pk_live_xxx or private: sk_live_xxx) */
|
|
3
|
+
apiKey: string;
|
|
4
|
+
/** Backend base URL. Default: https://api.behio.com */
|
|
5
|
+
baseUrl?: string;
|
|
6
|
+
/** Default locale for catalog requests. Default: none (uses shop default) */
|
|
7
|
+
locale?: string;
|
|
8
|
+
/** Default currency for price resolution. Default: none (uses shop default) */
|
|
9
|
+
currency?: string;
|
|
10
|
+
/** Custom fetch implementation (for Node.js < 18 or testing) */
|
|
11
|
+
fetch?: typeof fetch;
|
|
12
|
+
/** Request timeout in milliseconds. Default: 30000 (30s) */
|
|
13
|
+
timeout?: number;
|
|
14
|
+
/** Number of retries on network/5xx errors. Default: 1 */
|
|
15
|
+
retries?: number;
|
|
16
|
+
/** Base delay between retries in ms (multiplied by attempt). Default: 1000 */
|
|
17
|
+
retryDelay?: number;
|
|
18
|
+
}
|
|
19
|
+
interface PaginatedResponse<T> {
|
|
20
|
+
items: T[];
|
|
21
|
+
total: number;
|
|
22
|
+
page: number;
|
|
23
|
+
limit: number;
|
|
24
|
+
totalPages: number;
|
|
25
|
+
}
|
|
26
|
+
interface MessageResponse {
|
|
27
|
+
message: string;
|
|
28
|
+
}
|
|
29
|
+
interface ShopInfo {
|
|
30
|
+
id: string;
|
|
31
|
+
name: string;
|
|
32
|
+
domain: string;
|
|
33
|
+
logo?: string;
|
|
34
|
+
favicon?: string;
|
|
35
|
+
isActive: boolean;
|
|
36
|
+
defaultLanguage: string;
|
|
37
|
+
supportedLanguages: string[];
|
|
38
|
+
defaultCurrency: string;
|
|
39
|
+
supportedCurrencies: string[];
|
|
40
|
+
metaTitle?: string;
|
|
41
|
+
metaDescription?: string;
|
|
42
|
+
allowGuestCheckout: boolean;
|
|
43
|
+
}
|
|
44
|
+
interface ProductPrice {
|
|
45
|
+
amount: number;
|
|
46
|
+
currency: string;
|
|
47
|
+
compareAtPrice?: number | null;
|
|
48
|
+
}
|
|
49
|
+
interface ProductVolumePrice {
|
|
50
|
+
minQuantity: number;
|
|
51
|
+
price: number;
|
|
52
|
+
currency?: string;
|
|
53
|
+
}
|
|
54
|
+
interface ProductVariant {
|
|
55
|
+
id: string;
|
|
56
|
+
sku: string;
|
|
57
|
+
name: string;
|
|
58
|
+
attributes: Record<string, string>;
|
|
59
|
+
price: ProductPrice;
|
|
60
|
+
inStock: boolean;
|
|
61
|
+
stockQuantity?: number;
|
|
62
|
+
}
|
|
63
|
+
interface ProductLabel {
|
|
64
|
+
id: string;
|
|
65
|
+
slug: string;
|
|
66
|
+
name: string;
|
|
67
|
+
color?: string;
|
|
68
|
+
}
|
|
69
|
+
interface ProductListItem {
|
|
70
|
+
id: string;
|
|
71
|
+
slug: string;
|
|
72
|
+
name: string;
|
|
73
|
+
shortDescription?: string;
|
|
74
|
+
sku: string;
|
|
75
|
+
gtin?: string;
|
|
76
|
+
price: ProductPrice;
|
|
77
|
+
inStock: boolean;
|
|
78
|
+
stockQuantity?: number;
|
|
79
|
+
image?: string | null;
|
|
80
|
+
labels: ProductLabel[];
|
|
81
|
+
isFeatured: boolean;
|
|
82
|
+
}
|
|
83
|
+
interface ProductDetail extends ProductListItem {
|
|
84
|
+
longDescription?: string;
|
|
85
|
+
images: Array<{
|
|
86
|
+
url: string;
|
|
87
|
+
alt?: string;
|
|
88
|
+
order: number;
|
|
89
|
+
}>;
|
|
90
|
+
categories: Array<{
|
|
91
|
+
id: string;
|
|
92
|
+
slug: string;
|
|
93
|
+
name: string;
|
|
94
|
+
}>;
|
|
95
|
+
variants: ProductVariant[];
|
|
96
|
+
volumePricing: ProductVolumePrice[];
|
|
97
|
+
customFields: Record<string, unknown>;
|
|
98
|
+
seo: {
|
|
99
|
+
title?: string | null;
|
|
100
|
+
description?: string | null;
|
|
101
|
+
keywords?: string | null;
|
|
102
|
+
};
|
|
103
|
+
productGroups?: Array<{
|
|
104
|
+
slug: string;
|
|
105
|
+
name: string;
|
|
106
|
+
products: ProductListItem[];
|
|
107
|
+
}>;
|
|
108
|
+
/** Product weight (from warehouse item) */
|
|
109
|
+
weight?: number | null;
|
|
110
|
+
/** Weight unit: GRAM, KILOGRAM, TONNE */
|
|
111
|
+
weightUnit?: string | null;
|
|
112
|
+
}
|
|
113
|
+
interface Category {
|
|
114
|
+
id: string;
|
|
115
|
+
slug: string;
|
|
116
|
+
name: string;
|
|
117
|
+
description?: string;
|
|
118
|
+
imageUrl?: string;
|
|
119
|
+
children: Category[];
|
|
120
|
+
productCount?: number;
|
|
121
|
+
}
|
|
122
|
+
interface CategoryDetail extends Category {
|
|
123
|
+
seoTitle?: string;
|
|
124
|
+
seoDescription?: string;
|
|
125
|
+
}
|
|
126
|
+
type DataGroupFieldType = "TEXT" | "NUMBER" | "DECIMAL" | "BOOLEAN" | "DATE" | "TIME" | "DATETIME" | "PERCENTAGE" | "MONEY" | "ASSET" | "ITEM_LIST" | "DYNAMIC_NUMBER_CALCULATION_FROM_OTHERS";
|
|
127
|
+
interface FilterField {
|
|
128
|
+
key: string;
|
|
129
|
+
name: string;
|
|
130
|
+
type: DataGroupFieldType | string;
|
|
131
|
+
groupKey: string;
|
|
132
|
+
groupName: string;
|
|
133
|
+
values?: string[];
|
|
134
|
+
}
|
|
135
|
+
declare const ProductSort: {
|
|
136
|
+
readonly PRICE_ASC: "price_asc";
|
|
137
|
+
readonly PRICE_DESC: "price_desc";
|
|
138
|
+
readonly NAME_ASC: "name_asc";
|
|
139
|
+
readonly NAME_DESC: "name_desc";
|
|
140
|
+
readonly NEWEST: "newest";
|
|
141
|
+
readonly FEATURED: "featured";
|
|
142
|
+
};
|
|
143
|
+
type ProductSortValue = (typeof ProductSort)[keyof typeof ProductSort];
|
|
144
|
+
declare const OrderStatuses: {
|
|
145
|
+
readonly PENDING: "PENDING";
|
|
146
|
+
readonly CONFIRMED: "CONFIRMED";
|
|
147
|
+
readonly PROCESSING: "PROCESSING";
|
|
148
|
+
readonly SHIPPED: "SHIPPED";
|
|
149
|
+
readonly DELIVERED: "DELIVERED";
|
|
150
|
+
readonly CANCELLED: "CANCELLED";
|
|
151
|
+
readonly REFUNDED: "REFUNDED";
|
|
152
|
+
};
|
|
153
|
+
declare const PaymentStatuses: {
|
|
154
|
+
readonly UNPAID: "UNPAID";
|
|
155
|
+
readonly PAID: "PAID";
|
|
156
|
+
readonly PARTIALLY_REFUNDED: "PARTIALLY_REFUNDED";
|
|
157
|
+
readonly REFUNDED: "REFUNDED";
|
|
158
|
+
};
|
|
159
|
+
declare const FulfillmentStatuses: {
|
|
160
|
+
readonly UNFULFILLED: "UNFULFILLED";
|
|
161
|
+
readonly PARTIALLY_FULFILLED: "PARTIALLY_FULFILLED";
|
|
162
|
+
readonly FULFILLED: "FULFILLED";
|
|
163
|
+
};
|
|
164
|
+
declare const AddressTypes: {
|
|
165
|
+
readonly SHIPPING: "SHIPPING";
|
|
166
|
+
readonly BILLING: "BILLING";
|
|
167
|
+
};
|
|
168
|
+
type AddressType = (typeof AddressTypes)[keyof typeof AddressTypes];
|
|
169
|
+
interface ProductsQuery {
|
|
170
|
+
page?: number;
|
|
171
|
+
limit?: number;
|
|
172
|
+
category?: string;
|
|
173
|
+
label?: string;
|
|
174
|
+
priceMin?: number;
|
|
175
|
+
priceMax?: number;
|
|
176
|
+
currency?: string;
|
|
177
|
+
locale?: string;
|
|
178
|
+
sort?: ProductSortValue;
|
|
179
|
+
inStock?: boolean;
|
|
180
|
+
search?: string;
|
|
181
|
+
customFields?: Record<string, unknown>;
|
|
182
|
+
}
|
|
183
|
+
interface AuthTokens {
|
|
184
|
+
accessToken: string;
|
|
185
|
+
refreshToken: string;
|
|
186
|
+
}
|
|
187
|
+
interface RegisterInput {
|
|
188
|
+
email: string;
|
|
189
|
+
password: string;
|
|
190
|
+
firstName?: string;
|
|
191
|
+
lastName?: string;
|
|
192
|
+
}
|
|
193
|
+
interface LoginInput {
|
|
194
|
+
email: string;
|
|
195
|
+
password: string;
|
|
196
|
+
}
|
|
197
|
+
interface CartItemProduct {
|
|
198
|
+
slug: string;
|
|
199
|
+
name: string;
|
|
200
|
+
sku: string;
|
|
201
|
+
imageUrl?: string;
|
|
202
|
+
inStock: boolean;
|
|
203
|
+
currentPrice: number;
|
|
204
|
+
}
|
|
205
|
+
interface CartItem {
|
|
206
|
+
id: string;
|
|
207
|
+
product: CartItemProduct;
|
|
208
|
+
quantity: number;
|
|
209
|
+
unitPrice: number;
|
|
210
|
+
totalPrice: number;
|
|
211
|
+
priceChanged: boolean;
|
|
212
|
+
volumePriceApplied: boolean;
|
|
213
|
+
}
|
|
214
|
+
interface CartDiscount {
|
|
215
|
+
code: string;
|
|
216
|
+
type: string;
|
|
217
|
+
value: number;
|
|
218
|
+
}
|
|
219
|
+
interface Cart {
|
|
220
|
+
id: string;
|
|
221
|
+
sessionToken?: string;
|
|
222
|
+
items: CartItem[];
|
|
223
|
+
subtotal: number;
|
|
224
|
+
discountTotal: number;
|
|
225
|
+
discount?: CartDiscount;
|
|
226
|
+
grandTotal: number;
|
|
227
|
+
currency: string;
|
|
228
|
+
itemCount: number;
|
|
229
|
+
}
|
|
230
|
+
interface AddToCartInput {
|
|
231
|
+
/** Product ID (eshop product ID or warehouse item ID) */
|
|
232
|
+
productId: string;
|
|
233
|
+
quantity: number;
|
|
234
|
+
}
|
|
235
|
+
interface CheckoutAddress {
|
|
236
|
+
firstName: string;
|
|
237
|
+
lastName: string;
|
|
238
|
+
company?: string;
|
|
239
|
+
street: string;
|
|
240
|
+
city: string;
|
|
241
|
+
zip: string;
|
|
242
|
+
country: string;
|
|
243
|
+
phone?: string;
|
|
244
|
+
}
|
|
245
|
+
interface CheckoutInput {
|
|
246
|
+
shippingAddress: CheckoutAddress;
|
|
247
|
+
billingAddress: CheckoutAddress;
|
|
248
|
+
email: string;
|
|
249
|
+
phone?: string;
|
|
250
|
+
customerNote?: string;
|
|
251
|
+
}
|
|
252
|
+
type OrderStatus = (typeof OrderStatuses)[keyof typeof OrderStatuses];
|
|
253
|
+
type PaymentStatus = (typeof PaymentStatuses)[keyof typeof PaymentStatuses];
|
|
254
|
+
type FulfillmentStatus = (typeof FulfillmentStatuses)[keyof typeof FulfillmentStatuses];
|
|
255
|
+
interface OrderListItem {
|
|
256
|
+
id: string;
|
|
257
|
+
orderNumber: string;
|
|
258
|
+
status: OrderStatus;
|
|
259
|
+
paymentStatus: PaymentStatus;
|
|
260
|
+
grandTotal: number;
|
|
261
|
+
currency: string;
|
|
262
|
+
itemCount: number;
|
|
263
|
+
createdAt: number;
|
|
264
|
+
}
|
|
265
|
+
interface OrderItem {
|
|
266
|
+
productName: string;
|
|
267
|
+
sku: string;
|
|
268
|
+
imageUrl?: string;
|
|
269
|
+
quantity: number;
|
|
270
|
+
unitPrice: number;
|
|
271
|
+
totalPrice: number;
|
|
272
|
+
totalPriceWithTax: number;
|
|
273
|
+
}
|
|
274
|
+
interface OrderStatusHistory {
|
|
275
|
+
fromStatus?: OrderStatus;
|
|
276
|
+
toStatus: OrderStatus;
|
|
277
|
+
note?: string;
|
|
278
|
+
changedBy?: string;
|
|
279
|
+
createdAt: number;
|
|
280
|
+
}
|
|
281
|
+
interface OrderDetail extends OrderListItem {
|
|
282
|
+
items: OrderItem[];
|
|
283
|
+
shippingAddress: CheckoutAddress;
|
|
284
|
+
billingAddress: CheckoutAddress;
|
|
285
|
+
email: string;
|
|
286
|
+
phone?: string;
|
|
287
|
+
customerNote?: string;
|
|
288
|
+
subtotal: number;
|
|
289
|
+
taxTotal: number;
|
|
290
|
+
shippingTotal: number;
|
|
291
|
+
discountTotal: number;
|
|
292
|
+
fulfillmentStatus: FulfillmentStatus;
|
|
293
|
+
statusHistory: OrderStatusHistory[];
|
|
294
|
+
trackingToken?: string;
|
|
295
|
+
}
|
|
296
|
+
interface CustomerProfile {
|
|
297
|
+
id: string;
|
|
298
|
+
email: string;
|
|
299
|
+
firstName?: string;
|
|
300
|
+
lastName?: string;
|
|
301
|
+
phone?: string;
|
|
302
|
+
emailVerified: boolean;
|
|
303
|
+
}
|
|
304
|
+
interface CustomerAddress {
|
|
305
|
+
id: string;
|
|
306
|
+
type: AddressType;
|
|
307
|
+
isDefault: boolean;
|
|
308
|
+
firstName: string;
|
|
309
|
+
lastName: string;
|
|
310
|
+
company?: string;
|
|
311
|
+
street: string;
|
|
312
|
+
city: string;
|
|
313
|
+
zip: string;
|
|
314
|
+
country: string;
|
|
315
|
+
phone?: string;
|
|
316
|
+
}
|
|
317
|
+
interface Page {
|
|
318
|
+
slug: string;
|
|
319
|
+
title: string;
|
|
320
|
+
isActive: boolean;
|
|
321
|
+
}
|
|
322
|
+
interface PageDetail {
|
|
323
|
+
slug: string;
|
|
324
|
+
title: string;
|
|
325
|
+
content: unknown;
|
|
326
|
+
seoTitle?: string;
|
|
327
|
+
seoDescription?: string;
|
|
328
|
+
}
|
|
329
|
+
type BehioErrorCode = "UNAUTHORIZED" | "FORBIDDEN" | "NOT_FOUND" | "VALIDATION_ERROR" | "CONFLICT" | "RATE_LIMITED" | "CART_EMPTY" | "PRODUCT_NOT_FOUND" | "INVALID_CREDENTIALS" | "INVALID_DISCOUNT" | "DISCOUNT_EXPIRED" | "TOKEN_EXPIRED" | "TOKEN_INVALID" | "EMAIL_ALREADY_EXISTS" | "ORDER_NOT_CANCELLABLE" | "INTERNAL_ERROR" | "NETWORK_ERROR" | "TIMEOUT" | "UNKNOWN";
|
|
330
|
+
declare class BehioApiError extends Error {
|
|
331
|
+
readonly code: BehioErrorCode;
|
|
332
|
+
readonly status: number;
|
|
333
|
+
readonly body: unknown;
|
|
334
|
+
readonly isRetryable: boolean;
|
|
335
|
+
constructor(status: number, body: unknown, message?: string);
|
|
336
|
+
static resolveCode(status: number, body: unknown): BehioErrorCode;
|
|
337
|
+
/** Check if this is a specific error type */
|
|
338
|
+
is(code: BehioErrorCode): boolean;
|
|
339
|
+
}
|
|
340
|
+
declare class BehioNetworkError extends Error {
|
|
341
|
+
readonly code: "NETWORK_ERROR" | "TIMEOUT";
|
|
342
|
+
readonly isRetryable = true;
|
|
343
|
+
constructor(message: string, isTimeout?: boolean);
|
|
344
|
+
}
|
|
345
|
+
type BehioEventType = "auth:login" | "auth:logout" | "auth:token-refresh" | "auth:token-refresh-failed" | "cart:updated" | "cart:cleared" | "order:created" | "error" | "request" | "response" | "rate-limit-warning";
|
|
346
|
+
type BehioEventHandler = (data?: unknown) => void;
|
|
347
|
+
interface RequestInterceptorConfig {
|
|
348
|
+
url: string;
|
|
349
|
+
method: string;
|
|
350
|
+
headers: Record<string, string>;
|
|
351
|
+
body?: string;
|
|
352
|
+
}
|
|
353
|
+
interface RequestInterceptor {
|
|
354
|
+
(config: RequestInterceptorConfig): RequestInterceptorConfig | Promise<RequestInterceptorConfig>;
|
|
355
|
+
}
|
|
356
|
+
interface ResponseInterceptorData {
|
|
357
|
+
status: number;
|
|
358
|
+
data: unknown;
|
|
359
|
+
headers: Headers;
|
|
360
|
+
}
|
|
361
|
+
interface ResponseInterceptor {
|
|
362
|
+
(response: ResponseInterceptorData): void | Promise<void>;
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
declare class BehioStorefront {
|
|
366
|
+
private baseUrl;
|
|
367
|
+
private apiKey;
|
|
368
|
+
private defaultLocale?;
|
|
369
|
+
private defaultCurrency?;
|
|
370
|
+
private fetchFn;
|
|
371
|
+
private timeout;
|
|
372
|
+
private retries;
|
|
373
|
+
private retryDelay;
|
|
374
|
+
private accessToken?;
|
|
375
|
+
private refreshToken?;
|
|
376
|
+
private isRefreshing;
|
|
377
|
+
private refreshPromise;
|
|
378
|
+
private cartSession?;
|
|
379
|
+
private listeners;
|
|
380
|
+
private requestInterceptors;
|
|
381
|
+
private responseInterceptors;
|
|
382
|
+
private rateLimitRemaining;
|
|
383
|
+
private rateLimitReset;
|
|
384
|
+
constructor(config: BehioStorefrontConfig);
|
|
385
|
+
readonly catalog: CatalogModule;
|
|
386
|
+
readonly auth: AuthModule;
|
|
387
|
+
readonly cart: CartModule;
|
|
388
|
+
readonly checkout: CheckoutModule;
|
|
389
|
+
readonly orders: OrdersModule;
|
|
390
|
+
readonly customer: CustomerModule;
|
|
391
|
+
readonly pages: PagesModule;
|
|
392
|
+
/** Get basic shop info */
|
|
393
|
+
getShopInfo(): Promise<ShopInfo>;
|
|
394
|
+
/** Set auth tokens (e.g. from localStorage) */
|
|
395
|
+
setTokens(tokens: {
|
|
396
|
+
accessToken: string;
|
|
397
|
+
refreshToken: string;
|
|
398
|
+
}): void;
|
|
399
|
+
/** Clear auth tokens */
|
|
400
|
+
clearTokens(): void;
|
|
401
|
+
/** Get current access token */
|
|
402
|
+
getAccessToken(): string | undefined;
|
|
403
|
+
/** Get current refresh token */
|
|
404
|
+
getRefreshToken(): string | undefined;
|
|
405
|
+
/** Set cart session token (e.g. from cookie) */
|
|
406
|
+
setCartSession(token: string): void;
|
|
407
|
+
/** Get cart session token */
|
|
408
|
+
getCartSession(): string | undefined;
|
|
409
|
+
/** Clear cart session */
|
|
410
|
+
clearCartSession(): void;
|
|
411
|
+
/** Subscribe to SDK events. Returns an unsubscribe function. */
|
|
412
|
+
on(event: BehioEventType, handler: BehioEventHandler): () => void;
|
|
413
|
+
/** @internal Emit an event (fire-and-forget, handler errors are swallowed) */
|
|
414
|
+
emit(event: BehioEventType, data?: unknown): void;
|
|
415
|
+
/** Add a request interceptor. Returns an unsubscribe function. */
|
|
416
|
+
addRequestInterceptor(fn: RequestInterceptor): () => void;
|
|
417
|
+
/** Add a response interceptor. Returns an unsubscribe function. */
|
|
418
|
+
addResponseInterceptor(fn: ResponseInterceptor): () => void;
|
|
419
|
+
/** Get current rate limit info from latest response headers */
|
|
420
|
+
getRateLimitInfo(): {
|
|
421
|
+
remaining: number | null;
|
|
422
|
+
reset: number | null;
|
|
423
|
+
};
|
|
424
|
+
private handleTokenRefresh;
|
|
425
|
+
/** @internal */
|
|
426
|
+
request<T>(method: string, path: string, options?: {
|
|
427
|
+
body?: unknown;
|
|
428
|
+
query?: Record<string, string | number | boolean | undefined>;
|
|
429
|
+
auth?: boolean;
|
|
430
|
+
signal?: AbortSignal;
|
|
431
|
+
/** @internal Prevents infinite refresh loops */
|
|
432
|
+
_isRetryAfterRefresh?: boolean;
|
|
433
|
+
}): Promise<T>;
|
|
434
|
+
}
|
|
435
|
+
declare class CatalogModule {
|
|
436
|
+
private client;
|
|
437
|
+
constructor(client: BehioStorefront);
|
|
438
|
+
/** List products with filtering, pagination, search */
|
|
439
|
+
getProducts(query?: ProductsQuery): Promise<PaginatedResponse<ProductListItem>>;
|
|
440
|
+
/** Get product detail by slug */
|
|
441
|
+
getProduct(slug: string, options?: {
|
|
442
|
+
locale?: string;
|
|
443
|
+
currency?: string;
|
|
444
|
+
}): Promise<ProductDetail>;
|
|
445
|
+
/** Get category tree */
|
|
446
|
+
getCategories(locale?: string): Promise<{
|
|
447
|
+
categories: Category[];
|
|
448
|
+
}>;
|
|
449
|
+
/** Get category detail by slug */
|
|
450
|
+
getCategory(slug: string, locale?: string): Promise<CategoryDetail>;
|
|
451
|
+
/** Get products in a category */
|
|
452
|
+
getCategoryProducts(slug: string, query?: ProductsQuery): Promise<PaginatedResponse<ProductListItem>>;
|
|
453
|
+
/** Get all labels */
|
|
454
|
+
getLabels(locale?: string): Promise<{
|
|
455
|
+
labels: ProductLabel[];
|
|
456
|
+
}>;
|
|
457
|
+
/** Get featured products */
|
|
458
|
+
getFeatured(options?: {
|
|
459
|
+
locale?: string;
|
|
460
|
+
currency?: string;
|
|
461
|
+
}): Promise<PaginatedResponse<ProductListItem>>;
|
|
462
|
+
/** Get available filter fields for dynamic filter UI */
|
|
463
|
+
getFilters(): Promise<{
|
|
464
|
+
filters: FilterField[];
|
|
465
|
+
}>;
|
|
466
|
+
/** Search products */
|
|
467
|
+
search(query: string, options?: {
|
|
468
|
+
page?: number;
|
|
469
|
+
limit?: number;
|
|
470
|
+
}): Promise<PaginatedResponse<ProductListItem>>;
|
|
471
|
+
}
|
|
472
|
+
declare class AuthModule {
|
|
473
|
+
private client;
|
|
474
|
+
constructor(client: BehioStorefront);
|
|
475
|
+
/** Register a new customer */
|
|
476
|
+
register(input: RegisterInput): Promise<AuthTokens>;
|
|
477
|
+
/** Login with email and password */
|
|
478
|
+
login(input: LoginInput): Promise<AuthTokens>;
|
|
479
|
+
/** Refresh access token using refresh token */
|
|
480
|
+
refresh(refreshToken?: string): Promise<AuthTokens>;
|
|
481
|
+
/** Logout (invalidate refresh token) */
|
|
482
|
+
logout(refreshToken?: string): Promise<MessageResponse>;
|
|
483
|
+
/** Request password reset email */
|
|
484
|
+
forgotPassword(email: string): Promise<MessageResponse>;
|
|
485
|
+
/** Reset password with token */
|
|
486
|
+
resetPassword(token: string, newPassword: string): Promise<MessageResponse>;
|
|
487
|
+
/** Verify email with token */
|
|
488
|
+
verifyEmail(token: string): Promise<MessageResponse>;
|
|
489
|
+
/** Check if user is logged in (has access token) */
|
|
490
|
+
isLoggedIn(): boolean;
|
|
491
|
+
}
|
|
492
|
+
declare class CartModule {
|
|
493
|
+
private client;
|
|
494
|
+
constructor(client: BehioStorefront);
|
|
495
|
+
/** Get current cart */
|
|
496
|
+
get(): Promise<Cart>;
|
|
497
|
+
/** Add item to cart */
|
|
498
|
+
addItem(input: AddToCartInput): Promise<Cart & {
|
|
499
|
+
newSessionToken?: string;
|
|
500
|
+
}>;
|
|
501
|
+
/** Update item quantity */
|
|
502
|
+
updateQuantity(itemId: string, quantity: number): Promise<Cart>;
|
|
503
|
+
/** Remove item from cart */
|
|
504
|
+
removeItem(itemId: string): Promise<Cart>;
|
|
505
|
+
/** Clear entire cart */
|
|
506
|
+
clear(): Promise<void>;
|
|
507
|
+
/** Merge anonymous cart into authenticated customer cart */
|
|
508
|
+
merge(): Promise<Cart>;
|
|
509
|
+
/** Apply discount code */
|
|
510
|
+
applyDiscount(code: string): Promise<Cart>;
|
|
511
|
+
/** Remove discount code */
|
|
512
|
+
removeDiscount(): Promise<Cart>;
|
|
513
|
+
}
|
|
514
|
+
declare class CheckoutModule {
|
|
515
|
+
private client;
|
|
516
|
+
constructor(client: BehioStorefront);
|
|
517
|
+
/** Create order from cart */
|
|
518
|
+
createOrder(input: CheckoutInput): Promise<OrderDetail>;
|
|
519
|
+
}
|
|
520
|
+
declare class OrdersModule {
|
|
521
|
+
private client;
|
|
522
|
+
constructor(client: BehioStorefront);
|
|
523
|
+
/** List customer orders (requires auth) */
|
|
524
|
+
list(options?: {
|
|
525
|
+
page?: number;
|
|
526
|
+
limit?: number;
|
|
527
|
+
}): Promise<PaginatedResponse<OrderListItem>>;
|
|
528
|
+
/** Get order detail (requires auth) */
|
|
529
|
+
get(orderNumber: string): Promise<OrderDetail>;
|
|
530
|
+
/** Cancel a PENDING order (requires auth) */
|
|
531
|
+
cancel(orderNumber: string): Promise<OrderDetail>;
|
|
532
|
+
/** Track order by tracking token (no auth required) */
|
|
533
|
+
track(trackingToken: string): Promise<OrderDetail>;
|
|
534
|
+
}
|
|
535
|
+
declare class CustomerModule {
|
|
536
|
+
private client;
|
|
537
|
+
constructor(client: BehioStorefront);
|
|
538
|
+
/** Get customer profile */
|
|
539
|
+
getProfile(): Promise<CustomerProfile>;
|
|
540
|
+
/** Update customer profile */
|
|
541
|
+
updateProfile(data: Partial<Pick<CustomerProfile, "firstName" | "lastName" | "phone">>): Promise<CustomerProfile>;
|
|
542
|
+
/** Change password */
|
|
543
|
+
changePassword(currentPassword: string, newPassword: string): Promise<MessageResponse>;
|
|
544
|
+
/** List addresses */
|
|
545
|
+
getAddresses(): Promise<{
|
|
546
|
+
items: CustomerAddress[];
|
|
547
|
+
}>;
|
|
548
|
+
/** Create address */
|
|
549
|
+
createAddress(address: Omit<CustomerAddress, "id">): Promise<CustomerAddress>;
|
|
550
|
+
/** Update address */
|
|
551
|
+
updateAddress(addressId: string, data: Partial<CustomerAddress>): Promise<CustomerAddress>;
|
|
552
|
+
/** Delete address */
|
|
553
|
+
deleteAddress(addressId: string): Promise<void>;
|
|
554
|
+
}
|
|
555
|
+
declare class PagesModule {
|
|
556
|
+
private client;
|
|
557
|
+
constructor(client: BehioStorefront);
|
|
558
|
+
/** List CMS pages */
|
|
559
|
+
list(locale?: string): Promise<{
|
|
560
|
+
pages: Page[];
|
|
561
|
+
}>;
|
|
562
|
+
/** Get page by slug */
|
|
563
|
+
get(slug: string, locale?: string): Promise<PageDetail>;
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
export { type AddToCartInput, type AddressType, AddressTypes, type AuthTokens, BehioApiError, type BehioErrorCode, type BehioEventHandler, type BehioEventType, BehioNetworkError, BehioStorefront, type BehioStorefrontConfig, type Cart, type CartDiscount, type CartItem, type CartItemProduct, type Category, type CategoryDetail, type CheckoutAddress, type CheckoutInput, type CustomerAddress, type CustomerProfile, type DataGroupFieldType, type FilterField, type FulfillmentStatus, FulfillmentStatuses, type LoginInput, type MessageResponse, type OrderDetail, type OrderItem, type OrderListItem, type OrderStatus, type OrderStatusHistory, OrderStatuses, type Page, type PageDetail, type PaginatedResponse, type PaymentStatus, PaymentStatuses, type ProductDetail, type ProductLabel, type ProductListItem, type ProductPrice, ProductSort, type ProductSortValue, type ProductVariant, type ProductVolumePrice, type ProductsQuery, type RegisterInput, type RequestInterceptor, type RequestInterceptorConfig, type ResponseInterceptor, type ResponseInterceptorData, type ShopInfo };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
var _chunk26WZOAWPjs = require('./chunk-26WZOAWP.js');
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
exports.AddressTypes = _chunk26WZOAWPjs.AddressTypes; exports.BehioApiError = _chunk26WZOAWPjs.BehioApiError; exports.BehioNetworkError = _chunk26WZOAWPjs.BehioNetworkError; exports.BehioStorefront = _chunk26WZOAWPjs.BehioStorefront; exports.FulfillmentStatuses = _chunk26WZOAWPjs.FulfillmentStatuses; exports.OrderStatuses = _chunk26WZOAWPjs.OrderStatuses; exports.PaymentStatuses = _chunk26WZOAWPjs.PaymentStatuses; exports.ProductSort = _chunk26WZOAWPjs.ProductSort;
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AddressTypes,
|
|
3
|
+
BehioApiError,
|
|
4
|
+
BehioNetworkError,
|
|
5
|
+
BehioStorefront,
|
|
6
|
+
FulfillmentStatuses,
|
|
7
|
+
OrderStatuses,
|
|
8
|
+
PaymentStatuses,
|
|
9
|
+
ProductSort
|
|
10
|
+
} from "./chunk-3OJEEMLI.mjs";
|
|
11
|
+
export {
|
|
12
|
+
AddressTypes,
|
|
13
|
+
BehioApiError,
|
|
14
|
+
BehioNetworkError,
|
|
15
|
+
BehioStorefront,
|
|
16
|
+
FulfillmentStatuses,
|
|
17
|
+
OrderStatuses,
|
|
18
|
+
PaymentStatuses,
|
|
19
|
+
ProductSort
|
|
20
|
+
};
|