@behio/storefront-sdk 0.10.0 → 0.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,1318 +1,13 @@
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 ShopSeo {
45
- locale: string;
46
- title: string | null;
47
- description: string | null;
48
- keywords: string | null;
49
- ogTitle: string | null;
50
- ogDescription: string | null;
51
- ogImage: string | null;
52
- }
53
- /**
54
- * Money amount displayed to a customer in a chosen currency.
55
- *
56
- * Two cases:
57
- * - **Fixed price** (preferred): merchant configured an explicit price for
58
- * this currency. `isApproximate` is `false`/absent and `fxSource` is `null`.
59
- * - **Approximate / FX-converted**: no fixed price for the requested
60
- * currency, so Behio converted from the eshop's default currency using
61
- * today's rate from `fxSource` (CNB or Frankfurter/ECB) plus the eshop's
62
- * safety margin. UI should show a `≈` hint and offer the base price too.
63
- */
64
- /**
65
- * Payment method available at checkout. Returned by
66
- * `GET /storefront/v1/catalog/payment-methods` filtered for the customer's
67
- * chosen currency. Credentials (API keys, merchant ids) stay server-side
68
- * — only customer-safe fields appear here.
69
- */
70
- interface CheckoutPaymentMethod {
71
- id: string;
72
- /** Merchant-chosen label, e.g. "Kartou (Stripe)" or "Převodem na účet". */
73
- name: string;
74
- description?: string | null;
75
- /** Provider id: "stripe" | "gopay" | "comgate" | "bank_transfer" | "cod" | "custom". */
76
- provider: string;
77
- /** Currencies this method accepts. Empty = any. */
78
- currencies: string[];
79
- /** Optional fee added to the order total (e.g. COD surcharge). */
80
- fee?: number | null;
81
- feeCurrency?: string | null;
82
- /** Customer-safe slice of config: bank account, IBAN, instructions, … */
83
- publicConfig?: Record<string, unknown>;
84
- }
85
- interface ProductPrice {
86
- amount: number;
87
- currency: string;
88
- compareAtPrice?: number | null;
89
- /** `true` when this amount was FX-converted from the eshop default currency. */
90
- isApproximate?: boolean;
91
- /** Provider id ("cnb" | "frankfurter" | "manual") when FX-converted. */
92
- fxSource?: string | null;
93
- /** Original amount in the eshop default currency before conversion. */
94
- baseAmount?: number | null;
95
- /** ISO code of the currency `baseAmount` is denominated in. */
96
- baseCurrency?: string | null;
97
- }
98
- interface ProductVolumePrice {
99
- minQuantity: number;
100
- price: number;
101
- currency?: string;
102
- }
103
- interface ProductVariant {
104
- id: string;
105
- sku: string;
106
- name: string;
107
- attributes: Record<string, string>;
108
- price: ProductPrice;
109
- inStock: boolean;
110
- stockQuantity?: number;
111
- /**
112
- * Cover image URL for the variant. Falls back to the parent product's
113
- * cover when the variant has no photo of its own — see `imageIsInherited`.
114
- */
115
- imageUrl?: string | null;
116
- /**
117
- * `true` when `imageUrl` is borrowed from the parent product because the
118
- * variant has no cover image of its own. Use this to render a hint like
119
- * "default photo" or to render the picture in a subtler style.
120
- */
121
- imageIsInherited: boolean;
122
- }
123
- interface ProductLabel {
124
- id: string;
125
- slug: string;
126
- name: string;
127
- color?: string;
128
- }
129
- interface ProductListItem {
130
- id: string;
131
- slug: string;
132
- name: string;
133
- shortDescription?: string;
134
- sku: string;
135
- gtin?: string;
136
- price: ProductPrice;
137
- inStock: boolean;
138
- stockQuantity?: number;
139
- image?: string | null;
140
- labels: ProductLabel[];
141
- isFeatured: boolean;
142
- }
143
- /** A single responsive derivative (size + format) of a media image. */
144
- interface ProductMediaVariant {
145
- variant: 'thumb' | 'medium' | 'large' | 'xlarge';
146
- format: 'jpeg' | 'webp' | 'avif';
147
- url: string;
148
- width: number;
149
- height: number;
150
- }
151
- /**
152
- * A product gallery entry (image or video), sourced from the inventory item
153
- * so it is shared across every storefront listing the product. Images carry
154
- * responsive `variants` (webp/avif/jpeg in three sizes) for fast LCP; pick
155
- * the smallest format the client supports.
156
- */
157
- interface ProductMedia {
158
- id: string;
159
- type: 'IMAGE' | 'VIDEO';
160
- /** Original uploaded file URL. */
161
- url: string;
162
- alt?: string | null;
163
- isCover: boolean;
164
- order: number;
165
- variants: ProductMediaVariant[];
166
- }
167
- interface ProductDetail extends ProductListItem {
168
- longDescription?: string;
169
- /** @deprecated Legacy per-listing images. Prefer `media`. */
170
- images: Array<{
171
- url: string;
172
- alt?: string;
173
- order: number;
174
- }>;
175
- /** Product gallery (images + videos) with responsive derivatives. */
176
- media: ProductMedia[];
177
- categories: Array<{
178
- id: string;
179
- slug: string;
180
- name: string;
181
- }>;
182
- variants: ProductVariant[];
183
- volumePricing: ProductVolumePrice[];
184
- customFields: Record<string, unknown>;
185
- seo: {
186
- title?: string | null;
187
- description?: string | null;
188
- keywords?: string | null;
189
- };
190
- productGroups?: Array<{
191
- slug: string;
192
- name: string;
193
- products: ProductListItem[];
194
- }>;
195
- /** Product weight (from warehouse item) */
196
- weight?: number | null;
197
- /** Weight unit: GRAM, KILOGRAM, TONNE */
198
- weightUnit?: string | null;
199
- }
200
- interface Category {
201
- id: string;
202
- slug: string;
203
- name: string;
204
- description?: string;
205
- imageUrl?: string;
206
- children: Category[];
207
- productCount?: number;
208
- }
209
- interface CategoryDetail extends Category {
210
- seoTitle?: string;
211
- seoDescription?: string;
212
- }
213
- type DataGroupFieldType = "TEXT" | "NUMBER" | "DECIMAL" | "BOOLEAN" | "DATE" | "TIME" | "DATETIME" | "PERCENTAGE" | "MONEY" | "ASSET" | "ITEM_LIST" | "DYNAMIC_NUMBER_CALCULATION_FROM_OTHERS";
214
- interface FilterField {
215
- key: string;
216
- name: string;
217
- type: DataGroupFieldType | string;
218
- groupKey: string;
219
- groupName: string;
220
- values?: string[];
221
- }
222
- declare const ProductSort: {
223
- readonly PRICE_ASC: "price_asc";
224
- readonly PRICE_DESC: "price_desc";
225
- readonly NAME_ASC: "name_asc";
226
- readonly NAME_DESC: "name_desc";
227
- readonly NEWEST: "newest";
228
- readonly FEATURED: "featured";
229
- };
230
- type ProductSortValue = (typeof ProductSort)[keyof typeof ProductSort];
231
- declare const OrderStatuses: {
232
- readonly PENDING: "PENDING";
233
- readonly CONFIRMED: "CONFIRMED";
234
- readonly PROCESSING: "PROCESSING";
235
- readonly SHIPPED: "SHIPPED";
236
- readonly DELIVERED: "DELIVERED";
237
- readonly CANCELLED: "CANCELLED";
238
- readonly REFUNDED: "REFUNDED";
239
- };
240
- declare const PaymentStatuses: {
241
- readonly UNPAID: "UNPAID";
242
- readonly PAID: "PAID";
243
- readonly PARTIALLY_REFUNDED: "PARTIALLY_REFUNDED";
244
- readonly REFUNDED: "REFUNDED";
245
- };
246
- declare const FulfillmentStatuses: {
247
- readonly UNFULFILLED: "UNFULFILLED";
248
- readonly PARTIALLY_FULFILLED: "PARTIALLY_FULFILLED";
249
- readonly FULFILLED: "FULFILLED";
250
- };
251
- declare const AddressTypes: {
252
- readonly SHIPPING: "SHIPPING";
253
- readonly BILLING: "BILLING";
254
- };
255
- type AddressType = (typeof AddressTypes)[keyof typeof AddressTypes];
256
- interface ProductsQuery {
257
- page?: number;
258
- limit?: number;
259
- /** Single category slug (OR logic with categories array) */
260
- category?: string;
261
- /** Multiple category slugs (OR logic — product in ANY of these categories) */
262
- categories?: string[];
263
- /** Single label slug */
264
- label?: string;
265
- priceMin?: number;
266
- priceMax?: number;
267
- currency?: string;
268
- locale?: string;
269
- sort?: ProductSortValue;
270
- inStock?: boolean;
271
- search?: string;
272
- customFields?: Record<string, unknown>;
273
- /** Filter by specific product IDs (comma-separated in URL) */
274
- ids?: string[];
275
- /** Filter by specific product slugs */
276
- slugs?: string[];
277
- /** Multiple labels (AND logic — product must have ALL) */
278
- labels?: string[];
279
- /** Exclude specific product IDs (e.g. for "related products" excluding current) */
280
- excludeIds?: string[];
281
- /** Exclude products in specific categories */
282
- excludeCategories?: string[];
283
- /** Only products with compareAtPrice (on sale) */
284
- hasDiscount?: boolean;
285
- /** Only featured products */
286
- isFeatured?: boolean;
287
- /** Products created after timestamp (epoch ms) */
288
- createdAfter?: number;
289
- }
290
- interface AuthTokens {
291
- accessToken: string;
292
- refreshToken: string;
293
- }
294
- interface RegisterInput {
295
- email: string;
296
- password: string;
297
- firstName?: string;
298
- lastName?: string;
299
- }
300
- interface LoginInput {
301
- email: string;
302
- password: string;
303
- }
304
- interface CartItemProduct {
305
- slug: string;
306
- name: string;
307
- sku: string;
308
- imageUrl?: string;
309
- inStock: boolean;
310
- currentPrice: number;
311
- }
312
- interface CartItem {
313
- id: string;
314
- product: CartItemProduct;
315
- quantity: number;
316
- unitPrice: number;
317
- totalPrice: number;
318
- priceChanged: boolean;
319
- volumePriceApplied: boolean;
320
- }
321
- interface CartDiscount {
322
- code: string;
323
- type: string;
324
- value: number;
325
- }
326
- interface Cart {
327
- id: string;
328
- sessionToken?: string;
329
- items: CartItem[];
330
- subtotal: number;
331
- discountTotal: number;
332
- discount?: CartDiscount;
333
- grandTotal: number;
334
- currency: string;
335
- itemCount: number;
336
- }
337
- interface AddToCartInput {
338
- /** Product ID (eshop product ID or warehouse item ID) */
339
- productId: string;
340
- quantity: number;
341
- }
342
- interface CheckoutAddress {
343
- firstName: string;
344
- lastName: string;
345
- company?: string;
346
- street: string;
347
- city: string;
348
- zip: string;
349
- country: string;
350
- phone?: string;
351
- }
352
- interface CheckoutInput {
353
- shippingAddress: CheckoutAddress;
354
- billingAddress: CheckoutAddress;
355
- email: string;
356
- phone?: string;
357
- customerNote?: string;
358
- /**
359
- * Chosen shipping method. Required whenever the eshop has at least one
360
- * enabled shipping method — the backend rejects the order without it.
361
- * Prefer also sending `shippingQuoteId` from `shipping.quote()`; with only
362
- * the method id the backend re-quotes the cart server-side.
363
- */
364
- shippingMethodId?: string;
365
- /**
366
- * Quote id from `shipping.quote()` — pins the exact server-computed price
367
- * the customer saw. Expired quotes are re-quoted automatically; a consumed
368
- * or foreign quote is rejected.
369
- */
370
- shippingQuoteId?: string;
371
- paymentMethodId?: string;
372
- }
373
- type OrderStatus = (typeof OrderStatuses)[keyof typeof OrderStatuses];
374
- type PaymentStatus = (typeof PaymentStatuses)[keyof typeof PaymentStatuses];
375
- type FulfillmentStatus = (typeof FulfillmentStatuses)[keyof typeof FulfillmentStatuses];
376
- interface OrderListItem {
377
- id: string;
378
- orderNumber: string;
379
- status: OrderStatus;
380
- paymentStatus: PaymentStatus;
381
- grandTotal: number;
382
- currency: string;
383
- itemCount: number;
384
- createdAt: number;
385
- }
386
- interface OrderItem {
387
- productName: string;
388
- sku: string;
389
- imageUrl?: string;
390
- quantity: number;
391
- unitPrice: number;
392
- totalPrice: number;
393
- totalPriceWithTax: number;
394
- }
395
- /**
396
- * PII-minimized order view returned by `orders.track(token)`. The tracking
397
- * token is shared in URLs and e-mails, so this deliberately omits full
398
- * address, phone, billing and customer note, and masks the email.
399
- */
400
- interface OrderTracking {
401
- orderNumber: string;
402
- status: OrderStatus;
403
- paymentStatus: PaymentStatus;
404
- fulfillmentStatus: FulfillmentStatus;
405
- currency: string;
406
- grandTotal: number;
407
- /** Masked, e.g. "j***@e***.cz" */
408
- emailMasked: string;
409
- shippingCity: string | null;
410
- shippingCountry: string | null;
411
- items: OrderItem[];
412
- createdAt: number;
413
- }
414
- interface OrderStatusHistory {
415
- fromStatus?: OrderStatus;
416
- toStatus: OrderStatus;
417
- note?: string;
418
- changedBy?: string;
419
- createdAt: number;
420
- }
421
- interface OrderDetail extends OrderListItem {
422
- items: OrderItem[];
423
- shippingAddress: CheckoutAddress;
424
- billingAddress: CheckoutAddress;
425
- email: string;
426
- phone?: string;
427
- customerNote?: string;
428
- subtotal: number;
429
- taxTotal: number;
430
- shippingTotal: number;
431
- discountTotal: number;
432
- fulfillmentStatus: FulfillmentStatus;
433
- statusHistory: OrderStatusHistory[];
434
- trackingToken?: string;
435
- /**
436
- * For redirect payment gateways (GoPay, ...), the hosted URL the
437
- * storefront must send the customer to in order to pay. Present only on
438
- * the order returned by `checkout.createOrder()`. Null/absent for
439
- * offline methods (bank transfer, COD) and zero-total orders.
440
- */
441
- paymentRedirectUrl?: string | null;
442
- }
443
- /** Generic response to `orders.requestAccessCode` — never reveals existence. */
444
- interface OrderAccessRequestResponse {
445
- success: boolean;
446
- message: string;
447
- }
448
- /** Response to a successful `orders.verifyAccessCode`. */
449
- interface OrderAccessVerifyResponse {
450
- /** Short-lived JWT scoped to this single order (use with `getByAccessToken`). */
451
- accessToken: string;
452
- /** Token lifetime in seconds. */
453
- expiresIn: number;
454
- order: OrderDetail;
455
- }
456
- interface CustomerProfile {
457
- id: string;
458
- email: string;
459
- firstName?: string;
460
- lastName?: string;
461
- phone?: string;
462
- emailVerified: boolean;
463
- }
464
- interface CustomerAddress {
465
- id: string;
466
- type: AddressType;
467
- isDefault: boolean;
468
- firstName: string;
469
- lastName: string;
470
- company?: string;
471
- street: string;
472
- city: string;
473
- zip: string;
474
- country: string;
475
- phone?: string;
476
- }
477
- interface Page {
478
- slug: string;
479
- title: string;
480
- isActive: boolean;
481
- }
482
- interface PageDetail {
483
- slug: string;
484
- title: string;
485
- content: unknown;
486
- seoTitle?: string;
487
- seoDescription?: string;
488
- /** Downloadable files attached to the page (e.g. legal form PDFs). */
489
- attachments: PageAttachment[];
490
- }
491
- interface PageAttachment {
492
- name: string;
493
- description: string | null;
494
- url: string;
495
- mimeType: string;
496
- fileSize: number;
497
- }
498
- 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";
499
- declare class BehioApiError extends Error {
500
- readonly code: BehioErrorCode;
501
- readonly status: number;
502
- readonly body: unknown;
503
- readonly isRetryable: boolean;
504
- constructor(status: number, body: unknown, message?: string);
505
- static resolveCode(status: number, body: unknown): BehioErrorCode;
506
- /** Check if this is a specific error type */
507
- is(code: BehioErrorCode): boolean;
508
- }
509
- declare class BehioNetworkError extends Error {
510
- readonly code: "NETWORK_ERROR" | "TIMEOUT";
511
- readonly isRetryable = true;
512
- constructor(message: string, isTimeout?: boolean);
513
- }
514
- /**
515
- * Shape every SDK call returns. Destructure `{data, error}` — exactly
516
- * one of them is non-null on any given call. No more try/catch for
517
- * expected failures; the type system forces you to handle `error`
518
- * before touching `data`.
519
- *
520
- * const {data, error} = await behio.catalog.getProduct(slug);
521
- * if (error) return <ErrorState code={error.code} />;
522
- * return <ProductView product={data} />;
523
- */
524
- type SdkResult<T> = {
525
- data: T;
526
- error: null;
527
- } | {
528
- data: null;
529
- error: SdkError;
530
- };
531
- /**
532
- * Canonical error shape returned from every SDK call. Always carries a
533
- * `code` you can branch on without parsing messages.
534
- */
535
- interface SdkError {
536
- /**
537
- * High-level category. `BehioErrorCode` covers API errors; additional
538
- * buckets are network/timeout/abort/unknown.
539
- */
540
- code: BehioErrorCode;
541
- /** Human-readable message (fallback for unknown codes / dev logging). */
542
- message: string;
543
- /** HTTP status, if the error came from the API. Null for network / abort. */
544
- status: number | null;
545
- /** Raw API body, if present. */
546
- body?: unknown;
547
- /** Whether the operation is safe to retry (true for 5xx / 429 / network). */
548
- isRetryable: boolean;
549
- /** Preserves the original thrown instance for stack traces + rethrows. */
550
- cause?: unknown;
551
- }
552
- declare function ok<T>(data: T): SdkResult<T>;
553
- declare function err<T = never>(error: SdkError): SdkResult<T>;
554
- /**
555
- * Converts any thrown value into a canonical SdkError. Used by the
556
- * request wrapper when catching internal throws.
557
- */
558
- declare function toSdkError(err: unknown): SdkError;
559
- 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";
560
- type BehioEventHandler = (data?: unknown) => void;
561
- interface RequestInterceptorConfig {
562
- url: string;
563
- method: string;
564
- headers: Record<string, string>;
565
- body?: string;
566
- }
567
- interface RequestInterceptor {
568
- (config: RequestInterceptorConfig): RequestInterceptorConfig | Promise<RequestInterceptorConfig>;
569
- }
570
- interface ResponseInterceptorData {
571
- status: number;
572
- data: unknown;
573
- headers: Headers;
574
- }
575
- interface ResponseInterceptor {
576
- (response: ResponseInterceptorData): void | Promise<void>;
577
- }
578
- interface BundleItem {
579
- productId: string;
580
- slug: string | null;
581
- name: string;
582
- sku: string;
583
- quantity: number;
584
- imageUrl: string | null;
585
- defaultPrice: number | null;
586
- }
587
- interface Bundle {
588
- id: string;
589
- slug: string;
590
- name: string;
591
- description: string | null;
592
- bundlePrice: number;
593
- currency: string;
594
- coverImage: string | null;
595
- endsAt: number | null;
596
- itemsSum: number;
597
- /** Absolute saving vs buying the components separately, in `currency`. */
598
- savings: number;
599
- /** Percentage saving, 0–100. 0 when `itemsSum` is zero. */
600
- savingsPercent: number;
601
- /** Minimum bundles per order. Default 1. */
602
- minQuantity: number;
603
- /** Maximum bundles per order. `null` = uncapped. */
604
- maxQuantity: number | null;
605
- /** Lifetime stock limit. `null` = uncapped. Once exceeded, add-to-cart fails. */
606
- stockLimit: number | null;
607
- /** Lifetime units sold (materialized counter). Used for "X sold" badges. */
608
- soldCount: number;
609
- items: BundleItem[];
610
- }
611
- /**
612
- * Shape returned by `behio.shipping.listMethods()` — the merchant's
613
- * configured shipping methods filtered by cart currency + destination
614
- * country. Use this for the "always-on" picker; for live quotes, prefer
615
- * `behio.shipping.quote()` which can dispatch to the meta-provider
616
- * (Zaslat, Shippo, …) for a live carrier rate per address.
617
- */
618
- interface ShippingMethodSummary {
619
- id: string;
620
- name: string;
621
- description: string | null;
622
- /** Internal routing id ("zaslat", "ppl_direct", "manual", …). Not for display. */
623
- provider: string;
624
- /** "fixed" = price known upfront; "live_quote" = must call shipping.quote() with address. */
625
- priceStrategy: "fixed" | "live_quote";
626
- currency: string | null;
627
- /** Final customer-facing price. Null for live_quote methods (call quote() to resolve). */
628
- price: number | null;
629
- /** Per-currency base price from the merchant's config. Null for live_quote. */
630
- basePrice: number | null;
631
- isFreeShipping: boolean;
632
- freeShippingThreshold: number | null;
633
- /** "address" | "pickup_point" | "in_store" | "digital". */
634
- deliveryType: string;
635
- supportsPickupPoints: boolean;
636
- etaDaysMin: number | null;
637
- etaDaysMax: number | null;
638
- allowedCountries: string[];
639
- /** Customer-safe config fields the merchant filled in (pickup address, instructions). */
640
- publicConfig: Record<string, unknown>;
641
- }
642
- /**
643
- * Input for `behio.shipping.quote()`. At minimum requires the destination
644
- * country — passing more (zip, weight per item, cart total) lets the
645
- * meta-provider return better-fitting carriers and triggers free-shipping
646
- * thresholds correctly.
647
- */
648
- interface ShippingQuoteInput {
649
- destinationAddress: {
650
- country: string;
651
- zip?: string;
652
- city?: string;
653
- street?: string;
654
- };
655
- items?: Array<{
656
- whItemId: string;
657
- quantity: number;
658
- weightKg?: number;
659
- }>;
660
- cartTotal?: number;
661
- currency?: string;
662
- }
663
- /**
664
- * One option returned by `behio.shipping.quote()`. Methods configured for
665
- * fixed pricing always come back with `available: true` and the merchant's
666
- * configured price. Methods configured for live quoting come back available
667
- * only when the upstream meta-provider returned a rate for the destination
668
- * — otherwise `available: false` with a `reason` (e.g. `"no_rate_returned"`,
669
- * `"live_quote_not_implemented"`). Filter `available: true` in your
670
- * checkout picker.
671
- */
672
- interface ShippingQuote extends ShippingMethodSummary {
673
- /** `"fixed"` uses `pricing` rows; `"live_quote"` came from the upstream provider. */
674
- strategy: "fixed" | "live_quote";
675
- available: boolean;
676
- reason: string | null;
677
- /** Server-generated quote ID. Null for fixed-price methods. Pass to checkout for tamper-proof pricing. */
678
- quoteId: string | null;
679
- /** Quote expiry (epoch ms). Null for fixed-price methods. */
680
- expiresAt: number | null;
681
- }
682
- interface CrossSellItem {
683
- productId: string;
684
- slug: string | null;
685
- name: string;
686
- sku: string;
687
- price: number | null;
688
- imageUrl: string | null;
689
- stockCached: number;
690
- }
691
- interface ActivePromotion {
692
- id: string;
693
- name: string;
694
- slug: string;
695
- type: string;
696
- discountType: string;
697
- discountValue: number;
698
- startsAt: number;
699
- endsAt: number | null;
700
- badgeText: string | null;
701
- badgeColor: string | null;
702
- showCountdown: boolean;
703
- couponRequired: boolean;
704
- }
705
- interface GiftCardBalance {
706
- valid: boolean;
707
- balance: number;
708
- currency: string;
709
- }
710
- interface WishlistItem {
711
- id: string;
712
- productId: string;
713
- productName: string;
714
- productSku: string;
715
- productSlug: string | null;
716
- imageUrl: string | null;
717
- price: number | null;
718
- stockCached: number;
719
- createdAt: number;
720
- }
721
- interface ProductReview {
722
- id: string;
723
- authorName: string;
724
- rating: number;
725
- title: string | null;
726
- content: string | null;
727
- imageUrls: string[];
728
- isVerifiedPurchase: boolean;
729
- helpfulCount: number;
730
- unhelpfulCount: number;
731
- replyContent: string | null;
732
- replyAt: number | null;
733
- createdAt: number;
734
- }
735
- interface ProductReviewsResponse {
736
- reviews: ProductReview[];
737
- total: number;
738
- page: number;
739
- limit: number;
740
- averageRating: number;
741
- reviewCount: number;
742
- }
743
- /** Returned by `catalog.notifyWhenAvailable()` — back-in-stock subscription. */
744
- interface BackInStockSubscription {
745
- id: string;
746
- eshopId: string;
747
- productId: string;
748
- email: string;
749
- createdAt: number;
750
- }
751
- interface SubmitReviewInput {
752
- productId: string;
753
- rating: number;
754
- title?: string;
755
- content?: string;
756
- authorName: string;
757
- authorEmail?: string;
758
- imageUrls?: string[];
759
- }
760
- interface ReturnableOrderItem {
761
- orderItemId: string;
762
- productName: string;
763
- /** Quantity ordered */
764
- quantity: number;
765
- /** Units still returnable (ordered minus active return claims) */
766
- returnableQuantity: number;
767
- }
768
- /**
769
- * Result of the guest order lookup used by the EU withdrawal form:
770
- * the customer enters their order number + email and gets back the
771
- * internal ids needed to submit a return. No account required.
772
- */
773
- interface ReturnableOrder {
774
- orderId: string;
775
- orderNumber: string;
776
- status: string;
777
- items: ReturnableOrderItem[];
778
- createdAt: number;
779
- }
780
- interface ReturnRequestItem {
781
- id: string;
782
- orderItemId: string;
783
- productName: string;
784
- quantity: number;
785
- reason: string | null;
786
- imageUrls: string[];
787
- }
788
- /** Returned by `returns.submit()` — the acknowledged withdrawal request. */
789
- interface ReturnRequest {
790
- id: string;
791
- eshopId: string;
792
- orderId: string;
793
- /** REQUESTED | APPROVED | SHIPPED_BACK | RECEIVED | REFUNDED | REJECTED | CLOSED */
794
- status: string;
795
- reason: string;
796
- customerNote: string | null;
797
- items: ReturnRequestItem[];
798
- createdAt: number;
799
- }
800
- interface ReturnStatusItem {
801
- id: string;
802
- productName: string;
803
- quantity: number;
804
- reason: string | null;
805
- }
806
- /** Returned by `returns.getStatus()` — the full public view of a return. */
807
- interface ReturnStatus {
808
- id: string;
809
- orderNumber: string;
810
- /** REQUESTED | APPROVED | SHIPPED_BACK | RECEIVED | REFUNDED | REJECTED | CLOSED */
811
- status: string;
812
- reason: string;
813
- customerNote: string | null;
814
- refundMethod: string | null;
815
- refundAmount: number | null;
816
- refundedAt: number | null;
817
- returnTrackingNumber: string | null;
818
- items: ReturnStatusItem[];
819
- createdAt: number;
820
- updatedAt: number;
821
- }
822
- interface SubmitReturnInput {
823
- orderId: string;
824
- /**
825
- * Email used on the order. Required — it is the ownership gate for guest
826
- * withdrawals; the backend rejects submissions whose email doesn't match.
827
- */
828
- email: string;
829
- reason: string;
830
- customerNote?: string;
831
- items: {
832
- orderItemId: string;
833
- productName: string;
834
- quantity: number;
835
- reason?: string;
836
- imageUrls?: string[];
837
- }[];
838
- }
839
- interface CookieConsent {
840
- necessary: boolean;
841
- analytics: boolean;
842
- marketing: boolean;
843
- preferences: boolean;
844
- consentedAt: number;
845
- }
846
- interface CookieConsentInput {
847
- visitorId: string;
848
- analytics: boolean;
849
- marketing: boolean;
850
- preferences: boolean;
851
- }
852
- interface QuoteItem {
853
- productId: string;
854
- quantity: number;
855
- requestedPrice: number | null;
856
- quotedPrice: number | null;
857
- }
858
- interface QuoteRequest {
859
- id: string;
860
- /** PENDING | QUOTED | ACCEPTED | REJECTED | EXPIRED */
861
- status: string;
862
- contactName: string;
863
- contactEmail: string;
864
- companyName: string | null;
865
- quotedTotal: number | null;
866
- quotedCurrency: string | null;
867
- quotedNote: string | null;
868
- expiresAt: number | null;
869
- items: QuoteItem[];
870
- createdAt: number;
871
- }
872
- interface SubmitQuoteInput {
873
- contactName: string;
874
- contactEmail: string;
875
- contactPhone?: string;
876
- companyName?: string;
877
- companyIco?: string;
878
- message?: string;
879
- items: {
880
- productId: string;
881
- quantity: number;
882
- requestedPrice?: number;
883
- }[];
884
- }
1
+ export { t as ActivePromotion, J as AddToCartInput, j as AddressDetail, A as AddressSuggestion, a3 as AddressType, a4 as AddressTypes, K as AuthTokens, I as BackInStockSubscription, L as BehioApiError, a5 as BehioErrorCode, a6 as BehioEventHandler, a7 as BehioEventType, a8 as BehioNetworkError, a as BehioStorefront, B as BehioStorefrontConfig, r as Bundle, M as BundleItem, g as Cart, N as CartDiscount, T as CartItem, a9 as CartItemProduct, C as Category, e as CategoryDetail, U as CheckoutAddress, n as CheckoutInput, aa as CheckoutPaymentMethod, D as CookieConsent, E as CookieConsentInput, s as CrossSellItem, i as CustomerAddress, h as CustomerProfile, ab as DataGroupFieldType, F as FilterField, V as FulfillmentStatus, ac as FulfillmentStatuses, G as GiftCardBalance, X as LoginInput, Y as MessageResponse, l as OrderAccessRequestResponse, m as OrderAccessVerifyResponse, k as OrderDetail, Z as OrderItem, O as OrderListItem, _ as OrderStatus, ad as OrderStatusHistory, ae as OrderStatuses, af as OrderTracking, p as Page, ag as PageAttachment, o as PageDetail, b as PaginatedResponse, $ as PaymentStatus, ah as PaymentStatuses, d as ProductDetail, f as ProductLabel, c as ProductListItem, ai as ProductMedia, aj as ProductMediaVariant, a0 as ProductPrice, a1 as ProductReview, u as ProductReviewsResponse, ak as ProductSort, al as ProductSortValue, a2 as ProductVariant, am as ProductVolumePrice, P as ProductsQuery, an as QuoteItem, Q as QuoteRequest, R as RegisterInput, ao as RequestInterceptor, ap as RequestInterceptorConfig, aq as ResponseInterceptor, ar as ResponseInterceptorData, y as ReturnRequest, as as ReturnRequestItem, x as ReturnStatus, at as ReturnStatusItem, w as ReturnableOrder, au as ReturnableOrderItem, av as SdkError, aw as SdkResult, ax as ShippingMethodSummary, ay as ShippingQuote, az as ShippingQuoteInput, S as ShopInfo, q as ShopSeo, H as SubmitQuoteInput, z as SubmitReturnInput, v as SubmitReviewInput, W as WishlistItem, aA as err, aB as ok, aC as toSdkError } from './client-Dy4lLabe.js';
885
2
 
886
- declare class BehioStorefront {
887
- private baseUrl;
888
- private apiKey;
889
- private defaultLocale?;
890
- private defaultCurrency?;
891
- private fetchFn;
892
- private timeout;
893
- private retries;
894
- private retryDelay;
895
- private accessToken?;
896
- private refreshToken?;
897
- private isRefreshing;
898
- private refreshPromise;
899
- private cartSession?;
900
- private listeners;
901
- private requestInterceptors;
902
- private responseInterceptors;
903
- private rateLimitRemaining;
904
- private rateLimitReset;
905
- constructor(config: BehioStorefrontConfig);
906
- readonly catalog: CatalogModule;
907
- readonly auth: AuthModule;
908
- readonly cart: CartModule;
909
- readonly checkout: CheckoutModule;
910
- readonly orders: OrdersModule;
911
- readonly customer: CustomerModule;
912
- readonly pages: PagesModule;
913
- readonly wishlist: WishlistModule;
914
- readonly reviews: ReviewsModule;
915
- readonly returns: ReturnsModule;
916
- readonly consent: ConsentModule;
917
- readonly quotes: QuotesModule;
918
- readonly addresses: AddressModule;
919
- readonly shipping: ShippingModule;
920
- /** Get basic shop info */
921
- getShopInfo(): Promise<SdkResult<ShopInfo>>;
922
- /** Get SEO metadata for the shop homepage in the given locale (defaults to shop default). */
923
- getShopSeo(locale?: string): Promise<SdkResult<ShopSeo>>;
924
- /** Set auth tokens (e.g. from localStorage) */
925
- setTokens(tokens: {
926
- accessToken: string;
927
- refreshToken: string;
928
- }): void;
929
- /** Clear auth tokens */
930
- clearTokens(): void;
931
- /** Get current access token */
932
- getAccessToken(): string | undefined;
933
- /** Get current refresh token */
934
- getRefreshToken(): string | undefined;
935
- /** Set cart session token (e.g. from cookie) */
936
- setCartSession(token: string): void;
937
- /** Get cart session token */
938
- getCartSession(): string | undefined;
939
- /** Clear cart session */
940
- clearCartSession(): void;
941
- /** Subscribe to SDK events. Returns an unsubscribe function. */
942
- on(event: BehioEventType, handler: BehioEventHandler): () => void;
943
- /** @internal Emit an event (fire-and-forget, handler errors are swallowed) */
944
- emit(event: BehioEventType, data?: unknown): void;
945
- /** Add a request interceptor. Returns an unsubscribe function. */
946
- addRequestInterceptor(fn: RequestInterceptor): () => void;
947
- /** Add a response interceptor. Returns an unsubscribe function. */
948
- addResponseInterceptor(fn: ResponseInterceptor): () => void;
949
- /** Get current rate limit info from latest response headers */
950
- getRateLimitInfo(): {
951
- remaining: number | null;
952
- reset: number | null;
953
- };
954
- private handleTokenRefresh;
955
- /**
956
- * Every public module method funnels through here. Internally calls
957
- * `rawRequest` (which throws on failure) and maps thrown errors to
958
- * `SdkError` so the public surface can return `SdkResult<T>`.
959
- *
960
- * @internal — don't call from outside the SDK; use the typed module
961
- * methods (behio.catalog.*, behio.cart.*, …) instead.
962
- */
963
- request<T>(method: string, path: string, options?: {
964
- body?: unknown;
965
- query?: Record<string, string | number | boolean | undefined | string[] | number[]>;
966
- auth?: boolean;
967
- signal?: AbortSignal;
968
- headers?: Record<string, string>;
969
- }): Promise<SdkResult<T>>;
970
- /**
971
- * Throws on failure (API error / network / timeout). Kept private so
972
- * internal auth refresh recursion keeps its existing control flow —
973
- * public callers must go through `request()` which returns Result.
974
- */
975
- private rawRequest;
976
- }
977
- declare class CatalogModule {
978
- private client;
979
- constructor(client: BehioStorefront);
980
- /** List products with filtering, pagination, search */
981
- getProducts(query?: ProductsQuery): Promise<SdkResult<PaginatedResponse<ProductListItem>>>;
982
- /** Get product detail by slug */
983
- getProduct(slug: string, options?: {
984
- locale?: string;
985
- currency?: string;
986
- }): Promise<SdkResult<ProductDetail>>;
987
- /** Get category tree */
988
- getCategories(locale?: string): Promise<SdkResult<{
989
- categories: Category[];
990
- }>>;
991
- /** Get category detail by slug */
992
- getCategory(slug: string, locale?: string): Promise<SdkResult<CategoryDetail>>;
993
- /** Get products in a category */
994
- getCategoryProducts(slug: string, query?: ProductsQuery): Promise<SdkResult<PaginatedResponse<ProductListItem>>>;
995
- /** Get all labels */
996
- getLabels(locale?: string): Promise<SdkResult<{
997
- labels: ProductLabel[];
998
- }>>;
999
- /** Get featured products */
1000
- getFeatured(options?: {
1001
- locale?: string;
1002
- currency?: string;
1003
- }): Promise<SdkResult<PaginatedResponse<ProductListItem>>>;
1004
- /** Get available filter fields for dynamic filter UI */
1005
- getFilters(): Promise<SdkResult<{
1006
- filters: FilterField[];
1007
- }>>;
1008
- /** Search products */
1009
- search(query: string, options?: {
1010
- page?: number;
1011
- limit?: number;
1012
- }): Promise<SdkResult<PaginatedResponse<ProductListItem>>>;
1013
- /** List all active bundles */
1014
- getBundles(): Promise<SdkResult<{
1015
- items: Bundle[];
1016
- }>>;
1017
- /** Get a single bundle by slug */
1018
- getBundle(slug: string): Promise<SdkResult<Bundle>>;
1019
- /** Cross-sell / related / upsell products for a product */
1020
- getCrossSell(productSlug: string): Promise<SdkResult<{
1021
- related: CrossSellItem[];
1022
- upsell: CrossSellItem[];
1023
- crossSell: CrossSellItem[];
1024
- }>>;
1025
- /** Active promotions applicable to a product (with countdown end time) */
1026
- /** Back-in-stock notification subscription for a sold-out product. */
1027
- notifyWhenAvailable(productId: string, email: string): Promise<SdkResult<BackInStockSubscription>>;
1028
- getProductPromotions(productSlug: string): Promise<SdkResult<{
1029
- items: ActivePromotion[];
1030
- }>>;
1031
- /** Check a gift card code — returns validity and remaining balance */
1032
- checkGiftCard(code: string): Promise<SdkResult<GiftCardBalance>>;
1033
- /** List configured payment methods (filtered by currency). */
1034
- listPaymentMethods(opts?: {
1035
- currency?: string;
1036
- }): Promise<SdkResult<{
1037
- items: CheckoutPaymentMethod[];
1038
- }>>;
1039
- }
1040
- declare class AuthModule {
1041
- private client;
1042
- constructor(client: BehioStorefront);
1043
- /** Register a new customer */
1044
- register(input: RegisterInput): Promise<SdkResult<AuthTokens>>;
1045
- /** Login with email and password */
1046
- login(input: LoginInput): Promise<SdkResult<AuthTokens>>;
1047
- /** Refresh access token using refresh token */
1048
- refresh(refreshToken?: string): Promise<SdkResult<AuthTokens>>;
1049
- /** Logout (invalidate refresh token) */
1050
- logout(refreshToken?: string): Promise<SdkResult<MessageResponse>>;
1051
- /** Request password reset email */
1052
- forgotPassword(email: string): Promise<SdkResult<MessageResponse>>;
1053
- /** Reset password with token */
1054
- resetPassword(token: string, newPassword: string): Promise<SdkResult<MessageResponse>>;
1055
- /** Verify email with token */
1056
- verifyEmail(token: string): Promise<SdkResult<MessageResponse>>;
1057
- /** Check if user is logged in (has access token) */
1058
- isLoggedIn(): boolean;
1059
- }
1060
- declare class CartModule {
1061
- private client;
1062
- constructor(client: BehioStorefront);
1063
- /** Get current cart */
1064
- get(): Promise<SdkResult<Cart>>;
1065
- /** Add item to cart */
1066
- addItem(input: AddToCartInput): Promise<SdkResult<Cart & {
1067
- newSessionToken?: string;
1068
- }>>;
1069
- /** Update item quantity */
1070
- updateQuantity(itemId: string, quantity: number): Promise<SdkResult<Cart>>;
1071
- /** Remove item from cart */
1072
- removeItem(itemId: string): Promise<SdkResult<Cart>>;
1073
- /** Clear entire cart */
1074
- clear(): Promise<SdkResult<void>>;
1075
- /** Apply a gift card code to the cart. Balance is deducted at checkout. */
1076
- applyGiftCard(code: string): Promise<SdkResult<Cart>>;
1077
- /** Remove a gift card from the cart */
1078
- removeGiftCard(): Promise<SdkResult<Cart>>;
1079
- /**
1080
- * Add a bundle to the cart. Price is snapshotted at the bundle's current
1081
- * price. Pass either the bundle id or its slug — slug is more ergonomic
1082
- * for static storefront wiring (`behio.cart.addBundle({slug: "morning-set"})`).
1083
- *
1084
- * Respects the bundle's `minQuantity`, `maxQuantity`, and `stockLimit`:
1085
- * the request rejects with HTTP 400 if the resulting cart line would
1086
- * violate any of them. The returned error includes the relevant field
1087
- * (`minQuantity`, `maxQuantity`, or `remaining`) so the storefront can
1088
- * surface a meaningful message.
1089
- *
1090
- * @param identifier Either `{id: bundleId}` or `{slug: bundleSlug}`. As a
1091
- * convenience, passing a plain string is treated as the
1092
- * bundle id for backwards compatibility.
1093
- * @param quantity How many bundles to add (defaults to 1). Capped by
1094
- * the bundle's `maxQuantity` if set.
1095
- */
1096
- addBundle(identifier: string | {
1097
- id: string;
1098
- } | {
1099
- slug: string;
1100
- }, quantity?: number): Promise<SdkResult<Cart>>;
1101
- /** Update quantity of a bundle already in the cart */
1102
- updateBundleQuantity(bundleId: string, quantity: number): Promise<SdkResult<Cart>>;
1103
- /** Remove a bundle from the cart */
1104
- removeBundle(bundleId: string): Promise<SdkResult<Cart>>;
1105
- /** Merge anonymous cart into authenticated customer cart */
1106
- merge(): Promise<SdkResult<Cart>>;
1107
- /** Apply discount code */
1108
- applyDiscount(code: string): Promise<SdkResult<Cart>>;
1109
- /** Remove discount code */
1110
- removeDiscount(): Promise<SdkResult<Cart>>;
1111
- }
1112
- declare class CheckoutModule {
1113
- private client;
1114
- constructor(client: BehioStorefront);
1115
- /** Create order from cart */
1116
- createOrder(input: CheckoutInput): Promise<SdkResult<OrderDetail>>;
1117
- }
1118
- declare class OrdersModule {
1119
- private client;
1120
- constructor(client: BehioStorefront);
1121
- /** List customer orders (requires auth) */
1122
- list(options?: {
1123
- page?: number;
1124
- limit?: number;
1125
- }): Promise<SdkResult<PaginatedResponse<OrderListItem>>>;
1126
- /** Get order detail (requires auth) */
1127
- get(orderNumber: string): Promise<SdkResult<OrderDetail>>;
1128
- /** Cancel a PENDING order (requires auth) */
1129
- cancel(orderNumber: string): Promise<SdkResult<OrderDetail>>;
1130
- /**
1131
- * Track an order by tracking token (no login, only API key). Returns a
1132
- * PII-minimized view: order status + items + masked email + destination
1133
- * city, never full address / phone / billing — the token travels in URLs
1134
- * and e-mails so it must not expose full personal data.
1135
- */
1136
- track(trackingToken: string): Promise<SdkResult<OrderTracking>>;
1137
- /**
1138
- * Step 1 of guest order-access: request a 6-digit code e-mailed to the
1139
- * address on the order. The response is always generic (success) regardless
1140
- * of whether the order number + e-mail match, so order numbers can't be
1141
- * enumerated. No login, only API key.
1142
- */
1143
- requestAccessCode(orderNumber: string, email: string): Promise<SdkResult<OrderAccessRequestResponse>>;
1144
- /**
1145
- * Step 2 of guest order-access: verify the e-mailed code. On success returns
1146
- * the FULL order detail plus a short-lived `accessToken` you can pass to
1147
- * {@link getByAccessToken} to re-fetch the detail without re-entering the
1148
- * code. No login, only API key.
1149
- */
1150
- verifyAccessCode(orderNumber: string, email: string, code: string): Promise<SdkResult<OrderAccessVerifyResponse>>;
1151
- /**
1152
- * Re-fetch a guest order's full detail using the `accessToken` returned by
1153
- * {@link verifyAccessCode}. The token is scoped to that single order and
1154
- * expires after 30 minutes.
1155
- */
1156
- getByAccessToken(accessToken: string): Promise<SdkResult<OrderDetail>>;
1157
- }
1158
- declare class CustomerModule {
1159
- private client;
1160
- constructor(client: BehioStorefront);
1161
- /** Get customer profile */
1162
- getProfile(): Promise<SdkResult<CustomerProfile>>;
1163
- /** Update customer profile */
1164
- updateProfile(data: Partial<Pick<CustomerProfile, "firstName" | "lastName" | "phone">>): Promise<SdkResult<CustomerProfile>>;
1165
- /** Change password */
1166
- changePassword(currentPassword: string, newPassword: string): Promise<SdkResult<MessageResponse>>;
1167
- /** List addresses */
1168
- getAddresses(): Promise<SdkResult<{
1169
- items: CustomerAddress[];
1170
- }>>;
1171
- /** Create address */
1172
- createAddress(address: Omit<CustomerAddress, "id">): Promise<SdkResult<CustomerAddress>>;
1173
- /** Update address */
1174
- updateAddress(addressId: string, data: Partial<CustomerAddress>): Promise<SdkResult<CustomerAddress>>;
1175
- /** Delete address */
1176
- deleteAddress(addressId: string): Promise<SdkResult<void>>;
1177
- }
1178
- declare class PagesModule {
1179
- private client;
1180
- constructor(client: BehioStorefront);
1181
- /** List CMS pages */
1182
- list(locale?: string): Promise<SdkResult<{
1183
- pages: Page[];
1184
- }>>;
1185
- /** Get page by slug */
1186
- get(slug: string, locale?: string): Promise<SdkResult<PageDetail>>;
1187
- }
1188
- declare class WishlistModule {
1189
- private client;
1190
- constructor(client: BehioStorefront);
1191
- get(): Promise<SdkResult<{
1192
- items: WishlistItem[];
1193
- }>>;
1194
- add(productId: string): Promise<SdkResult<{
1195
- success: boolean;
1196
- }>>;
1197
- remove(productId: string): Promise<SdkResult<{
1198
- success: boolean;
1199
- }>>;
1200
- isInWishlist(productId: string): Promise<SdkResult<{
1201
- inWishlist: boolean;
1202
- }>>;
1203
- }
1204
- declare class ReviewsModule {
1205
- private client;
1206
- constructor(client: BehioStorefront);
1207
- getProductReviews(productId: string, page?: number, limit?: number): Promise<SdkResult<ProductReviewsResponse>>;
1208
- submit(input: SubmitReviewInput): Promise<SdkResult<{
1209
- id: string;
1210
- }>>;
1211
- voteHelpful(reviewId: string, helpful: boolean): Promise<SdkResult<{
1212
- success: boolean;
1213
- }>>;
1214
- }
1215
- declare class ReturnsModule {
1216
- private client;
1217
- constructor(client: BehioStorefront);
1218
- /**
1219
- * Guest order lookup for the EU withdrawal form: order number + the email
1220
- * used on the order resolve to the order id and per-item returnable
1221
- * quantities. POST so the email never appears in a URL.
1222
- */
1223
- lookupOrder(orderNumber: string, email: string): Promise<SdkResult<ReturnableOrder>>;
1224
- submit(input: SubmitReturnInput): Promise<SdkResult<ReturnRequest>>;
1225
- /** Email is the ownership gate; POST so it never lands in a URL / log. */
1226
- getStatus(returnId: string, email: string): Promise<SdkResult<ReturnStatus>>;
1227
- }
1228
- declare class ConsentModule {
1229
- private client;
1230
- constructor(client: BehioStorefront);
1231
- record(input: CookieConsentInput): Promise<SdkResult<CookieConsent>>;
1232
- get(visitorId: string): Promise<SdkResult<CookieConsent | null>>;
1233
- revoke(visitorId: string): Promise<SdkResult<{
1234
- success: boolean;
1235
- }>>;
1236
- }
1237
- declare class QuotesModule {
1238
- private client;
1239
- constructor(client: BehioStorefront);
1240
- submit(input: SubmitQuoteInput): Promise<SdkResult<QuoteRequest>>;
1241
- accept(quoteId: string, email: string): Promise<SdkResult<QuoteRequest>>;
1242
- /** Email is the ownership gate — quotes carry contact PII and negotiated
1243
- * prices, so the id alone is never enough. POST keeps it out of URLs. */
1244
- getStatus(quoteId: string, email: string): Promise<SdkResult<QuoteRequest>>;
1245
- }
1246
- interface AddressSuggestion {
1247
- placeId: string;
1248
- description: string;
1249
- street: string;
1250
- city: string;
1251
- zip: string;
1252
- country: string;
1253
- countryCode: string;
1254
- }
1255
- interface AddressDetail {
1256
- street: string;
1257
- streetNumber: string;
1258
- city: string;
1259
- zip: string;
1260
- country: string;
1261
- countryCode: string;
1262
- formattedAddress: string;
1263
- lat: number;
1264
- lng: number;
1265
- }
1266
- declare class AddressModule {
1267
- private client;
1268
- constructor(client: BehioStorefront);
1269
- /** Search for address suggestions (debounce on your side, or use the React hook) */
1270
- autocomplete(query: string, country: string): Promise<SdkResult<{
1271
- suggestions: AddressSuggestion[];
1272
- }>>;
1273
- /** Get full structured address from a suggestion's placeId */
1274
- getDetail(placeId: string): Promise<SdkResult<AddressDetail>>;
1275
- }
1276
3
  /**
1277
- * Storefront shipping module list configured methods and fetch live
1278
- * quotes for a destination + cart. Use `listMethods` for the always-on
1279
- * picker (sidebar, info page) and `quote` once the customer enters a
1280
- * destination address so live-quote providers (Zaslat etc.) can return
1281
- * destination-specific prices.
4
+ * Format a price amount with currency using Intl.NumberFormat.
5
+ *
6
+ * @param amount - The price amount (e.g. 1499, 24.99)
7
+ * @param currency - ISO 4217 currency code (e.g. "CZK", "EUR", "USD")
8
+ * @param locale - BCP 47 locale string (e.g. "cs", "en", "de"). Defaults to "cs".
9
+ * @returns Formatted price string (e.g. "1 499 Kč", "24,99 €")
1282
10
  */
1283
- declare class ShippingModule {
1284
- private client;
1285
- constructor(client: BehioStorefront);
1286
- /**
1287
- * Return the configured shipping methods that pass the current
1288
- * currency + country filter. Fixed-price methods come back with
1289
- * their `pricing[]` row resolved; live-quote methods come back with
1290
- * `price` 0 here — call `quote()` to get the real live price.
1291
- */
1292
- listMethods(opts?: {
1293
- currency?: string;
1294
- country?: string;
1295
- cartTotal?: number;
1296
- cartWeightKg?: number;
1297
- }): Promise<SdkResult<{
1298
- items: ShippingMethodSummary[];
1299
- }>>;
1300
- /**
1301
- * Quote shipping for a destination address + cart contents. Each
1302
- * configured method is evaluated:
1303
- * - `priceStrategy="fixed"` → resolved from the merchant's per-currency
1304
- * `pricing[]` rows + free-shipping threshold check.
1305
- * - `priceStrategy="live_quote"` → dispatched to the upstream
1306
- * meta-provider (Zaslat, future Shippo / Sendcloud / …) and run
1307
- * through the merchant's markup/rounding rules.
1308
- *
1309
- * Filter `available: true` for the checkout picker; `available: false`
1310
- * rows carry a `reason` (`"no_rate_returned"`, `"live_quote_not_implemented"`,
1311
- * …) you can log but should not display.
1312
- */
1313
- quote(input: ShippingQuoteInput): Promise<SdkResult<{
1314
- items: ShippingQuote[];
1315
- }>>;
1316
- }
11
+ declare function formatPrice(amount: number, currency: string, locale?: string): string;
1317
12
 
1318
- export { type ActivePromotion, type AddToCartInput, type AddressDetail, type AddressSuggestion, type AddressType, AddressTypes, type AuthTokens, type BackInStockSubscription, BehioApiError, type BehioErrorCode, type BehioEventHandler, type BehioEventType, BehioNetworkError, BehioStorefront, type BehioStorefrontConfig, type Bundle, type BundleItem, type Cart, type CartDiscount, type CartItem, type CartItemProduct, type Category, type CategoryDetail, type CheckoutAddress, type CheckoutInput, type CheckoutPaymentMethod, type CookieConsent, type CookieConsentInput, type CrossSellItem, type CustomerAddress, type CustomerProfile, type DataGroupFieldType, type FilterField, type FulfillmentStatus, FulfillmentStatuses, type GiftCardBalance, type LoginInput, type MessageResponse, type OrderAccessRequestResponse, type OrderAccessVerifyResponse, type OrderDetail, type OrderItem, type OrderListItem, type OrderStatus, type OrderStatusHistory, OrderStatuses, type OrderTracking, type Page, type PageAttachment, type PageDetail, type PaginatedResponse, type PaymentStatus, PaymentStatuses, type ProductDetail, type ProductLabel, type ProductListItem, type ProductMedia, type ProductMediaVariant, type ProductPrice, type ProductReview, type ProductReviewsResponse, ProductSort, type ProductSortValue, type ProductVariant, type ProductVolumePrice, type ProductsQuery, type QuoteItem, type QuoteRequest, type RegisterInput, type RequestInterceptor, type RequestInterceptorConfig, type ResponseInterceptor, type ResponseInterceptorData, type ReturnRequest, type ReturnRequestItem, type ReturnStatus, type ReturnStatusItem, type ReturnableOrder, type ReturnableOrderItem, type SdkError, type SdkResult, type ShippingMethodSummary, type ShippingQuote, type ShippingQuoteInput, type ShopInfo, type ShopSeo, type SubmitQuoteInput, type SubmitReturnInput, type SubmitReviewInput, type WishlistItem, err, ok, toSdkError };
13
+ export { formatPrice };