@shoppexio/storefront 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,901 @@
1
+ import { NavigationMenuSlot } from '@shoppex/contracts/navigation';
2
+ export { NavigationMenuSlot } from '@shoppex/contracts/navigation';
3
+
4
+ /**
5
+ * SDK Configuration Types
6
+ */
7
+ interface ShoppexConfig {
8
+ storeSlug: string;
9
+ locale?: string;
10
+ currency?: string;
11
+ apiBaseUrl?: string;
12
+ checkoutBaseUrl?: string;
13
+ }
14
+ interface ShoppexInitOptions {
15
+ locale?: string;
16
+ currency?: string;
17
+ apiBaseUrl?: string;
18
+ checkoutBaseUrl?: string;
19
+ }
20
+
21
+ /**
22
+ * API Response Types
23
+ *
24
+ * Backend returns: { status: number, data: T, error: string | null }
25
+ * SDK maps to: { success: boolean, data?: T, message?: string }
26
+ */
27
+ interface ApiResponse<T> {
28
+ status: number;
29
+ data: T;
30
+ error: string | null;
31
+ }
32
+ interface SDKResponse<T> {
33
+ success: boolean;
34
+ data?: T;
35
+ message?: string;
36
+ }
37
+ interface Shop {
38
+ id: string;
39
+ name: string;
40
+ slug: string;
41
+ domain?: string;
42
+ description?: string;
43
+ title?: string;
44
+ message?: string;
45
+ url?: string;
46
+ logo?: string;
47
+ banner?: string;
48
+ avatar?: string;
49
+ average_score?: number | null;
50
+ rating?: number | null;
51
+ products_sold_count?: number;
52
+ hide_products_sold?: boolean;
53
+ currency: string;
54
+ tos_enabled?: boolean;
55
+ dark_mode?: boolean;
56
+ search_enabled?: boolean;
57
+ sort_enabled?: boolean;
58
+ cart_enabled?: boolean;
59
+ hide_out_of_stock?: boolean;
60
+ hide_stock_counter?: boolean;
61
+ center_product_titles?: boolean;
62
+ center_group_titles?: boolean;
63
+ default_sort?: string;
64
+ social?: Record<string, string | null>;
65
+ discord_link?: string | null;
66
+ twitter_link?: string | null;
67
+ instagram_link?: string | null;
68
+ facebook_link?: string | null;
69
+ telegram_link?: string | null;
70
+ youtube_link?: string | null;
71
+ reddit_link?: string | null;
72
+ tiktok_link?: string | null;
73
+ verified?: boolean;
74
+ on_hold?: boolean;
75
+ theme?: ShopTheme | null;
76
+ builder_settings?: Record<string, unknown> | null;
77
+ feedback?: ShopFeedback;
78
+ trusted_checks?: TrustedChecks | null;
79
+ }
80
+ interface ShopTheme {
81
+ primary_color?: string;
82
+ secondary_color?: string;
83
+ font?: string;
84
+ logo?: string | null;
85
+ logo_cloudflare_image_id?: string | null;
86
+ background_image?: string | null;
87
+ background_image_cloudflare_image_id?: string | null;
88
+ cards_in_row?: number | string;
89
+ cards_align?: string;
90
+ card_animation?: string;
91
+ dark_color?: string;
92
+ light_color?: string;
93
+ border_color?: string;
94
+ button_color?: string;
95
+ }
96
+ interface ShopFeedback {
97
+ positive: number;
98
+ neutral: number;
99
+ negative: number;
100
+ total: number;
101
+ }
102
+ interface TrustedChecks {
103
+ identity_verified?: boolean;
104
+ feedback_score?: string | null;
105
+ trusted_score?: number;
106
+ sales_last14days_metric?: string;
107
+ }
108
+ interface ProductCategory {
109
+ uniqid: string;
110
+ title: string;
111
+ description?: string | null;
112
+ image_attachment?: string | null;
113
+ image_name?: string | null;
114
+ image_storage?: string | null;
115
+ cloudflare_image_id?: string | null;
116
+ cdn_image_url?: string | null;
117
+ }
118
+ interface Product {
119
+ id?: string;
120
+ uniqid: string;
121
+ title: string;
122
+ slug?: string | null;
123
+ description?: string | null;
124
+ product_highlights?: string[];
125
+ price: string;
126
+ price_display?: string;
127
+ price_discount?: number;
128
+ currency: string;
129
+ stock?: number;
130
+ quantity_min?: number;
131
+ quantity_max?: number;
132
+ min_quantity?: number;
133
+ max_quantity?: number;
134
+ on_hold?: boolean | number;
135
+ unlisted?: boolean | number;
136
+ private?: boolean | number;
137
+ bestseller?: boolean | number;
138
+ type?: string;
139
+ subtype?: string | null;
140
+ isSubscription?: boolean;
141
+ isGroup?: boolean;
142
+ images: ProductImage[];
143
+ image_name?: string | null;
144
+ image_storage?: string | null;
145
+ cloudflare_image_id?: string | null;
146
+ image_attachment?: string | null;
147
+ sold_count?: number;
148
+ soldCount?: number;
149
+ image_attachments?: unknown[];
150
+ file_attachments?: unknown[];
151
+ variants?: ProductVariant[];
152
+ addons?: ProductAddon[];
153
+ price_variants?: PriceVariant[];
154
+ volume_discounts?: unknown;
155
+ custom_fields?: string | unknown[] | null;
156
+ categories?: ProductCategory[];
157
+ bundles?: ProductBundle[];
158
+ faqs?: ProductFaq[];
159
+ subscription?: Subscription;
160
+ feedbacks?: Feedback[];
161
+ feedback?: ProductFeedback;
162
+ cdn_image_url?: string;
163
+ recurring_interval?: string | null;
164
+ recurring_interval_count?: number | null;
165
+ trial_period?: number | null;
166
+ setup_cost?: string;
167
+ licensing_enabled?: boolean | number;
168
+ license_period?: number | null;
169
+ gateways?: string;
170
+ delivery_text?: string;
171
+ service_text?: string;
172
+ terms_of_service?: string | null;
173
+ warranty?: number;
174
+ warranty_text?: string | null;
175
+ sort_priority?: number;
176
+ price_conversions?: Record<string, number>;
177
+ pay_what_you_want?: boolean | number;
178
+ cost?: string | null;
179
+ cost_display?: string | null;
180
+ }
181
+ interface ProductFeedback {
182
+ total: number;
183
+ positive: number;
184
+ neutral: number;
185
+ negative: number;
186
+ numbers?: Record<number, number>;
187
+ list?: Array<{
188
+ score: number;
189
+ message: string | null;
190
+ reply: string | null;
191
+ created_at: string | null;
192
+ updated_at: string | null;
193
+ }>;
194
+ }
195
+ interface ProductImage {
196
+ id: string;
197
+ url: string;
198
+ cloudflare_image_id?: string;
199
+ alt?: string;
200
+ }
201
+ interface ProductVariant {
202
+ id: string;
203
+ title: string;
204
+ price?: number;
205
+ stock?: number;
206
+ }
207
+ interface ProductAddon {
208
+ id: string;
209
+ name?: string;
210
+ title?: string;
211
+ price: number;
212
+ required?: boolean;
213
+ }
214
+ interface PriceVariant {
215
+ id: string;
216
+ label?: string;
217
+ title?: string;
218
+ price: number;
219
+ }
220
+ interface CustomFieldDefinition {
221
+ id: string;
222
+ name: string;
223
+ type: 'text' | 'textarea' | 'select' | 'checkbox';
224
+ required?: boolean;
225
+ options?: string[];
226
+ }
227
+ interface Feedback {
228
+ id: string;
229
+ rating: number;
230
+ author?: string;
231
+ comment?: string;
232
+ is_automated?: boolean;
233
+ created_at: string;
234
+ }
235
+ interface ProductBundle {
236
+ id?: string;
237
+ uniqid?: string;
238
+ title?: string;
239
+ discount_type?: 'PERCENTAGE' | 'FIXED';
240
+ discount_amount?: number;
241
+ products?: Product[];
242
+ }
243
+ interface ProductFaq {
244
+ id?: string;
245
+ uniqid?: string;
246
+ question: string;
247
+ answer: string;
248
+ }
249
+ interface SubscriptionInterval {
250
+ unit?: string;
251
+ count?: number;
252
+ label?: string;
253
+ }
254
+ interface SubscriptionFlags {
255
+ cancel_anytime?: boolean;
256
+ }
257
+ interface Subscription {
258
+ id?: string;
259
+ name?: string;
260
+ description?: string;
261
+ badge?: string;
262
+ interval?: SubscriptionInterval;
263
+ flags?: SubscriptionFlags;
264
+ }
265
+ interface Invoice {
266
+ uniqid: string;
267
+ status: string;
268
+ total: number;
269
+ currency: string;
270
+ gateway?: string;
271
+ products: InvoiceProduct[];
272
+ created_at: string;
273
+ }
274
+ interface InvoiceProduct {
275
+ product_id: string;
276
+ title: string;
277
+ quantity: number;
278
+ price: number;
279
+ }
280
+ interface CouponValidation {
281
+ valid: boolean;
282
+ discount?: number;
283
+ discount_type?: 'percentage' | 'fixed';
284
+ message?: string;
285
+ }
286
+ interface ProductGroup {
287
+ id?: string;
288
+ uniqid: string;
289
+ category_id?: string | null;
290
+ slug?: string | null;
291
+ name?: string | null;
292
+ title: string;
293
+ description?: string | null;
294
+ products_bound?: Product[];
295
+ products_count?: number;
296
+ image_attachment?: string | null;
297
+ image_name?: string | null;
298
+ image_storage?: string | null;
299
+ cloudflare_image_id?: string | null;
300
+ cdn_image_url?: string | null;
301
+ sort_priority?: number | null;
302
+ }
303
+ interface Category {
304
+ uniqid: string;
305
+ title: string;
306
+ description?: string | null;
307
+ image_attachment?: string | null;
308
+ image_name?: string | null;
309
+ image_storage?: string | null;
310
+ cloudflare_image_id?: string | null;
311
+ cdn_image_url?: string | null;
312
+ products_bound?: Product[];
313
+ products_count?: number;
314
+ groups_bound?: ProductGroup[];
315
+ groups_count?: number;
316
+ }
317
+ interface StorefrontAnnouncementBarAddon {
318
+ id: string;
319
+ type: 'announcement_bar';
320
+ slot: string;
321
+ component: 'announcement_bar';
322
+ sort_order: number;
323
+ props: {
324
+ addon_id: string;
325
+ text: string;
326
+ link_label?: string | null;
327
+ link_url?: string | null;
328
+ dismissible: boolean;
329
+ display_mode: 'static' | 'marquee';
330
+ theme_preset: 'brand_blue' | 'emerald' | 'sunset' | 'rose' | 'charcoal' | 'custom';
331
+ animation_speed_seconds: number;
332
+ background_color: string;
333
+ text_color: string;
334
+ };
335
+ }
336
+ interface StorefrontCountdownBarAddon {
337
+ id: string;
338
+ type: 'countdown_bar';
339
+ slot: string;
340
+ component: 'countdown_bar';
341
+ sort_order: number;
342
+ props: {
343
+ addon_id: string;
344
+ text: string;
345
+ end_at: string;
346
+ link_label?: string | null;
347
+ link_url?: string | null;
348
+ dismissible: boolean;
349
+ theme_preset: 'brand_blue' | 'emerald' | 'sunset' | 'rose' | 'charcoal' | 'custom';
350
+ expired_behavior: 'hide' | 'message';
351
+ expired_message?: string | null;
352
+ density: 'compact' | 'comfortable';
353
+ cta_style: 'subtle' | 'outline' | 'solid';
354
+ timer_style: 'minimal' | 'boxed';
355
+ background_color: string;
356
+ text_color: string;
357
+ };
358
+ }
359
+ interface StorefrontPromoInfoCardAddon {
360
+ id: string;
361
+ type: 'promo_info_card';
362
+ slot: string;
363
+ component: 'promo_info_card';
364
+ sort_order: number;
365
+ props: {
366
+ addon_id: string;
367
+ eyebrow?: string | null;
368
+ title: string;
369
+ body: string;
370
+ link_label?: string | null;
371
+ link_url?: string | null;
372
+ theme_preset: 'indigo' | 'emerald' | 'amber' | 'rose' | 'slate' | 'custom';
373
+ layout_style: 'compact' | 'feature' | 'alert';
374
+ density: 'compact' | 'comfortable';
375
+ cta_style: 'subtle' | 'outline' | 'solid';
376
+ icon: 'sparkles' | 'megaphone' | 'gift' | 'truck' | 'shield' | 'support' | 'none';
377
+ icon_visibility: 'show' | 'hide';
378
+ background_color: string;
379
+ text_color: string;
380
+ accent_color: string;
381
+ };
382
+ }
383
+ interface StorefrontRecentPurchasePopupAddon {
384
+ id: string;
385
+ type: 'recent_purchase_popup';
386
+ slot: string;
387
+ component: 'recent_purchase_popup';
388
+ sort_order: number;
389
+ props: {
390
+ addon_id: string;
391
+ title: string;
392
+ cooldown_seconds: number;
393
+ items: Array<{
394
+ customer_label: string;
395
+ product_title: string;
396
+ created_at: string;
397
+ }>;
398
+ };
399
+ }
400
+ interface StorefrontCouponPopupModalAddon {
401
+ id: string;
402
+ type: 'coupon_popup_modal';
403
+ slot: string;
404
+ component: 'coupon_popup_modal';
405
+ sort_order: number;
406
+ props: {
407
+ addon_id: string;
408
+ eyebrow?: string | null;
409
+ title: string;
410
+ body: string;
411
+ coupon_code: string;
412
+ primary_button_label: string;
413
+ secondary_button_label: string;
414
+ disclaimer?: string | null;
415
+ theme_preset: 'midnight' | 'ocean' | 'ember' | 'forest' | 'custom';
416
+ trigger: 'delay' | 'exit_intent';
417
+ delay_seconds: number;
418
+ show_once_per_session: boolean;
419
+ reminder_hours: number;
420
+ background_color: string;
421
+ text_color: string;
422
+ accent_color: string;
423
+ };
424
+ }
425
+ type StorefrontAddon = StorefrontAnnouncementBarAddon | StorefrontCountdownBarAddon | StorefrontPromoInfoCardAddon | StorefrontRecentPurchasePopupAddon | StorefrontCouponPopupModalAddon;
426
+ interface StorefrontAddonBootstrap {
427
+ items: StorefrontAddon[];
428
+ }
429
+ type StorefrontItem = (Product & {
430
+ item_type: 'PRODUCT';
431
+ }) | (ProductGroup & {
432
+ item_type: 'GROUP';
433
+ });
434
+ interface StorefrontData {
435
+ shop: Shop;
436
+ products: Product[];
437
+ groups: ProductGroup[];
438
+ items: StorefrontItem[];
439
+ categories: Category[];
440
+ addons: StorefrontAddonBootstrap;
441
+ }
442
+ interface Page {
443
+ id: string;
444
+ shop_id?: string;
445
+ slug: string;
446
+ name: string;
447
+ content: string | null;
448
+ template_type: string;
449
+ is_system: boolean;
450
+ settings: Record<string, unknown> | null;
451
+ visible_after: string | null;
452
+ created_at: number;
453
+ updated_at: number;
454
+ }
455
+ interface Menu {
456
+ id: string;
457
+ shop_id: string;
458
+ title: string;
459
+ slot?: NavigationMenuSlot | null;
460
+ items?: MenuItem[];
461
+ created_at: number;
462
+ updated_at: number;
463
+ }
464
+ interface MenuItem {
465
+ id: string;
466
+ shop_id?: string;
467
+ menu_id: string;
468
+ page_id: string | null;
469
+ title: string;
470
+ url?: string | null;
471
+ link_type?: 'link' | 'page';
472
+ target?: '_self' | '_blank' | null;
473
+ sort_order: number;
474
+ page_slug: string | null;
475
+ created_at: number;
476
+ updated_at: number;
477
+ }
478
+
479
+ /**
480
+ * Cart Types
481
+ *
482
+ * Extended cart schema supporting Shoppex features:
483
+ * - Addons (express shipping, gift wrap, etc.)
484
+ * - Custom Fields (engraving, gift message, etc.)
485
+ * - Price Variants (different pricing tiers)
486
+ *
487
+ * All fields use snake_case to match API conventions.
488
+ */
489
+ interface CartAddon {
490
+ id: string;
491
+ quantity?: number;
492
+ }
493
+ interface CartItem {
494
+ product_id: string;
495
+ variant_id: string;
496
+ quantity: number;
497
+ addons?: CartAddon[];
498
+ custom_fields?: Record<string, string>;
499
+ price_variant_id?: string;
500
+ price_data?: {
501
+ unit_price: number;
502
+ };
503
+ }
504
+ interface CartAddOptions {
505
+ addons?: CartAddon[];
506
+ custom_fields?: Record<string, string>;
507
+ price_variant_id?: string;
508
+ price_data?: {
509
+ unit_price: number;
510
+ };
511
+ }
512
+ interface CartPayload {
513
+ store_slug: string;
514
+ items: CartItem[];
515
+ coupon?: string;
516
+ }
517
+ interface CartMetadata {
518
+ created_at: number;
519
+ last_modified: number;
520
+ version: number;
521
+ checksum: string;
522
+ }
523
+ interface CartStats {
524
+ item_count: number;
525
+ total_quantity: number;
526
+ last_modified: number;
527
+ version: number;
528
+ has_backup: boolean;
529
+ integrity_valid: boolean;
530
+ total_price: number;
531
+ total_price_is_estimate: boolean;
532
+ }
533
+
534
+ /**
535
+ * SDK Configuration Management
536
+ */
537
+
538
+ declare function getConfig(): ShoppexConfig;
539
+ declare function isInitialized(): boolean;
540
+
541
+ /**
542
+ * SDK Error Classes
543
+ */
544
+ declare class ShoppexError extends Error {
545
+ readonly code: string;
546
+ readonly statusCode?: number;
547
+ constructor(message: string, code: string, statusCode?: number);
548
+ }
549
+ declare class NotInitializedError extends ShoppexError {
550
+ constructor();
551
+ }
552
+ declare class NetworkError extends ShoppexError {
553
+ constructor(message: string, statusCode?: number);
554
+ }
555
+ declare class ValidationError extends ShoppexError {
556
+ readonly invalidFields?: string[];
557
+ constructor(message: string, invalidFields?: string[]);
558
+ }
559
+ declare class CartError extends ShoppexError {
560
+ constructor(message: string);
561
+ }
562
+
563
+ /**
564
+ * Theme configuration types (framework agnostic)
565
+ */
566
+ type SettingFieldType = 'color' | 'text' | 'range' | 'select' | 'boolean' | 'image' | 'font' | 'richtext' | 'products' | 'images';
567
+ interface BaseSettingField {
568
+ type: SettingFieldType;
569
+ label: string;
570
+ description?: string;
571
+ }
572
+ interface ColorField extends BaseSettingField {
573
+ type: 'color';
574
+ default: string;
575
+ }
576
+ interface RangeField extends BaseSettingField {
577
+ type: 'range';
578
+ default: number;
579
+ min: number;
580
+ max: number;
581
+ step?: number;
582
+ unit?: string;
583
+ }
584
+ interface SelectField extends BaseSettingField {
585
+ type: 'select';
586
+ default: string;
587
+ options: string[] | {
588
+ value: string;
589
+ label: string;
590
+ }[];
591
+ }
592
+ interface BooleanField extends BaseSettingField {
593
+ type: 'boolean';
594
+ default: boolean;
595
+ }
596
+ interface TextField extends BaseSettingField {
597
+ type: 'text';
598
+ default: string;
599
+ }
600
+ interface ImageField extends BaseSettingField {
601
+ type: 'image';
602
+ default: string | null;
603
+ }
604
+ interface FontField extends BaseSettingField {
605
+ type: 'font';
606
+ default: string;
607
+ options?: string[];
608
+ }
609
+ interface RichtextField extends BaseSettingField {
610
+ type: 'richtext';
611
+ default: string;
612
+ }
613
+ interface ProductsField extends BaseSettingField {
614
+ type: 'products';
615
+ default: string[];
616
+ max?: number;
617
+ }
618
+ interface ImagesField extends BaseSettingField {
619
+ type: 'images';
620
+ default: string[];
621
+ max?: number;
622
+ }
623
+ type SettingField = ColorField | RangeField | SelectField | BooleanField | TextField | ImageField | FontField | RichtextField | ProductsField | ImagesField;
624
+ interface SectionDefinition {
625
+ name: string;
626
+ description?: string;
627
+ icon?: string;
628
+ settings: Record<string, SettingField>;
629
+ }
630
+ interface ThemeConfig {
631
+ id: string;
632
+ name: string;
633
+ description?: string;
634
+ version: string;
635
+ author?: string;
636
+ preview?: string;
637
+ settings: Record<string, Record<string, SettingField>>;
638
+ sections: Record<string, SectionDefinition>;
639
+ }
640
+ type SettingValue = string | number | boolean | null | string[] | Record<string, unknown>;
641
+ type ResolvedThemeSettings = {
642
+ [Category: string]: {
643
+ [Key: string]: SettingValue;
644
+ };
645
+ };
646
+
647
+ /**
648
+ * Store Module
649
+ *
650
+ * API methods for store data.
651
+ */
652
+
653
+ declare function getStore(): Promise<SDKResponse<Shop>>;
654
+ declare function resolveStoreByDomain(domain?: string, apiBaseUrl?: string): Promise<SDKResponse<Shop>>;
655
+ declare function getStorefront(): Promise<SDKResponse<StorefrontData>>;
656
+ declare function getStoreLogoUrl(): Promise<string | null>;
657
+ declare function getStoreBannerUrl(): Promise<string | null>;
658
+
659
+ /**
660
+ * Products Module
661
+ *
662
+ * API methods for product data.
663
+ */
664
+
665
+ declare function getProducts(): Promise<SDKResponse<Product[]>>;
666
+ declare function getProduct(idOrSlug: string): Promise<SDKResponse<Product>>;
667
+ declare function getCategories(): Promise<SDKResponse<string[]>>;
668
+
669
+ /**
670
+ * Cart Module
671
+ *
672
+ * localStorage-based cart with support for Shoppex features:
673
+ * - Addons (express shipping, gift wrap, etc.)
674
+ * - Custom Fields (engraving, gift message, etc.)
675
+ * - Price Variants (different pricing tiers)
676
+ */
677
+
678
+ declare function getCart(): CartItem[];
679
+ declare function getCartItemCount(): number;
680
+ declare function addToCart(productId: string, variantId: string, quantity?: number, options?: CartAddOptions): void;
681
+ declare function updateCartItem(productId: string, variantId: string, updates: Partial<Omit<CartItem, 'product_id' | 'variant_id'>>): void;
682
+ declare function removeFromCart(productId: string, variantId: string): void;
683
+ declare function clearCart(): void;
684
+ declare function createCartBackup(): void;
685
+ declare function restoreCartFromBackup(): boolean;
686
+ declare function mergeBaskets(items: CartItem[]): CartItem[];
687
+ declare function moveBasketItem(fromProductId: string, fromVariantId: string, toProductId: string, toVariantId: string): void;
688
+ declare function validateCartIntegrity(): boolean;
689
+ declare function getCartStats(): CartStats;
690
+
691
+ /**
692
+ * Checkout Module
693
+ *
694
+ * Creates invoice via backend API and redirects to hosted checkout page.
695
+ * All checkout flows go through: checkout.shoppex.io/invoice/{invoiceId}
696
+ */
697
+ interface CheckoutOptions {
698
+ autoRedirect?: boolean;
699
+ locale?: string;
700
+ email?: string;
701
+ coupon?: string;
702
+ affiliateCode?: string;
703
+ }
704
+ interface CheckoutResult {
705
+ success: boolean;
706
+ redirectUrl?: string;
707
+ invoiceId?: string;
708
+ message?: string;
709
+ }
710
+ declare function checkout(couponOrOptions?: string | CheckoutOptions, options?: CheckoutOptions): Promise<CheckoutResult>;
711
+ /**
712
+ * Build checkout URL by creating invoice first.
713
+ * Returns the checkout URL for the created invoice.
714
+ */
715
+ declare function buildCheckoutUrl(couponOrOptions?: string | CheckoutOptions, options?: CheckoutOptions): Promise<string>;
716
+ /**
717
+ * @deprecated Use buildCheckoutUrl instead.
718
+ * Sync version is no longer supported as invoice creation requires API call.
719
+ */
720
+ declare function buildCheckoutUrlSync(): never;
721
+
722
+ declare function clearAffiliateCode(): void;
723
+ declare function getAffiliateCode(): string | null;
724
+ /**
725
+ * Capture an affiliate code from the current URL and store it for 30 days (last-click).
726
+ *
727
+ * Example:
728
+ * - URL: https://mystore.com/product/abc?ref=deadbeef
729
+ * - captureAffiliateFromUrl() stores "deadbeef" and returns it.
730
+ */
731
+ declare function captureAffiliateFromUrl(param?: string): Promise<string | null>;
732
+
733
+ /**
734
+ * Coupons Module
735
+ *
736
+ * Coupon validation before checkout.
737
+ */
738
+
739
+ declare function validateCoupon(code: string, productId?: string): Promise<SDKResponse<CouponValidation>>;
740
+
741
+ /**
742
+ * Reviews Module
743
+ *
744
+ * Shop-level feedback/reviews.
745
+ * Note: Shoppex has shop-level feedback, not product-level reviews.
746
+ */
747
+
748
+ declare function getShopReviews(): Promise<SDKResponse<Feedback[]>>;
749
+
750
+ interface SearchOptions {
751
+ hideOutOfStock?: boolean;
752
+ }
753
+ declare function searchProducts(query: string, options?: SearchOptions): Promise<SDKResponse<Product[]>>;
754
+
755
+ /**
756
+ * Invoices Module
757
+ *
758
+ * Invoice status checking after payment.
759
+ */
760
+
761
+ declare function getInvoice(invoiceId: string): Promise<SDKResponse<Invoice>>;
762
+ declare function getInvoiceStatus(invoiceId: string): Promise<SDKResponse<{
763
+ status: string;
764
+ }>>;
765
+
766
+ /**
767
+ * Pages Module
768
+ *
769
+ * API methods for public pages.
770
+ */
771
+
772
+ /**
773
+ * Get all public pages for the store
774
+ */
775
+ declare function getPages(): Promise<SDKResponse<Page[]>>;
776
+ /**
777
+ * Get a public page by slug
778
+ */
779
+ declare function getPage(slug: string): Promise<SDKResponse<Page>>;
780
+
781
+ /**
782
+ * Navigation Module
783
+ *
784
+ * API methods for menus and navigation.
785
+ */
786
+
787
+ /**
788
+ * Get all menus for the store
789
+ */
790
+ declare function getMenus(): Promise<SDKResponse<Menu[]>>;
791
+ /**
792
+ * Get a menu by its exact title.
793
+ */
794
+ declare function getMenuByTitle(title: string): Promise<SDKResponse<Menu>>;
795
+ /**
796
+ * Get a menu by canonical slot. The backend resolves legacy menu titles too.
797
+ */
798
+ declare function getMenuBySlot(slot: NavigationMenuSlot): Promise<SDKResponse<Menu>>;
799
+ declare function getMenuSlotTitles(slot: NavigationMenuSlot): string[];
800
+
801
+ declare function trackPageView(cartValue?: number, itemCount?: number): Promise<void>;
802
+
803
+ /**
804
+ * Formatting Utilities
805
+ */
806
+ declare function createFormatter(currency?: string, locale?: string): Intl.NumberFormat;
807
+ declare function formatPrice(amount: number | string, currency?: string, locale?: string): string;
808
+
809
+ interface CacheStats {
810
+ hits: number;
811
+ misses: number;
812
+ pendingRequests: number;
813
+ entries: number;
814
+ }
815
+ declare function getCacheStats(): CacheStats;
816
+ declare function clearCache(): void;
817
+ declare function invalidateCache(prefixOrKey: string): void;
818
+
819
+ declare function fetchPublishedThemeSettings(shopSlug: string): Promise<ResolvedThemeSettings | null>;
820
+ declare function resolveDefaults(config: ThemeConfig): ResolvedThemeSettings;
821
+ declare function mergeSettings(defaults: ResolvedThemeSettings, overrides: Partial<ResolvedThemeSettings>): ResolvedThemeSettings;
822
+
823
+ /**
824
+ * Shoppex Storefront SDK
825
+ *
826
+ * Usage:
827
+ * ```html
828
+ * <script src="https://cdn.shoppex.io/sdk/v1/shoppex.min.js"></script>
829
+ * <script>
830
+ * shoppex.init('my-store');
831
+ *
832
+ * shoppex.getStore().then(store => console.log(store));
833
+ * shoppex.addToCart('product-id', 'variant-id', 2);
834
+ * shoppex.checkout();
835
+ * </script>
836
+ * ```
837
+ */
838
+
839
+ /**
840
+ * Initialize the SDK with a store slug
841
+ */
842
+ declare function init(storeSlug: string, options?: ShoppexInitOptions): void;
843
+ declare function init(options: ShoppexInitOptions & {
844
+ storeId: string;
845
+ }): void;
846
+ /**
847
+ * Shoppex SDK instance
848
+ */
849
+ declare const shoppex: {
850
+ init: typeof init;
851
+ isInitialized: typeof isInitialized;
852
+ getConfig: typeof getConfig;
853
+ getStore: typeof getStore;
854
+ getStorefront: typeof getStorefront;
855
+ getStoreLogoUrl: typeof getStoreLogoUrl;
856
+ getStoreBannerUrl: typeof getStoreBannerUrl;
857
+ resolveStoreByDomain: typeof resolveStoreByDomain;
858
+ getProducts: typeof getProducts;
859
+ getProduct: typeof getProduct;
860
+ getCategories: typeof getCategories;
861
+ getCart: typeof getCart;
862
+ getCartItemCount: typeof getCartItemCount;
863
+ addToCart: typeof addToCart;
864
+ updateCartItem: typeof updateCartItem;
865
+ removeFromCart: typeof removeFromCart;
866
+ clearCart: typeof clearCart;
867
+ createCartBackup: typeof createCartBackup;
868
+ restoreCartFromBackup: typeof restoreCartFromBackup;
869
+ mergeBaskets: typeof mergeBaskets;
870
+ moveBasketItem: typeof moveBasketItem;
871
+ getCartStats: typeof getCartStats;
872
+ validateCartIntegrity: typeof validateCartIntegrity;
873
+ checkout: typeof checkout;
874
+ buildCheckoutUrl: typeof buildCheckoutUrl;
875
+ buildCheckoutUrlSync: typeof buildCheckoutUrlSync;
876
+ captureAffiliateFromUrl: typeof captureAffiliateFromUrl;
877
+ getAffiliateCode: typeof getAffiliateCode;
878
+ clearAffiliateCode: typeof clearAffiliateCode;
879
+ validateCoupon: typeof validateCoupon;
880
+ getShopReviews: typeof getShopReviews;
881
+ searchProducts: typeof searchProducts;
882
+ getInvoice: typeof getInvoice;
883
+ getInvoiceStatus: typeof getInvoiceStatus;
884
+ getPages: typeof getPages;
885
+ getPage: typeof getPage;
886
+ getMenus: typeof getMenus;
887
+ getMenuBySlot: typeof getMenuBySlot;
888
+ getMenuByTitle: typeof getMenuByTitle;
889
+ getMenuSlotTitles: typeof getMenuSlotTitles;
890
+ trackPageView: typeof trackPageView;
891
+ createFormatter: typeof createFormatter;
892
+ formatPrice: typeof formatPrice;
893
+ clearCache: typeof clearCache;
894
+ invalidateCache: typeof invalidateCache;
895
+ getCacheStats: typeof getCacheStats;
896
+ fetchPublishedThemeSettings: typeof fetchPublishedThemeSettings;
897
+ resolveDefaults: typeof resolveDefaults;
898
+ mergeSettings: typeof mergeSettings;
899
+ };
900
+
901
+ export { type ApiResponse, type CartAddOptions, type CartAddon, CartError, type CartItem, type CartMetadata, type CartPayload, type CartStats, type Category, type CouponValidation, type CustomFieldDefinition, type Feedback, type Invoice, type InvoiceProduct, type Menu, type MenuItem, NetworkError, NotInitializedError, type Page, type PriceVariant, type Product, type ProductAddon, type ProductBundle, type ProductCategory, type ProductFaq, type ProductFeedback, type ProductGroup, type ProductImage, type ProductVariant, type ResolvedThemeSettings, type SDKResponse, type SectionDefinition, type SettingField, type Shop, type ShopFeedback, type ShopTheme, type ShoppexConfig, ShoppexError, type ShoppexInitOptions, type StorefrontAddon, type StorefrontAddonBootstrap, type StorefrontAnnouncementBarAddon, type StorefrontCountdownBarAddon, type StorefrontCouponPopupModalAddon, type StorefrontData, type StorefrontItem, type StorefrontPromoInfoCardAddon, type StorefrontRecentPurchasePopupAddon, type Subscription, type SubscriptionFlags, type SubscriptionInterval, type ThemeConfig, type TrustedChecks, ValidationError, shoppex as default, fetchPublishedThemeSettings, getMenuBySlot, getMenuByTitle, getMenuSlotTitles, mergeSettings, resolveDefaults, shoppex, trackPageView };