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