@shoppexio/storefront 0.1.0 → 0.3.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/CHANGELOG.md +9 -0
- package/README.md +28 -2
- package/dist/index.cjs +8987 -274
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +268 -20
- package/dist/index.d.ts +268 -20
- package/dist/index.js +8995 -280
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { createApiClient } from '@shoppex/contracts';
|
|
1
2
|
import { NavigationMenuSlot } from '@shoppex/contracts/navigation';
|
|
2
3
|
export { NavigationMenuSlot } from '@shoppex/contracts/navigation';
|
|
4
|
+
import * as src from 'src';
|
|
3
5
|
|
|
4
6
|
/**
|
|
5
7
|
* SDK Configuration Types
|
|
@@ -16,6 +18,7 @@ interface ShoppexInitOptions {
|
|
|
16
18
|
currency?: string;
|
|
17
19
|
apiBaseUrl?: string;
|
|
18
20
|
checkoutBaseUrl?: string;
|
|
21
|
+
shopId?: string;
|
|
19
22
|
}
|
|
20
23
|
|
|
21
24
|
/**
|
|
@@ -49,6 +52,7 @@ interface Shop {
|
|
|
49
52
|
average_score?: number | null;
|
|
50
53
|
rating?: number | null;
|
|
51
54
|
products_sold_count?: number;
|
|
55
|
+
customers_count?: number;
|
|
52
56
|
hide_products_sold?: boolean;
|
|
53
57
|
currency: string;
|
|
54
58
|
tos_enabled?: boolean;
|
|
@@ -76,6 +80,18 @@ interface Shop {
|
|
|
76
80
|
builder_settings?: Record<string, unknown> | null;
|
|
77
81
|
feedback?: ShopFeedback;
|
|
78
82
|
trusted_checks?: TrustedChecks | null;
|
|
83
|
+
available_gateways?: string[];
|
|
84
|
+
reward_program_summary?: RewardProgramSummary | null;
|
|
85
|
+
}
|
|
86
|
+
interface RewardProgramTeaserItem {
|
|
87
|
+
trigger_type: RewardReason;
|
|
88
|
+
action_type: RewardActionType;
|
|
89
|
+
label: string;
|
|
90
|
+
}
|
|
91
|
+
interface RewardProgramSummary {
|
|
92
|
+
enabled: boolean;
|
|
93
|
+
headline: string;
|
|
94
|
+
items: RewardProgramTeaserItem[];
|
|
79
95
|
}
|
|
80
96
|
interface ShopTheme {
|
|
81
97
|
primary_color?: string;
|
|
@@ -160,6 +176,7 @@ interface Product {
|
|
|
160
176
|
feedbacks?: Feedback[];
|
|
161
177
|
feedback?: ProductFeedback;
|
|
162
178
|
cdn_image_url?: string;
|
|
179
|
+
detail_image_url?: string | null;
|
|
163
180
|
recurring_interval?: string | null;
|
|
164
181
|
recurring_interval_count?: number | null;
|
|
165
182
|
trial_period?: number | null;
|
|
@@ -189,7 +206,11 @@ interface ProductFeedback {
|
|
|
189
206
|
message: string | null;
|
|
190
207
|
reply: string | null;
|
|
191
208
|
created_at: string | null;
|
|
209
|
+
createdAt?: string | null;
|
|
192
210
|
updated_at: string | null;
|
|
211
|
+
updatedAt?: string | null;
|
|
212
|
+
is_automated?: boolean;
|
|
213
|
+
isAutomated?: boolean;
|
|
193
214
|
}>;
|
|
194
215
|
}
|
|
195
216
|
interface ProductImage {
|
|
@@ -203,6 +224,16 @@ interface ProductVariant {
|
|
|
203
224
|
title: string;
|
|
204
225
|
price?: number;
|
|
205
226
|
stock?: number;
|
|
227
|
+
quantity_min?: number;
|
|
228
|
+
quantity_max?: number;
|
|
229
|
+
quantityMin?: number;
|
|
230
|
+
quantityMax?: number;
|
|
231
|
+
image_id?: string | null;
|
|
232
|
+
imageId?: string | null;
|
|
233
|
+
cloudflare_image_id?: string | null;
|
|
234
|
+
cloudflareImageId?: string | null;
|
|
235
|
+
image_url?: string | null;
|
|
236
|
+
imageUrl?: string | null;
|
|
206
237
|
}
|
|
207
238
|
interface ProductAddon {
|
|
208
239
|
id: string;
|
|
@@ -216,6 +247,17 @@ interface PriceVariant {
|
|
|
216
247
|
label?: string;
|
|
217
248
|
title?: string;
|
|
218
249
|
price: number;
|
|
250
|
+
stock?: number;
|
|
251
|
+
quantity_min?: number;
|
|
252
|
+
quantity_max?: number;
|
|
253
|
+
quantityMin?: number;
|
|
254
|
+
quantityMax?: number;
|
|
255
|
+
image_id?: string | null;
|
|
256
|
+
imageId?: string | null;
|
|
257
|
+
cloudflare_image_id?: string | null;
|
|
258
|
+
cloudflareImageId?: string | null;
|
|
259
|
+
image_url?: string | null;
|
|
260
|
+
imageUrl?: string | null;
|
|
219
261
|
}
|
|
220
262
|
interface CustomFieldDefinition {
|
|
221
263
|
id: string;
|
|
@@ -227,10 +269,19 @@ interface CustomFieldDefinition {
|
|
|
227
269
|
interface Feedback {
|
|
228
270
|
id: string;
|
|
229
271
|
rating: number;
|
|
272
|
+
score?: number;
|
|
230
273
|
author?: string;
|
|
274
|
+
customer_name?: string;
|
|
231
275
|
comment?: string;
|
|
276
|
+
message?: string | null;
|
|
277
|
+
reply?: string | null;
|
|
232
278
|
is_automated?: boolean;
|
|
279
|
+
isAutomated?: boolean;
|
|
280
|
+
product_id?: string | null;
|
|
281
|
+
product_title?: string | null;
|
|
282
|
+
cloudflare_image_id?: string | null;
|
|
233
283
|
created_at: string;
|
|
284
|
+
updated_at?: string | number | null;
|
|
234
285
|
}
|
|
235
286
|
interface ProductBundle {
|
|
236
287
|
id?: string;
|
|
@@ -238,7 +289,13 @@ interface ProductBundle {
|
|
|
238
289
|
title?: string;
|
|
239
290
|
discount_type?: 'PERCENTAGE' | 'FIXED';
|
|
240
291
|
discount_amount?: number;
|
|
241
|
-
products?:
|
|
292
|
+
products?: ProductBundleProduct[];
|
|
293
|
+
}
|
|
294
|
+
interface ProductBundleProduct {
|
|
295
|
+
id?: string;
|
|
296
|
+
uniqid: string;
|
|
297
|
+
title?: string | null;
|
|
298
|
+
default_variant_id?: string;
|
|
242
299
|
}
|
|
243
300
|
interface ProductFaq {
|
|
244
301
|
id?: string;
|
|
@@ -270,6 +327,7 @@ interface Invoice {
|
|
|
270
327
|
gateway?: string;
|
|
271
328
|
products: InvoiceProduct[];
|
|
272
329
|
created_at: string;
|
|
330
|
+
rewards?: BuyerRewards | null;
|
|
273
331
|
}
|
|
274
332
|
interface InvoiceProduct {
|
|
275
333
|
product_id: string;
|
|
@@ -277,10 +335,56 @@ interface InvoiceProduct {
|
|
|
277
335
|
quantity: number;
|
|
278
336
|
price: number;
|
|
279
337
|
}
|
|
338
|
+
type RewardActionType = 'WALLET_CREDIT' | 'COUPON';
|
|
339
|
+
type RewardGrantStatus = 'PENDING' | 'FULFILLED' | 'FAILED' | 'REVOKED';
|
|
340
|
+
type RewardReason = 'ORDER_COMPLETED' | 'ORDER_COUNT_REACHED' | 'SPEND_AMOUNT_REACHED' | 'POSITIVE_REVIEW_LEFT' | 'FIRST_PURCHASE_COMPLETED';
|
|
341
|
+
interface BuyerRewardActivityItem {
|
|
342
|
+
id: string;
|
|
343
|
+
type: RewardActionType;
|
|
344
|
+
status: RewardGrantStatus;
|
|
345
|
+
amount: string | null;
|
|
346
|
+
currency: string | null;
|
|
347
|
+
coupon_code: string | null;
|
|
348
|
+
reason: RewardReason;
|
|
349
|
+
trigger_reference_type: string;
|
|
350
|
+
trigger_reference_id: string;
|
|
351
|
+
created_at: number;
|
|
352
|
+
fulfilled_at: number | null;
|
|
353
|
+
expires_at: number | null;
|
|
354
|
+
}
|
|
355
|
+
interface BuyerRewards {
|
|
356
|
+
summary: {
|
|
357
|
+
available: string;
|
|
358
|
+
pending: string;
|
|
359
|
+
lifetime_earned: string;
|
|
360
|
+
redeemed: string | null;
|
|
361
|
+
currency: string;
|
|
362
|
+
};
|
|
363
|
+
activity: BuyerRewardActivityItem[];
|
|
364
|
+
earned_after_invoice: BuyerRewardActivityItem[];
|
|
365
|
+
pending_after_invoice: BuyerRewardActivityItem[];
|
|
366
|
+
}
|
|
280
367
|
interface CouponValidation {
|
|
281
368
|
valid: boolean;
|
|
282
369
|
discount?: number;
|
|
283
370
|
discount_type?: 'percentage' | 'fixed';
|
|
371
|
+
source?: 'COUPON' | 'AFFILIATE';
|
|
372
|
+
product_restricted?: boolean;
|
|
373
|
+
variant_restricted?: boolean;
|
|
374
|
+
restriction_scope?: 'all' | 'products' | 'variants' | 'products_and_variants';
|
|
375
|
+
allowed_product_ids?: string[];
|
|
376
|
+
allowed_variant_ids?: string[];
|
|
377
|
+
message?: string;
|
|
378
|
+
}
|
|
379
|
+
interface CouponValidationOptions {
|
|
380
|
+
productId?: string;
|
|
381
|
+
variantId?: string;
|
|
382
|
+
}
|
|
383
|
+
interface AffiliateValidation {
|
|
384
|
+
valid: boolean;
|
|
385
|
+
affiliate_code: string | null;
|
|
386
|
+
discount_active: boolean;
|
|
387
|
+
discount_percent: number;
|
|
284
388
|
message?: string;
|
|
285
389
|
}
|
|
286
390
|
interface ProductGroup {
|
|
@@ -309,11 +413,16 @@ interface Category {
|
|
|
309
413
|
image_storage?: string | null;
|
|
310
414
|
cloudflare_image_id?: string | null;
|
|
311
415
|
cdn_image_url?: string | null;
|
|
416
|
+
product_uniqids?: string[];
|
|
312
417
|
products_bound?: Product[];
|
|
313
418
|
products_count?: number;
|
|
314
419
|
groups_bound?: ProductGroup[];
|
|
315
420
|
groups_count?: number;
|
|
316
421
|
}
|
|
422
|
+
interface CursorPagination {
|
|
423
|
+
next_cursor: string | null;
|
|
424
|
+
has_more: boolean;
|
|
425
|
+
}
|
|
317
426
|
interface StorefrontAnnouncementBarAddon {
|
|
318
427
|
id: string;
|
|
319
428
|
type: 'announcement_bar';
|
|
@@ -420,20 +529,26 @@ interface StorefrontCouponPopupModalAddon {
|
|
|
420
529
|
background_color: string;
|
|
421
530
|
text_color: string;
|
|
422
531
|
accent_color: string;
|
|
532
|
+
hero_image_url?: string | null;
|
|
533
|
+
discount_display?: string | null;
|
|
534
|
+
expires_at?: string | null;
|
|
423
535
|
};
|
|
424
536
|
}
|
|
425
537
|
type StorefrontAddon = StorefrontAnnouncementBarAddon | StorefrontCountdownBarAddon | StorefrontPromoInfoCardAddon | StorefrontRecentPurchasePopupAddon | StorefrontCouponPopupModalAddon;
|
|
426
538
|
interface StorefrontAddonBootstrap {
|
|
427
539
|
items: StorefrontAddon[];
|
|
428
540
|
}
|
|
429
|
-
type StorefrontItem =
|
|
430
|
-
item_type: 'PRODUCT';
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
541
|
+
type StorefrontItem = {
|
|
542
|
+
item_type: 'PRODUCT' | 'GROUP';
|
|
543
|
+
uniqid: string;
|
|
544
|
+
sort_priority?: number | null;
|
|
545
|
+
title?: string | null;
|
|
546
|
+
name?: string | null;
|
|
547
|
+
};
|
|
434
548
|
interface StorefrontData {
|
|
435
549
|
shop: Shop;
|
|
436
550
|
products: Product[];
|
|
551
|
+
products_pagination?: CursorPagination | null;
|
|
437
552
|
groups: ProductGroup[];
|
|
438
553
|
items: StorefrontItem[];
|
|
439
554
|
categories: Category[];
|
|
@@ -457,6 +572,7 @@ interface Menu {
|
|
|
457
572
|
shop_id: string;
|
|
458
573
|
title: string;
|
|
459
574
|
slot?: NavigationMenuSlot | null;
|
|
575
|
+
item_count?: number | null;
|
|
460
576
|
items?: MenuItem[];
|
|
461
577
|
created_at: number;
|
|
462
578
|
updated_at: number;
|
|
@@ -468,12 +584,13 @@ interface MenuItem {
|
|
|
468
584
|
page_id: string | null;
|
|
469
585
|
title: string;
|
|
470
586
|
url?: string | null;
|
|
471
|
-
link_type?: 'link' | 'page';
|
|
587
|
+
link_type?: 'LINK' | 'PAGE' | 'link' | 'page' | null;
|
|
472
588
|
target?: '_self' | '_blank' | null;
|
|
473
589
|
sort_order: number;
|
|
474
590
|
page_slug: string | null;
|
|
475
591
|
created_at: number;
|
|
476
592
|
updated_at: number;
|
|
593
|
+
children?: MenuItem[];
|
|
477
594
|
}
|
|
478
595
|
|
|
479
596
|
/**
|
|
@@ -514,6 +631,53 @@ interface CartPayload {
|
|
|
514
631
|
items: CartItem[];
|
|
515
632
|
coupon?: string;
|
|
516
633
|
}
|
|
634
|
+
interface CartAppliedDiscount {
|
|
635
|
+
source: 'AUTOMATIC_PRODUCT_DEAL' | 'BUNDLE_DEAL' | 'COUPON';
|
|
636
|
+
source_id: string | null;
|
|
637
|
+
source_uniqid: string | null;
|
|
638
|
+
label: string;
|
|
639
|
+
amount: string;
|
|
640
|
+
}
|
|
641
|
+
interface EligibleCartDeal {
|
|
642
|
+
source?: 'AUTOMATIC_PRODUCT_DEAL';
|
|
643
|
+
deal_id: string;
|
|
644
|
+
deal_uniqid: string;
|
|
645
|
+
product_id: string;
|
|
646
|
+
product_uniqid: string | null;
|
|
647
|
+
label: string;
|
|
648
|
+
missing_quantity: number;
|
|
649
|
+
required_quantity: number;
|
|
650
|
+
}
|
|
651
|
+
interface EligibleBundleDealProduct {
|
|
652
|
+
product_id: string;
|
|
653
|
+
product_uniqid: string;
|
|
654
|
+
title: string;
|
|
655
|
+
quantity: number;
|
|
656
|
+
price: string;
|
|
657
|
+
currency: string;
|
|
658
|
+
default_variant_id: string;
|
|
659
|
+
}
|
|
660
|
+
interface EligibleBundleDeal {
|
|
661
|
+
source: 'BUNDLE_DEAL';
|
|
662
|
+
bundle_id: string;
|
|
663
|
+
bundle_uniqid: string;
|
|
664
|
+
label: string;
|
|
665
|
+
discount_type: 'PERCENTAGE' | 'FIXED';
|
|
666
|
+
discount_amount: string;
|
|
667
|
+
missing_products: EligibleBundleDealProduct[];
|
|
668
|
+
products: EligibleBundleDealProduct[];
|
|
669
|
+
}
|
|
670
|
+
interface CartQuote {
|
|
671
|
+
subtotal: string;
|
|
672
|
+
discount: string;
|
|
673
|
+
total: string;
|
|
674
|
+
currency: string;
|
|
675
|
+
applied_discounts: CartAppliedDiscount[];
|
|
676
|
+
automatic_product_deals: Array<Record<string, unknown>>;
|
|
677
|
+
bundle_deals: Array<Record<string, unknown>>;
|
|
678
|
+
eligible_deals: EligibleCartDeal[];
|
|
679
|
+
eligible_bundle_deals: EligibleBundleDeal[];
|
|
680
|
+
}
|
|
517
681
|
interface CartMetadata {
|
|
518
682
|
created_at: number;
|
|
519
683
|
last_modified: number;
|
|
@@ -538,6 +702,28 @@ interface CartStats {
|
|
|
538
702
|
declare function getConfig(): ShoppexConfig;
|
|
539
703
|
declare function isInitialized(): boolean;
|
|
540
704
|
|
|
705
|
+
/**
|
|
706
|
+
* Typed OpenAPI client factory.
|
|
707
|
+
*
|
|
708
|
+
* Surfaces the generated `createApiClient` from `@shoppex/contracts` with the
|
|
709
|
+
* SDK's configured `apiBaseUrl`. This lets consumers of `@shoppexio/storefront`
|
|
710
|
+
* call any public Dev API endpoint with full end-to-end types without
|
|
711
|
+
* rebuilding a client from scratch.
|
|
712
|
+
*
|
|
713
|
+
* Prefer the high-level modules (`shoppex.getProducts()` etc.) for common
|
|
714
|
+
* read flows — they handle caching, pagination defaults, and storefront
|
|
715
|
+
* scoping. Drop down to `shoppex.client()` only when you need an endpoint
|
|
716
|
+
* the high-level API does not cover yet.
|
|
717
|
+
*/
|
|
718
|
+
|
|
719
|
+
type ApiClient = ReturnType<typeof createApiClient>;
|
|
720
|
+
/**
|
|
721
|
+
* Return a typed OpenAPI client bound to the SDK's configured API base URL.
|
|
722
|
+
* The client is cached per base URL and recreated when the SDK is re-initialized
|
|
723
|
+
* against a different host.
|
|
724
|
+
*/
|
|
725
|
+
declare function getTypedClient(token?: string): ApiClient;
|
|
726
|
+
|
|
541
727
|
/**
|
|
542
728
|
* SDK Error Classes
|
|
543
729
|
*/
|
|
@@ -560,6 +746,19 @@ declare class CartError extends ShoppexError {
|
|
|
560
746
|
constructor(message: string);
|
|
561
747
|
}
|
|
562
748
|
|
|
749
|
+
interface StorefrontCustomField {
|
|
750
|
+
name: string;
|
|
751
|
+
type: string;
|
|
752
|
+
required: boolean;
|
|
753
|
+
defaultValue: string;
|
|
754
|
+
placeholder: string;
|
|
755
|
+
regex?: string;
|
|
756
|
+
}
|
|
757
|
+
declare function normalizeStorefrontCustomFields(raw: unknown): StorefrontCustomField[];
|
|
758
|
+
declare function isStorefrontCheckboxCustomFieldValueChecked(value: string | undefined): boolean;
|
|
759
|
+
declare function validateStorefrontCustomFieldValue(field: StorefrontCustomField, value: string): string | null;
|
|
760
|
+
declare function buildStorefrontCustomFieldPayload(fields: StorefrontCustomField[], values: Record<string, string>): Record<string, string>;
|
|
761
|
+
|
|
563
762
|
/**
|
|
564
763
|
* Theme configuration types (framework agnostic)
|
|
565
764
|
*/
|
|
@@ -627,6 +826,28 @@ interface SectionDefinition {
|
|
|
627
826
|
icon?: string;
|
|
628
827
|
settings: Record<string, SettingField>;
|
|
629
828
|
}
|
|
829
|
+
interface BlockDefinition {
|
|
830
|
+
name: string;
|
|
831
|
+
description?: string;
|
|
832
|
+
icon?: string;
|
|
833
|
+
settings: Record<string, SettingField>;
|
|
834
|
+
allowedPages?: string[];
|
|
835
|
+
maxPerPage?: number;
|
|
836
|
+
}
|
|
837
|
+
interface BlockInstance {
|
|
838
|
+
id: string;
|
|
839
|
+
type: string;
|
|
840
|
+
visible?: boolean;
|
|
841
|
+
settings?: Record<string, SettingValue>;
|
|
842
|
+
}
|
|
843
|
+
interface PageLayout {
|
|
844
|
+
blocks: BlockInstance[];
|
|
845
|
+
}
|
|
846
|
+
interface ThemeBlockManifest {
|
|
847
|
+
pages: string[];
|
|
848
|
+
blocks: Record<string, BlockDefinition>;
|
|
849
|
+
defaultLayouts?: Record<string, PageLayout>;
|
|
850
|
+
}
|
|
630
851
|
interface ThemeConfig {
|
|
631
852
|
id: string;
|
|
632
853
|
name: string;
|
|
@@ -636,6 +857,9 @@ interface ThemeConfig {
|
|
|
636
857
|
preview?: string;
|
|
637
858
|
settings: Record<string, Record<string, SettingField>>;
|
|
638
859
|
sections: Record<string, SectionDefinition>;
|
|
860
|
+
blocks?: Record<string, BlockDefinition>;
|
|
861
|
+
pageLayouts?: Record<string, PageLayout>;
|
|
862
|
+
builder?: ThemeBlockManifest;
|
|
639
863
|
}
|
|
640
864
|
type SettingValue = string | number | boolean | null | string[] | Record<string, unknown>;
|
|
641
865
|
type ResolvedThemeSettings = {
|
|
@@ -650,9 +874,13 @@ type ResolvedThemeSettings = {
|
|
|
650
874
|
* API methods for store data.
|
|
651
875
|
*/
|
|
652
876
|
|
|
877
|
+
interface GetStorefrontOptions {
|
|
878
|
+
productsLimit?: number;
|
|
879
|
+
productsCursor?: string | null;
|
|
880
|
+
}
|
|
653
881
|
declare function getStore(): Promise<SDKResponse<Shop>>;
|
|
654
882
|
declare function resolveStoreByDomain(domain?: string, apiBaseUrl?: string): Promise<SDKResponse<Shop>>;
|
|
655
|
-
declare function getStorefront(): Promise<SDKResponse<StorefrontData>>;
|
|
883
|
+
declare function getStorefront(options?: GetStorefrontOptions): Promise<SDKResponse<StorefrontData>>;
|
|
656
884
|
declare function getStoreLogoUrl(): Promise<string | null>;
|
|
657
885
|
declare function getStoreBannerUrl(): Promise<string | null>;
|
|
658
886
|
|
|
@@ -662,22 +890,25 @@ declare function getStoreBannerUrl(): Promise<string | null>;
|
|
|
662
890
|
* API methods for product data.
|
|
663
891
|
*/
|
|
664
892
|
|
|
893
|
+
interface GetStorefrontProductsPageOptions {
|
|
894
|
+
cursor?: string | null;
|
|
895
|
+
limit?: number;
|
|
896
|
+
}
|
|
665
897
|
declare function getProducts(): Promise<SDKResponse<Product[]>>;
|
|
898
|
+
declare function getStorefrontProductsPage(options?: GetStorefrontProductsPageOptions): Promise<SDKResponse<{
|
|
899
|
+
products: Product[];
|
|
900
|
+
pagination: CursorPagination | null;
|
|
901
|
+
}>>;
|
|
666
902
|
declare function getProduct(idOrSlug: string): Promise<SDKResponse<Product>>;
|
|
667
903
|
declare function getCategories(): Promise<SDKResponse<string[]>>;
|
|
668
904
|
|
|
669
|
-
|
|
670
|
-
|
|
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
|
-
|
|
905
|
+
declare function getCartCoupon(): string | null;
|
|
906
|
+
declare function setCartCoupon(coupon: string | null | undefined): string | null;
|
|
907
|
+
declare function clearCartCoupon(): void;
|
|
678
908
|
declare function getCart(): CartItem[];
|
|
679
909
|
declare function getCartItemCount(): number;
|
|
680
910
|
declare function addToCart(productId: string, variantId: string, quantity?: number, options?: CartAddOptions): void;
|
|
911
|
+
declare function setCartItem(productId: string, variantId: string, quantity?: number, options?: CartAddOptions): void;
|
|
681
912
|
declare function updateCartItem(productId: string, variantId: string, updates: Partial<Omit<CartItem, 'product_id' | 'variant_id'>>): void;
|
|
682
913
|
declare function removeFromCart(productId: string, variantId: string): void;
|
|
683
914
|
declare function clearCart(): void;
|
|
@@ -687,6 +918,7 @@ declare function mergeBaskets(items: CartItem[]): CartItem[];
|
|
|
687
918
|
declare function moveBasketItem(fromProductId: string, fromVariantId: string, toProductId: string, toVariantId: string): void;
|
|
688
919
|
declare function validateCartIntegrity(): boolean;
|
|
689
920
|
declare function getCartStats(): CartStats;
|
|
921
|
+
declare function quoteCart(coupon?: string): Promise<src.SDKResponse<CartQuote>>;
|
|
690
922
|
|
|
691
923
|
/**
|
|
692
924
|
* Checkout Module
|
|
@@ -694,17 +926,20 @@ declare function getCartStats(): CartStats;
|
|
|
694
926
|
* Creates invoice via backend API and redirects to hosted checkout page.
|
|
695
927
|
* All checkout flows go through: checkout.shoppex.io/invoice/{invoiceId}
|
|
696
928
|
*/
|
|
929
|
+
|
|
697
930
|
interface CheckoutOptions {
|
|
698
931
|
autoRedirect?: boolean;
|
|
699
932
|
locale?: string;
|
|
700
933
|
email?: string;
|
|
701
934
|
coupon?: string;
|
|
702
935
|
affiliateCode?: string;
|
|
936
|
+
referralCode?: string;
|
|
703
937
|
}
|
|
704
938
|
interface CheckoutResult {
|
|
705
939
|
success: boolean;
|
|
706
940
|
redirectUrl?: string;
|
|
707
941
|
invoiceId?: string;
|
|
942
|
+
rewards?: BuyerRewards | null;
|
|
708
943
|
message?: string;
|
|
709
944
|
}
|
|
710
945
|
declare function checkout(couponOrOptions?: string | CheckoutOptions, options?: CheckoutOptions): Promise<CheckoutResult>;
|
|
@@ -719,8 +954,11 @@ declare function buildCheckoutUrl(couponOrOptions?: string | CheckoutOptions, op
|
|
|
719
954
|
*/
|
|
720
955
|
declare function buildCheckoutUrlSync(): never;
|
|
721
956
|
|
|
957
|
+
declare function setAffiliateCode(code: string | null | undefined, ttlDays?: number): string | null;
|
|
722
958
|
declare function clearAffiliateCode(): void;
|
|
723
959
|
declare function getAffiliateCode(): string | null;
|
|
960
|
+
declare function validateAffiliateCode(code: string): Promise<SDKResponse<AffiliateValidation>>;
|
|
961
|
+
declare function applyAffiliateCode(code: string): Promise<SDKResponse<AffiliateValidation>>;
|
|
724
962
|
/**
|
|
725
963
|
* Capture an affiliate code from the current URL and store it for 30 days (last-click).
|
|
726
964
|
*
|
|
@@ -736,7 +974,7 @@ declare function captureAffiliateFromUrl(param?: string): Promise<string | null>
|
|
|
736
974
|
* Coupon validation before checkout.
|
|
737
975
|
*/
|
|
738
976
|
|
|
739
|
-
declare function validateCoupon(code: string,
|
|
977
|
+
declare function validateCoupon(code: string, productOrOptions?: string | CouponValidationOptions): Promise<SDKResponse<CouponValidation>>;
|
|
740
978
|
|
|
741
979
|
/**
|
|
742
980
|
* Reviews Module
|
|
@@ -825,7 +1063,7 @@ declare function mergeSettings(defaults: ResolvedThemeSettings, overrides: Parti
|
|
|
825
1063
|
*
|
|
826
1064
|
* Usage:
|
|
827
1065
|
* ```html
|
|
828
|
-
* <script src="https://cdn.shoppex.io/sdk/
|
|
1066
|
+
* <script src="https://cdn.shoppex.io/sdk/v0.3/shoppex.umd.js"></script>
|
|
829
1067
|
* <script>
|
|
830
1068
|
* shoppex.init('my-store');
|
|
831
1069
|
*
|
|
@@ -850,17 +1088,23 @@ declare const shoppex: {
|
|
|
850
1088
|
init: typeof init;
|
|
851
1089
|
isInitialized: typeof isInitialized;
|
|
852
1090
|
getConfig: typeof getConfig;
|
|
1091
|
+
client: typeof getTypedClient;
|
|
853
1092
|
getStore: typeof getStore;
|
|
854
1093
|
getStorefront: typeof getStorefront;
|
|
855
1094
|
getStoreLogoUrl: typeof getStoreLogoUrl;
|
|
856
1095
|
getStoreBannerUrl: typeof getStoreBannerUrl;
|
|
857
1096
|
resolveStoreByDomain: typeof resolveStoreByDomain;
|
|
858
1097
|
getProducts: typeof getProducts;
|
|
1098
|
+
getStorefrontProductsPage: typeof getStorefrontProductsPage;
|
|
859
1099
|
getProduct: typeof getProduct;
|
|
860
1100
|
getCategories: typeof getCategories;
|
|
861
1101
|
getCart: typeof getCart;
|
|
862
1102
|
getCartItemCount: typeof getCartItemCount;
|
|
1103
|
+
getCartCoupon: typeof getCartCoupon;
|
|
1104
|
+
setCartCoupon: typeof setCartCoupon;
|
|
1105
|
+
clearCartCoupon: typeof clearCartCoupon;
|
|
863
1106
|
addToCart: typeof addToCart;
|
|
1107
|
+
setCartItem: typeof setCartItem;
|
|
864
1108
|
updateCartItem: typeof updateCartItem;
|
|
865
1109
|
removeFromCart: typeof removeFromCart;
|
|
866
1110
|
clearCart: typeof clearCart;
|
|
@@ -870,11 +1114,15 @@ declare const shoppex: {
|
|
|
870
1114
|
moveBasketItem: typeof moveBasketItem;
|
|
871
1115
|
getCartStats: typeof getCartStats;
|
|
872
1116
|
validateCartIntegrity: typeof validateCartIntegrity;
|
|
1117
|
+
quoteCart: typeof quoteCart;
|
|
873
1118
|
checkout: typeof checkout;
|
|
874
1119
|
buildCheckoutUrl: typeof buildCheckoutUrl;
|
|
875
1120
|
buildCheckoutUrlSync: typeof buildCheckoutUrlSync;
|
|
876
1121
|
captureAffiliateFromUrl: typeof captureAffiliateFromUrl;
|
|
1122
|
+
validateAffiliateCode: typeof validateAffiliateCode;
|
|
1123
|
+
applyAffiliateCode: typeof applyAffiliateCode;
|
|
877
1124
|
getAffiliateCode: typeof getAffiliateCode;
|
|
1125
|
+
setAffiliateCode: typeof setAffiliateCode;
|
|
878
1126
|
clearAffiliateCode: typeof clearAffiliateCode;
|
|
879
1127
|
validateCoupon: typeof validateCoupon;
|
|
880
1128
|
getShopReviews: typeof getShopReviews;
|
|
@@ -898,4 +1146,4 @@ declare const shoppex: {
|
|
|
898
1146
|
mergeSettings: typeof mergeSettings;
|
|
899
1147
|
};
|
|
900
1148
|
|
|
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 };
|
|
1149
|
+
export { type AffiliateValidation, type ApiResponse, type BlockDefinition, type BlockInstance, type BuyerRewardActivityItem, type BuyerRewards, type CartAddOptions, type CartAddon, type CartAppliedDiscount, CartError, type CartItem, type CartMetadata, type CartPayload, type CartQuote, type CartStats, type Category, type CouponValidation, type CouponValidationOptions, type CursorPagination, type CustomFieldDefinition, type EligibleBundleDeal, type EligibleBundleDealProduct, type EligibleCartDeal, type Feedback, type Invoice, type InvoiceProduct, type Menu, type MenuItem, NetworkError, NotInitializedError, type Page, type PageLayout, type PriceVariant, type Product, type ProductAddon, type ProductBundle, type ProductBundleProduct, type ProductCategory, type ProductFaq, type ProductFeedback, type ProductGroup, type ProductImage, type ProductVariant, type ResolvedThemeSettings, type RewardActionType, type RewardGrantStatus, type RewardProgramSummary, type RewardProgramTeaserItem, type RewardReason, 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 StorefrontCustomField, type StorefrontData, type StorefrontItem, type StorefrontPromoInfoCardAddon, type StorefrontRecentPurchasePopupAddon, type Subscription, type SubscriptionFlags, type SubscriptionInterval, type ThemeBlockManifest, type ThemeConfig, type TrustedChecks, ValidationError, buildStorefrontCustomFieldPayload, shoppex as default, fetchPublishedThemeSettings, getMenuBySlot, getMenuByTitle, getMenuSlotTitles, isStorefrontCheckboxCustomFieldValueChecked, mergeSettings, normalizeStorefrontCustomFields, resolveDefaults, shoppex, trackPageView, validateStorefrontCustomFieldValue };
|