@shoppexio/storefront-react 0.3.0 → 0.5.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 +31 -0
- package/dist/account.css +26 -8
- package/dist/account.js +3217 -1001
- package/dist/account.js.map +1 -1
- package/dist/index.d.ts +188 -14
- package/dist/index.js +43 -20
- package/dist/index.js.map +1 -1
- package/eject/account/account-downloads.ts +89 -1
- package/eject/account/account-payment-method.ts +1 -0
- package/eject/account/account-referrals.ts +70 -1
- package/eject/account/account-reseller.ts +6 -140
- package/eject/account/account-subscriptions.ts +158 -6
- package/eject/account/buyer-invoice-status.ts +100 -0
- package/eject/account/downloads.tsx +118 -17
- package/eject/account/hosted-page.ts +45 -0
- package/eject/account/messages/ar.json +150 -39
- package/eject/account/messages/de.json +150 -39
- package/eject/account/messages/en.json +150 -39
- package/eject/account/messages/es.json +150 -39
- package/eject/account/messages/fi.json +150 -39
- package/eject/account/messages/fr.json +150 -39
- package/eject/account/messages/hi.json +150 -39
- package/eject/account/messages/it.json +150 -39
- package/eject/account/messages/lt.json +150 -39
- package/eject/account/messages/nl.json +150 -39
- package/eject/account/messages/pl.json +150 -39
- package/eject/account/messages/pt.json +150 -39
- package/eject/account/messages/ru.json +150 -39
- package/eject/account/messages/tr.json +150 -39
- package/eject/account/messages/uk.json +150 -39
- package/eject/account/messages/zh.json +150 -39
- package/eject/account/orders.tsx +203 -41
- package/eject/account/overview.tsx +6 -0
- package/eject/account/referrals.tsx +47 -5
- package/eject/account/reseller.tsx +62 -308
- package/eject/account/rewards.tsx +5 -0
- package/eject/account/shared.tsx +60 -4
- package/eject/account/subscriptions.tsx +387 -50
- package/package.json +4 -4
package/dist/index.d.ts
CHANGED
|
@@ -469,6 +469,25 @@ interface SdkCustomerDeliverable {
|
|
|
469
469
|
value: string;
|
|
470
470
|
href: string | null;
|
|
471
471
|
created_at: string;
|
|
472
|
+
/**
|
|
473
|
+
* What the buyer can still do with a FILE: downloads left, until when, or why
|
|
474
|
+
* it closed. Null on keys and codes. Optional only because the backend that
|
|
475
|
+
* sends it may deploy after this package; a missing value reads as null.
|
|
476
|
+
*/
|
|
477
|
+
access?: SdkCustomerFileAccess | null;
|
|
478
|
+
}
|
|
479
|
+
/**
|
|
480
|
+
* One file's access, as `BuyerFileAccess` emits it. `ends_at` is an ISO instant
|
|
481
|
+
* and `time_zone` the SHOP's IANA zone: the end date is a day in the shop's
|
|
482
|
+
* calendar, so it is printed in that zone and never in the viewer's.
|
|
483
|
+
*/
|
|
484
|
+
interface SdkCustomerFileAccess {
|
|
485
|
+
state: 'open' | 'limit_reached' | 'expired' | 'revoked' | 'refunded';
|
|
486
|
+
downloads_left: number | null;
|
|
487
|
+
download_limit: number | null;
|
|
488
|
+
downloads_used: number;
|
|
489
|
+
ends_at: string | null;
|
|
490
|
+
time_zone: string;
|
|
472
491
|
}
|
|
473
492
|
/**
|
|
474
493
|
* One subscription, with the actions the SERVER says are possible on it.
|
|
@@ -509,6 +528,68 @@ interface SdkCustomerSubscription {
|
|
|
509
528
|
can_cancel: boolean;
|
|
510
529
|
can_manage_payment_method: boolean;
|
|
511
530
|
};
|
|
531
|
+
/**
|
|
532
|
+
* The day an unpaid renewal's hold ends the subscription (PAST_DUE: access is
|
|
533
|
+
* off until the buyer pays). Null without a hold; optional only for deploy order.
|
|
534
|
+
*/
|
|
535
|
+
hold_ends_at?: string | null;
|
|
536
|
+
/**
|
|
537
|
+
* Set to end without renewing (cancelled at the period end, or a voided
|
|
538
|
+
* renewal): the instant it ends. Null while it renews; optional only for deploy order.
|
|
539
|
+
*/
|
|
540
|
+
ends_at?: string | null;
|
|
541
|
+
/**
|
|
542
|
+
* The open renewal invoice: what it costs, the day to pay by, and its hosted
|
|
543
|
+
* checkout. A plain link: the invoice already exists, so following it creates
|
|
544
|
+
* nothing. Null when nothing is open; optional only for deploy order.
|
|
545
|
+
*/
|
|
546
|
+
open_renewal?: SdkCustomerOpenRenewal | null;
|
|
547
|
+
/**
|
|
548
|
+
* The open pause: `scheduled` while the plan still runs until `starts_at`, then
|
|
549
|
+
* `paused`. Null without one; optional only for deploy order (an older SDK strips it).
|
|
550
|
+
*/
|
|
551
|
+
pause?: SdkCustomerPause | null;
|
|
552
|
+
/** What a new pause would be; null when the buyer cannot pause now. Optional for deploy order. */
|
|
553
|
+
pause_options?: SdkCustomerPauseOptions | null;
|
|
554
|
+
/** Set only when every pause of the last 12 months is used. Optional for deploy order. */
|
|
555
|
+
pause_limit?: {
|
|
556
|
+
pauses_per_year: number;
|
|
557
|
+
available_again_at: string;
|
|
558
|
+
} | null;
|
|
559
|
+
/** The Discord roles a pause takes ([] none); null when not known. Optional for deploy order. */
|
|
560
|
+
pause_access_roles?: string[] | null;
|
|
561
|
+
}
|
|
562
|
+
/** Why a buyer pauses (`SUBSCRIPTION_PAUSE_REASONS`). */
|
|
563
|
+
type SdkCustomerPauseReason = 'taking_a_break' | 'too_expensive' | 'not_using' | 'not_working' | 'other';
|
|
564
|
+
/** `PauseWire` on the dashboard wire. ISO instants. */
|
|
565
|
+
interface SdkCustomerPause {
|
|
566
|
+
state: 'scheduled' | 'paused';
|
|
567
|
+
starts_at: string;
|
|
568
|
+
/** Null: paused until someone resumes it (merchant and Developer API pauses). */
|
|
569
|
+
resume_at: string | null;
|
|
570
|
+
reason: SdkCustomerPauseReason | null;
|
|
571
|
+
}
|
|
572
|
+
/** `BuyerPauseView.pause_options`: the start, the lengths with their resume dates, and the pauses left after this one. */
|
|
573
|
+
interface SdkCustomerPauseOptions {
|
|
574
|
+
starts_at: string;
|
|
575
|
+
lengths: Array<{
|
|
576
|
+
days: 7 | 14 | 30 | 60 | 90;
|
|
577
|
+
resume_at: string;
|
|
578
|
+
}>;
|
|
579
|
+
reason_enabled: boolean;
|
|
580
|
+
pauses_left_after: number;
|
|
581
|
+
}
|
|
582
|
+
/** An open renewal invoice of a subscription (`CustomerOpenRenewal` on the dashboard wire). */
|
|
583
|
+
interface SdkCustomerOpenRenewal {
|
|
584
|
+
uniqid: string;
|
|
585
|
+
amount: string;
|
|
586
|
+
currency: string;
|
|
587
|
+
/** ISO instant: renewal date plus the shop's time to pay, or the hold end while on hold. */
|
|
588
|
+
pay_by: string;
|
|
589
|
+
pay_url: string;
|
|
590
|
+
/** The plan this invoice bills, which differs from `plan` while a scheduled interval change waits for it. */
|
|
591
|
+
interval: string;
|
|
592
|
+
interval_count: number;
|
|
512
593
|
}
|
|
513
594
|
/** One earned reward. `created_at` and `expires_at` are epoch SECONDS. */
|
|
514
595
|
interface SdkCustomerRewardActivity {
|
|
@@ -555,6 +636,21 @@ type SdkCustomerAffiliateLedgerStatus = 'waiting_payment' | 'earned' | 'in_payou
|
|
|
555
636
|
* "money paths do not belong on the account API"), so this template renders
|
|
556
637
|
* what the buyer has earned and says where the payout lives.
|
|
557
638
|
*/
|
|
639
|
+
/** What a referral earns the affiliate. Amounts are USD, like the affiliate ledger. */
|
|
640
|
+
interface SdkCustomerAffiliateRates {
|
|
641
|
+
/** The affiliate's rate (link, affiliate or tier), else the shop default. */
|
|
642
|
+
percent: number;
|
|
643
|
+
/** Up to three products set to No Commission, by title; `disabled_product_count` is the full count. */
|
|
644
|
+
disabled_products: string[];
|
|
645
|
+
disabled_product_count: number;
|
|
646
|
+
/** Products paying their own rate instead of `percent`; 0 when the affiliate's own rate overrides them. */
|
|
647
|
+
custom_rate_product_count: number;
|
|
648
|
+
cap_usd: string | null;
|
|
649
|
+
minimum_order_usd: string | null;
|
|
650
|
+
binding_mode: 'PER_ORDER' | 'LIFETIME_FIRST' | 'LIFETIME_LAST';
|
|
651
|
+
/** Null keeps a referred buyer for good. */
|
|
652
|
+
binding_days: number | null;
|
|
653
|
+
}
|
|
558
654
|
interface SdkCustomerAffiliateSummary {
|
|
559
655
|
/** `not_enrolled` is the availability gate for the whole referrals panel. */
|
|
560
656
|
state: string;
|
|
@@ -571,6 +667,8 @@ interface SdkCustomerAffiliateSummary {
|
|
|
571
667
|
converted: string;
|
|
572
668
|
paid: string;
|
|
573
669
|
};
|
|
670
|
+
/** "Your rates" (`readAffiliateRatesSummary`); null until the main link is approved and active. */
|
|
671
|
+
rates: SdkCustomerAffiliateRates | null;
|
|
574
672
|
links: SdkCustomerAffiliateLink[];
|
|
575
673
|
commissions: Array<{
|
|
576
674
|
id: string;
|
|
@@ -654,6 +752,30 @@ interface SdkCustomerWarrantyClaim {
|
|
|
654
752
|
claim_status: 'REQUESTED';
|
|
655
753
|
};
|
|
656
754
|
}
|
|
755
|
+
/**
|
|
756
|
+
* The buyer's review of one order. `can_review` is the server's call (paid,
|
|
757
|
+
* reviews on, inside the edit window); a storefront never derives it.
|
|
758
|
+
*/
|
|
759
|
+
interface SdkCustomerOrderReview {
|
|
760
|
+
can_review: boolean;
|
|
761
|
+
already_submitted: boolean;
|
|
762
|
+
feedback_uniqid: string | null;
|
|
763
|
+
product_title: string | null;
|
|
764
|
+
score: 1 | 3 | 5 | null;
|
|
765
|
+
/** The automatic positive review the shop posts when the buyer left none. */
|
|
766
|
+
is_automated: boolean;
|
|
767
|
+
message: string | null;
|
|
768
|
+
submitted_at: string | null;
|
|
769
|
+
/** The name the review would show; null when the shop shows none. */
|
|
770
|
+
reviewer_name: string | null;
|
|
771
|
+
anonymous: boolean;
|
|
772
|
+
/**
|
|
773
|
+
* The hosted review page on the checkout host, null unless `can_review`. The
|
|
774
|
+
* review is written there, never posted from a storefront (#1152). Absent on
|
|
775
|
+
* a backend that predates it.
|
|
776
|
+
*/
|
|
777
|
+
review_url?: string | null;
|
|
778
|
+
}
|
|
657
779
|
interface SdkCustomerDashboard {
|
|
658
780
|
shop: {
|
|
659
781
|
name: string;
|
|
@@ -679,6 +801,8 @@ interface SdkCustomerDashboard {
|
|
|
679
801
|
hold: string;
|
|
680
802
|
currency: string;
|
|
681
803
|
enabled: boolean;
|
|
804
|
+
/** The shop takes top-ups; the account's "Top up" link to the hosted top-up page shows only then. */
|
|
805
|
+
topups_allowed: boolean;
|
|
682
806
|
} | null;
|
|
683
807
|
invoices: SdkCustomerDashboardOrder[];
|
|
684
808
|
rewards: SdkCustomerRewards;
|
|
@@ -746,6 +870,12 @@ interface SdkCustomerOrderDetail {
|
|
|
746
870
|
taxPercentage: string;
|
|
747
871
|
currency: string;
|
|
748
872
|
createdAt: string;
|
|
873
|
+
/** The goods went to a gift recipient or wait for a reveal; absent from a backend older than the field. */
|
|
874
|
+
deliveryWithheld?: boolean;
|
|
875
|
+
/** What became of money an expired order took: NONE when none was recorded; null unless EXPIRED. */
|
|
876
|
+
expiredPayment?: 'NONE' | 'IN_REVIEW' | 'HELD' | 'SETTLED' | 'REFUNDED' | null;
|
|
877
|
+
/** When the paying attempt completed; kept on a disputed order, so the status decides whether it reads as paid. */
|
|
878
|
+
paidAt?: string | null;
|
|
749
879
|
lineItems: Array<{
|
|
750
880
|
id: string;
|
|
751
881
|
productTitle: string;
|
|
@@ -754,6 +884,8 @@ interface SdkCustomerOrderDetail {
|
|
|
754
884
|
quantity: number;
|
|
755
885
|
total: string;
|
|
756
886
|
deliveryText: string | null;
|
|
887
|
+
/** When the line was delivered; null until it was. */
|
|
888
|
+
deliveredAt: string | null;
|
|
757
889
|
deliveryStatus: SdkCustomerDeliveryStatus;
|
|
758
890
|
deliverySummary: SdkCustomerDeliverySummary | null;
|
|
759
891
|
}>;
|
|
@@ -1004,6 +1136,8 @@ interface ShoppexSdk {
|
|
|
1004
1136
|
page?: number;
|
|
1005
1137
|
limit?: number;
|
|
1006
1138
|
status?: string;
|
|
1139
|
+
/** One order-list group of the buyer status table: "paid" holds COMPLETED and AWAITING_STOCK. */
|
|
1140
|
+
statusGroup?: 'awaiting_payment' | 'paid' | 'refunded';
|
|
1007
1141
|
search?: string;
|
|
1008
1142
|
}): Promise<SdkResponse<SdkCustomerOrderPage>>;
|
|
1009
1143
|
/** One order, by the `uniqid` the list rows carry. */
|
|
@@ -1023,6 +1157,8 @@ interface ShoppexSdk {
|
|
|
1023
1157
|
*/
|
|
1024
1158
|
warranties(invoiceUniqid?: string): Promise<SdkResponse<SdkCustomerWarrantyList>>;
|
|
1025
1159
|
claimWarranty(uniqid: string, message?: string): Promise<SdkResponse<SdkCustomerWarrantyClaim>>;
|
|
1160
|
+
/** The buyer's review of one order, by the order's `uniqid`. */
|
|
1161
|
+
orderReview(uniqid: string): Promise<SdkResponse<SdkCustomerOrderReview>>;
|
|
1026
1162
|
/** Clears a license's hardware lock so the next activation claims it. */
|
|
1027
1163
|
resetLicenseHwid(uniqid: string): Promise<SdkResponse<unknown>>;
|
|
1028
1164
|
/** Renewal invoices for one subscription. */
|
|
@@ -1035,7 +1171,12 @@ interface ShoppexSdk {
|
|
|
1035
1171
|
cancel_at_period_end?: boolean;
|
|
1036
1172
|
reason?: string | null;
|
|
1037
1173
|
}): Promise<SdkResponse<unknown>>;
|
|
1038
|
-
|
|
1174
|
+
/** Pauses from `pause_options.starts_at` for one of its lengths, with a reason when the shop asks for one. */
|
|
1175
|
+
pauseSubscription(uniqid: string, options?: {
|
|
1176
|
+
length_days?: 7 | 14 | 30 | 60 | 90;
|
|
1177
|
+
reason?: SdkCustomerPauseReason | null;
|
|
1178
|
+
}): Promise<SdkResponse<unknown>>;
|
|
1179
|
+
/** "Resume now" on a paused plan; "Don't pause" on a scheduled pause. */
|
|
1039
1180
|
resumeSubscription(uniqid: string): Promise<SdkResponse<unknown>>;
|
|
1040
1181
|
/** The buyer's saved products. */
|
|
1041
1182
|
favorites(): Promise<SdkResponse<unknown>>;
|
|
@@ -1108,12 +1249,6 @@ interface ShoppexSdk {
|
|
|
1108
1249
|
page?: number;
|
|
1109
1250
|
per_page?: number;
|
|
1110
1251
|
}): Promise<SdkResponse<unknown>>;
|
|
1111
|
-
/** Server-prices a basket, including volume discounts, without writing. */
|
|
1112
|
-
quoteResellerOrder(items: Array<{
|
|
1113
|
-
product_id: string;
|
|
1114
|
-
variant_id?: string;
|
|
1115
|
-
quantity: number;
|
|
1116
|
-
}>): Promise<SdkResponse<unknown>>;
|
|
1117
1252
|
/** Page-based wholesale order history. */
|
|
1118
1253
|
resellerOrders(options?: {
|
|
1119
1254
|
page?: number;
|
|
@@ -1138,7 +1273,7 @@ interface SdkShopReview {
|
|
|
1138
1273
|
id: string;
|
|
1139
1274
|
/** 1-5, normalized by the SDK from the shop-feedback score (5/3/1). */
|
|
1140
1275
|
rating: number;
|
|
1141
|
-
/**
|
|
1276
|
+
/** The name the buyer chose to post under, or "Anonymous". */
|
|
1142
1277
|
author?: string;
|
|
1143
1278
|
customer_name?: string;
|
|
1144
1279
|
comment?: string;
|
|
@@ -1147,6 +1282,8 @@ interface SdkShopReview {
|
|
|
1147
1282
|
/** True when the review is tied to a real completed purchase. */
|
|
1148
1283
|
verified?: boolean;
|
|
1149
1284
|
is_automated?: boolean;
|
|
1285
|
+
/** The shop's reply under the review; null when it has not replied. */
|
|
1286
|
+
reply?: string | null;
|
|
1150
1287
|
created_at: string;
|
|
1151
1288
|
}
|
|
1152
1289
|
type AddonBarPreset = 'brand_blue' | 'emerald' | 'sunset' | 'rose' | 'charcoal' | 'custom';
|
|
@@ -1407,6 +1544,16 @@ interface StorefrontPriceVariant {
|
|
|
1407
1544
|
quantityMax: number | null;
|
|
1408
1545
|
imageUrl: string | null;
|
|
1409
1546
|
isFeatured: boolean;
|
|
1547
|
+
/** The option's own billing cadence; null bills at the product's (`subscriptionForVariant`). */
|
|
1548
|
+
billingInterval: {
|
|
1549
|
+
unit: SubscriptionIntervalUnit;
|
|
1550
|
+
count: number;
|
|
1551
|
+
} | null;
|
|
1552
|
+
/**
|
|
1553
|
+
* The option's own trial (`'none'`: the option has no trial); null starts it
|
|
1554
|
+
* with the product's (`subscriptionForVariant`).
|
|
1555
|
+
*/
|
|
1556
|
+
ownTrial: SubscriptionTrial | 'none' | null;
|
|
1410
1557
|
}
|
|
1411
1558
|
interface VolumeDiscountRule {
|
|
1412
1559
|
quantity: number;
|
|
@@ -1586,7 +1733,7 @@ type YouReceive = {
|
|
|
1586
1733
|
};
|
|
1587
1734
|
declare function resolveYouReceive(product: Pick<StorefrontProduct, 'deliverable' | 'unitLabelSingular'>): YouReceive | null;
|
|
1588
1735
|
/**
|
|
1589
|
-
* How often a subscription product is charged, and
|
|
1736
|
+
* How often a subscription product is charged, and the trial it starts with.
|
|
1590
1737
|
*
|
|
1591
1738
|
* PARITY CONTRACT. The Easy lane derives the same three facts from the same
|
|
1592
1739
|
* flat wire fields in
|
|
@@ -1605,13 +1752,38 @@ interface ProductSubscription {
|
|
|
1605
1752
|
intervalUnit: SubscriptionIntervalUnit | null;
|
|
1606
1753
|
/** Intervals per charge, at least 1. */
|
|
1607
1754
|
intervalCount: number;
|
|
1608
|
-
/**
|
|
1609
|
-
|
|
1755
|
+
/** The trial the plan starts with; null when it has none. */
|
|
1756
|
+
trial: SubscriptionTrial | null;
|
|
1610
1757
|
}
|
|
1758
|
+
/**
|
|
1759
|
+
* A free trial, or a paid intro: `price` in `currency` (the product currency,
|
|
1760
|
+
* as the wire states it) for the first `days`. The trial checkout bills
|
|
1761
|
+
* (`resolveProductTrial`).
|
|
1762
|
+
*/
|
|
1763
|
+
type SubscriptionTrial = {
|
|
1764
|
+
kind: 'free';
|
|
1765
|
+
days: number;
|
|
1766
|
+
} | {
|
|
1767
|
+
kind: 'paid';
|
|
1768
|
+
days: number;
|
|
1769
|
+
price: number;
|
|
1770
|
+
currency: string;
|
|
1771
|
+
};
|
|
1611
1772
|
/** The cadence as it reads next to a price: "per month", "every 3 months". */
|
|
1612
1773
|
declare function formatSubscriptionCadence(subscription: ProductSubscription): string;
|
|
1613
|
-
/**
|
|
1614
|
-
|
|
1774
|
+
/**
|
|
1775
|
+
* "7-day free trial" for a free trial, "$4.99 for 7 days" for a paid intro
|
|
1776
|
+
* (`formatAmount` prints its price); empty when the plan has no trial.
|
|
1777
|
+
*/
|
|
1778
|
+
declare function formatSubscriptionTrial(subscription: ProductSubscription, formatAmount: (amount: number, currency: string) => string): string;
|
|
1779
|
+
/**
|
|
1780
|
+
* The subscription as the selected option bills it: an option with its own
|
|
1781
|
+
* interval (`billing_interval`, stored with its count or not at all) is charged
|
|
1782
|
+
* at that cadence, every other one at the product's. An option with its own
|
|
1783
|
+
* trial ("No trial" included) starts with it, every other one with the
|
|
1784
|
+
* product's: the rule checkout's `resolveProductTrial` applies.
|
|
1785
|
+
*/
|
|
1786
|
+
declare function subscriptionForVariant(subscription: ProductSubscription, variant: Pick<StorefrontPriceVariant, 'billingInterval' | 'ownTrial'> | null | undefined): ProductSubscription;
|
|
1615
1787
|
/**
|
|
1616
1788
|
* What a product image shows, from the backend's pixel analysis. `art` is a
|
|
1617
1789
|
* cover, artwork or photo; `logo` is a flat mark, drawn on a contrasting plate.
|
|
@@ -3204,6 +3376,8 @@ interface ShopReview {
|
|
|
3204
3376
|
verified: boolean;
|
|
3205
3377
|
/** Left by the shop's review automation, not written by the buyer. */
|
|
3206
3378
|
automated: boolean;
|
|
3379
|
+
/** The shop's reply under the review; null when it has not replied. */
|
|
3380
|
+
reply: string | null;
|
|
3207
3381
|
}
|
|
3208
3382
|
type ShopReviewsState = {
|
|
3209
3383
|
status: 'loading';
|
|
@@ -3531,4 +3705,4 @@ declare function useOnlineUserCount(): number | null;
|
|
|
3531
3705
|
*/
|
|
3532
3706
|
declare function resolveProductVideoEmbedSrc(value: unknown): string | null;
|
|
3533
3707
|
|
|
3534
|
-
export { ACCOUNT_ARTIFACT_CAPABILITIES, ACCOUNT_PATH, ACCOUNT_PATH_ALIAS, ACCOUNT_ROUTE_MESSAGE_KEYS, ACCOUNT_STOREFRONT_ROUTES, ACCOUNT_TABS, type AccountRouteMessageKey, type AccountRouteParts, type AccountTab, type AccountView, type BuyBoxVariantModel, CATALOG_PAGE_SIZE, CATALOG_SORTS, CATALOG_SORT_LABELS, type CartBoundsHeal, CartProvider, type CartQuoteLineBounds, type CartTotals, type CartView, type CartViewLine, type CatalogCardModel, type CatalogPage, type CatalogSort, type CheckoutFieldGroup, type CheckoutFieldValues, type CheckoutFields, type ContactFormValues, type ContactSubmissionContext, DEFAULT_ACCOUNT_TAB, DEFAULT_LOW_STOCK_THRESHOLD, DELIVERY_TIME_UNITS, type DeliveryPromise, type DeliveryTimeUnit, FAVORITES_CHANGED_EVENT, type FavoriteToggleResult, type FavoritesApi, FavoritesProvider, type FavoritesSnapshot, type FavoritesStatus, type FavoritesStore, type FavoritesTransport, type GroupCardModel, IMPLEMENTED_ACCOUNT_TABS, type ImplementedAccountTab, type LicenseStatement, type LicenseTerm, type LinePricing, MAX_PAY_WHAT_YOU_WANT_PRICE, type MenuNavLink, type MenuSlot, type NavLink, type NavigationLinks, PRODUCT_BADGE_ICON_NAMES, type PagedShopReviewsState, type ProductAddon, type ProductAutomaticDeal, type ProductBadge, type ProductBadgeIconName, type ProductBundle, type ProductBundleItem, type ProductCardModel, type ProductCategoryRef, type ProductContentTab, type ProductCustomField, type ProductDeliverable, type ProductDeliveryType, type ProductDetailModel, type ProductFaq, type ProductImage, type ProductImageKind, type ProductRatingModel, type ProductServiceStatus, type ProductSubscription, type ProductType, QUOTE_UNAVAILABLE_CHECKOUT_ERROR, type RatingStars, type ResellerProgramSummary, type RewardProgramItem, type RewardProgramSummary, SERVICE_STATES, SERVING_CONTEXT_HINT, SHOP_REVIEW_PAGE_SIZE, STOREFRONT_SORT_KEYS, type SdkCartAddOptions, type SdkCartAddon, type SdkCartAppliedDiscount, type SdkCartCodeSource, type SdkCartItem, type SdkCartQuote, type SdkCartQuoteLine, type SdkCheckoutResult, type SdkCustomerAffiliateLedgerStatus, type SdkCustomerAffiliateLink, type SdkCustomerAffiliateLinkCreated, type SdkCustomerAffiliateSummary, type SdkCustomerDashboard, type SdkCustomerDashboardOrder, type SdkCustomerDeliverable, type SdkCustomerDeliveryStatus, type SdkCustomerDeliverySummary, type SdkCustomerInvoicePdf, type SdkCustomerLicense, type SdkCustomerLoyalty, type SdkCustomerLoyaltyRedeem, type SdkCustomerLoyaltyTransactionType, type SdkCustomerNotificationPreferences, type SdkCustomerOrderDetail, type SdkCustomerOrderPage, type SdkCustomerOrderSummary, type SdkCustomerRewardActivity, type SdkCustomerRewards, type SdkCustomerSubscription, type SdkCustomerTicketSummary, type SdkCustomerWarranty, type SdkCustomerWarrantyClaim, type SdkCustomerWarrantyClaimStatus, type SdkCustomerWarrantyList, type SdkCustomerWarrantyStatus, type SdkEligibleCartDeal, type SdkInitOptions, type SdkMenu, type SdkMenuItem, type SdkPage, type SdkRecentSaleEntry, type SdkResponse, type SdkShopReview, type SdkShopReviewsSummary, type ServiceState, type ShopPageFaqItem, type ShopPageModel, type ShopPageState, type ShopReview, type ShopReviewLabels, type ShopReviewsPageResult, type ShopReviewsState, type ShoppexSdk, type SocialLink, type SocialNetwork, type StatusPageEntry, type StatusPageModel, type StockAlertRequest, type StockAlertResult, type StockChip, type StockTone, type StorefrontAddon, type StorefrontCatalog, type StorefrontCategory, type StorefrontData, type StorefrontGroup, type StorefrontListingItem, type StorefrontPaymentMethod, type StorefrontPaymentMethodKind, type StorefrontPriceVariant, type StorefrontProduct, StorefrontProvider, type StorefrontSettings, type StorefrontShop, type StorefrontShopStats, type StorefrontSortKey, type SubscriptionIntervalUnit, type SupportChannel, type VolumeDiscountRule, type YouReceive, accountOrderHref, accountRouteMessage, accountTabHref, accountTabLabelKey, addonChoiceMissing, averageRating, badgesForCard, badgesForProductPage, buildCartTotals, buildCartView, buildCustomFieldPayload, buildInitialCheckoutFieldValues, buildProductDetail, buildStatusPageModel, buildStorefrontCatalog, calculateDisplayLineTotal, calculateLinePricing, canRequestStockAlert, canonicalAccountPath, checkoutFieldKey, checkoutFieldWriteRepriced, checkoutNeedsDetails, clampQuantity, clearRecoveredQuoteCheckoutError, createFavoritesStore, filterCatalogCards, findStorefrontProduct, firstOptionalString, flattenMerchantHtmlToText, formatCompactCount, formatDeliveryTime, formatLicenseTerm, formatMoney, formatSubscriptionCadence, formatSubscriptionTrial, getAuthoredContent, getBuyerCurrency, getProductGroups, getProducts, getShoppex, getStorefrontAddons, getStorefrontCategories, getStorefrontListing, getStorefrontSettings, getStorefrontShop, hasInjectedStorefrontData, isAccountTab, isBlankMerchantHtml, isCardSoldOut, isCheckboxValueChecked, isImplementedAccountTab, isProductSoldOut, isRecord, isSelectionSoldOut, loadLatestWrittenReviews, loadShopPage, loadShopReviewsPage, missingRequiredCheckoutValues, notifyFavoritesChanged, optionalBoolean, optionalString, optionalStringWithDefault, paginateCatalogCards, parseAccountPath, parseCartQuoteLines, parseEnum, parseFiniteNumber, parseProductBadges, parseServiceStatus, parseStorefrontSortKey, readCheckoutNeedsDetails, readStorefrontData, requestStockAlert, requireArray, requireBoolean, requireNumber, requireRecord, requireString, requireStringFromKeys, requireUnknownRecord, resolveAccountView, resolveBadgeForeground, resolveCartBoundsHeals, resolveCategorySelection, resolveCheckoutFields, resolveDeliveryPromise, resolveDisplayStock, resolveHideStockCounter, resolveLicenseTerm, resolveMenuLinksForSlot, resolvePayWhatYouWantMinimum, resolveProductVideoEmbedSrc, resolveQuantityBounds, resolveSupportChannels, resolveUnsellableLineIds, resolveVariantStock, resolveYouReceive, reviewsForProduct, roundCurrency, sanitizeMerchantHtml, sdkFavoritesTransport, sortCatalogCards, startCartMutation, stripMerchantHtmlImages, submitContactTicket, toShopReviews, toStarCount, useCart, useFavorites, useNavigationLinks, useOnlineUserCount, usePagedShopReviews, useShopReviews, useStorefront, validateCheckoutFieldValue, validateCheckoutFields, validateContactSubmission, withRequiredAddons };
|
|
3708
|
+
export { ACCOUNT_ARTIFACT_CAPABILITIES, ACCOUNT_PATH, ACCOUNT_PATH_ALIAS, ACCOUNT_ROUTE_MESSAGE_KEYS, ACCOUNT_STOREFRONT_ROUTES, ACCOUNT_TABS, type AccountRouteMessageKey, type AccountRouteParts, type AccountTab, type AccountView, type BuyBoxVariantModel, CATALOG_PAGE_SIZE, CATALOG_SORTS, CATALOG_SORT_LABELS, type CartBoundsHeal, CartProvider, type CartQuoteLineBounds, type CartTotals, type CartView, type CartViewLine, type CatalogCardModel, type CatalogPage, type CatalogSort, type CheckoutFieldGroup, type CheckoutFieldValues, type CheckoutFields, type ContactFormValues, type ContactSubmissionContext, DEFAULT_ACCOUNT_TAB, DEFAULT_LOW_STOCK_THRESHOLD, DELIVERY_TIME_UNITS, type DeliveryPromise, type DeliveryTimeUnit, FAVORITES_CHANGED_EVENT, type FavoriteToggleResult, type FavoritesApi, FavoritesProvider, type FavoritesSnapshot, type FavoritesStatus, type FavoritesStore, type FavoritesTransport, type GroupCardModel, IMPLEMENTED_ACCOUNT_TABS, type ImplementedAccountTab, type LicenseStatement, type LicenseTerm, type LinePricing, MAX_PAY_WHAT_YOU_WANT_PRICE, type MenuNavLink, type MenuSlot, type NavLink, type NavigationLinks, PRODUCT_BADGE_ICON_NAMES, type PagedShopReviewsState, type ProductAddon, type ProductAutomaticDeal, type ProductBadge, type ProductBadgeIconName, type ProductBundle, type ProductBundleItem, type ProductCardModel, type ProductCategoryRef, type ProductContentTab, type ProductCustomField, type ProductDeliverable, type ProductDeliveryType, type ProductDetailModel, type ProductFaq, type ProductImage, type ProductImageKind, type ProductRatingModel, type ProductServiceStatus, type ProductSubscription, type ProductType, QUOTE_UNAVAILABLE_CHECKOUT_ERROR, type RatingStars, type ResellerProgramSummary, type RewardProgramItem, type RewardProgramSummary, SERVICE_STATES, SERVING_CONTEXT_HINT, SHOP_REVIEW_PAGE_SIZE, STOREFRONT_SORT_KEYS, type SdkCartAddOptions, type SdkCartAddon, type SdkCartAppliedDiscount, type SdkCartCodeSource, type SdkCartItem, type SdkCartQuote, type SdkCartQuoteLine, type SdkCheckoutResult, type SdkCustomerAffiliateLedgerStatus, type SdkCustomerAffiliateLink, type SdkCustomerAffiliateLinkCreated, type SdkCustomerAffiliateRates, type SdkCustomerAffiliateSummary, type SdkCustomerDashboard, type SdkCustomerDashboardOrder, type SdkCustomerDeliverable, type SdkCustomerDeliveryStatus, type SdkCustomerDeliverySummary, type SdkCustomerFileAccess, type SdkCustomerInvoicePdf, type SdkCustomerLicense, type SdkCustomerLoyalty, type SdkCustomerLoyaltyRedeem, type SdkCustomerLoyaltyTransactionType, type SdkCustomerNotificationPreferences, type SdkCustomerOpenRenewal, type SdkCustomerOrderDetail, type SdkCustomerOrderPage, type SdkCustomerOrderReview, type SdkCustomerOrderSummary, type SdkCustomerPause, type SdkCustomerPauseOptions, type SdkCustomerPauseReason, type SdkCustomerRewardActivity, type SdkCustomerRewards, type SdkCustomerSubscription, type SdkCustomerTicketSummary, type SdkCustomerWarranty, type SdkCustomerWarrantyClaim, type SdkCustomerWarrantyClaimStatus, type SdkCustomerWarrantyList, type SdkCustomerWarrantyStatus, type SdkEligibleCartDeal, type SdkInitOptions, type SdkMenu, type SdkMenuItem, type SdkPage, type SdkRecentSaleEntry, type SdkResponse, type SdkShopReview, type SdkShopReviewsSummary, type ServiceState, type ShopPageFaqItem, type ShopPageModel, type ShopPageState, type ShopReview, type ShopReviewLabels, type ShopReviewsPageResult, type ShopReviewsState, type ShoppexSdk, type SocialLink, type SocialNetwork, type StatusPageEntry, type StatusPageModel, type StockAlertRequest, type StockAlertResult, type StockChip, type StockTone, type StorefrontAddon, type StorefrontCatalog, type StorefrontCategory, type StorefrontData, type StorefrontGroup, type StorefrontListingItem, type StorefrontPaymentMethod, type StorefrontPaymentMethodKind, type StorefrontPriceVariant, type StorefrontProduct, StorefrontProvider, type StorefrontSettings, type StorefrontShop, type StorefrontShopStats, type StorefrontSortKey, type SubscriptionIntervalUnit, type SubscriptionTrial, type SupportChannel, type VolumeDiscountRule, type YouReceive, accountOrderHref, accountRouteMessage, accountTabHref, accountTabLabelKey, addonChoiceMissing, averageRating, badgesForCard, badgesForProductPage, buildCartTotals, buildCartView, buildCustomFieldPayload, buildInitialCheckoutFieldValues, buildProductDetail, buildStatusPageModel, buildStorefrontCatalog, calculateDisplayLineTotal, calculateLinePricing, canRequestStockAlert, canonicalAccountPath, checkoutFieldKey, checkoutFieldWriteRepriced, checkoutNeedsDetails, clampQuantity, clearRecoveredQuoteCheckoutError, createFavoritesStore, filterCatalogCards, findStorefrontProduct, firstOptionalString, flattenMerchantHtmlToText, formatCompactCount, formatDeliveryTime, formatLicenseTerm, formatMoney, formatSubscriptionCadence, formatSubscriptionTrial, getAuthoredContent, getBuyerCurrency, getProductGroups, getProducts, getShoppex, getStorefrontAddons, getStorefrontCategories, getStorefrontListing, getStorefrontSettings, getStorefrontShop, hasInjectedStorefrontData, isAccountTab, isBlankMerchantHtml, isCardSoldOut, isCheckboxValueChecked, isImplementedAccountTab, isProductSoldOut, isRecord, isSelectionSoldOut, loadLatestWrittenReviews, loadShopPage, loadShopReviewsPage, missingRequiredCheckoutValues, notifyFavoritesChanged, optionalBoolean, optionalString, optionalStringWithDefault, paginateCatalogCards, parseAccountPath, parseCartQuoteLines, parseEnum, parseFiniteNumber, parseProductBadges, parseServiceStatus, parseStorefrontSortKey, readCheckoutNeedsDetails, readStorefrontData, requestStockAlert, requireArray, requireBoolean, requireNumber, requireRecord, requireString, requireStringFromKeys, requireUnknownRecord, resolveAccountView, resolveBadgeForeground, resolveCartBoundsHeals, resolveCategorySelection, resolveCheckoutFields, resolveDeliveryPromise, resolveDisplayStock, resolveHideStockCounter, resolveLicenseTerm, resolveMenuLinksForSlot, resolvePayWhatYouWantMinimum, resolveProductVideoEmbedSrc, resolveQuantityBounds, resolveSupportChannels, resolveUnsellableLineIds, resolveVariantStock, resolveYouReceive, reviewsForProduct, roundCurrency, sanitizeMerchantHtml, sdkFavoritesTransport, sortCatalogCards, startCartMutation, stripMerchantHtmlImages, submitContactTicket, subscriptionForVariant, toShopReviews, toStarCount, useCart, useFavorites, useNavigationLinks, useOnlineUserCount, usePagedShopReviews, useShopReviews, useStorefront, validateCheckoutFieldValue, validateCheckoutFields, validateContactSubmission, withRequiredAddons };
|
package/dist/index.js
CHANGED
|
@@ -575,9 +575,21 @@ function formatSubscriptionCadence(subscription) {
|
|
|
575
575
|
const noun = SUBSCRIPTION_INTERVAL_NOUNS[unit];
|
|
576
576
|
return subscription.intervalCount === 1 ? `per ${noun}` : `every ${subscription.intervalCount} ${noun}s`;
|
|
577
577
|
}
|
|
578
|
-
function formatSubscriptionTrial(subscription) {
|
|
579
|
-
const
|
|
580
|
-
|
|
578
|
+
function formatSubscriptionTrial(subscription, formatAmount) {
|
|
579
|
+
const trial = subscription.trial;
|
|
580
|
+
if (!trial) return "";
|
|
581
|
+
if (trial.kind === "free") return `${trial.days}-day free trial`;
|
|
582
|
+
return `${formatAmount(trial.price, trial.currency)} for ${trial.days} ${trial.days === 1 ? "day" : "days"}`;
|
|
583
|
+
}
|
|
584
|
+
function subscriptionForVariant(subscription, variant) {
|
|
585
|
+
const own = variant?.billingInterval;
|
|
586
|
+
const ownTrial = variant?.ownTrial;
|
|
587
|
+
if (!own && !ownTrial) return subscription;
|
|
588
|
+
return {
|
|
589
|
+
...subscription,
|
|
590
|
+
...own ? { intervalUnit: own.unit, intervalCount: own.count } : {},
|
|
591
|
+
...ownTrial ? { trial: ownTrial === "none" ? null : ownTrial } : {}
|
|
592
|
+
};
|
|
581
593
|
}
|
|
582
594
|
function parseSubscription(product, productType) {
|
|
583
595
|
if (productType !== "SUBSCRIPTION") return null;
|
|
@@ -587,9 +599,29 @@ function parseSubscription(product, productType) {
|
|
|
587
599
|
return {
|
|
588
600
|
intervalUnit: unit,
|
|
589
601
|
intervalCount: count,
|
|
590
|
-
|
|
602
|
+
trial: parseTrial(product)
|
|
591
603
|
};
|
|
592
604
|
}
|
|
605
|
+
function parseVariantBillingInterval(variant) {
|
|
606
|
+
const unit = SUBSCRIPTION_INTERVAL_UNITS.find((entry) => entry === variant.billing_interval);
|
|
607
|
+
const count = normalizePositiveDays(variant.billing_interval_count);
|
|
608
|
+
return unit && count ? { unit, count } : null;
|
|
609
|
+
}
|
|
610
|
+
function parseTrial(record) {
|
|
611
|
+
const days = record.trial_days;
|
|
612
|
+
if (typeof days !== "number" || !Number.isInteger(days) || days < 1) return null;
|
|
613
|
+
if (record.trial_kind === "free") return { kind: "free", days };
|
|
614
|
+
const price = typeof record.trial_price === "string" ? Number(record.trial_price) : Number.NaN;
|
|
615
|
+
if (record.trial_kind === "paid" && price > 0 && typeof record.trial_price_currency === "string") {
|
|
616
|
+
return { kind: "paid", days, price, currency: record.trial_price_currency };
|
|
617
|
+
}
|
|
618
|
+
return null;
|
|
619
|
+
}
|
|
620
|
+
function parseVariantTrial(variant) {
|
|
621
|
+
const kind = variant.trial_kind;
|
|
622
|
+
if (kind !== "none" && kind !== "free" && kind !== "paid") return null;
|
|
623
|
+
return parseTrial(variant) ?? "none";
|
|
624
|
+
}
|
|
593
625
|
var PAYMENT_METHOD_KINDS = ["card", "wallet", "crypto"];
|
|
594
626
|
function parsePaymentMethods(value) {
|
|
595
627
|
if (!Array.isArray(value)) {
|
|
@@ -896,11 +928,7 @@ function parseProduct(value, index) {
|
|
|
896
928
|
imageUrl: resolveProductImage(product),
|
|
897
929
|
imageUrls: images.map((image) => image.url),
|
|
898
930
|
images,
|
|
899
|
-
stock:
|
|
900
|
-
normalizeStock(product.stock, `${context}.stock`),
|
|
901
|
-
product.orderable,
|
|
902
|
-
product.supplier_backed
|
|
903
|
-
),
|
|
931
|
+
stock: normalizeStock(product.stock, `${context}.stock`),
|
|
904
932
|
lowStockThreshold: normalizeLowStockThreshold(
|
|
905
933
|
normalizeOptionalNonNegativeNumber(product.quantity_warning)
|
|
906
934
|
),
|
|
@@ -1019,13 +1047,11 @@ function parsePriceVariants(value, productContext) {
|
|
|
1019
1047
|
label: requireStringFromKeys(variant, ["label", "title"], context),
|
|
1020
1048
|
description: optionalString(variant.description),
|
|
1021
1049
|
license: parseVariantLicense(variant),
|
|
1050
|
+
billingInterval: parseVariantBillingInterval(variant),
|
|
1051
|
+
ownTrial: parseVariantTrial(variant),
|
|
1022
1052
|
price: unitPrice,
|
|
1023
1053
|
baseUnitPrice: unitPrice,
|
|
1024
|
-
stock:
|
|
1025
|
-
normalizeStock(variant.stock, `${context}.stock`),
|
|
1026
|
-
variant.orderable,
|
|
1027
|
-
variant.supplier_backed
|
|
1028
|
-
),
|
|
1054
|
+
stock: normalizeStock(variant.stock, `${context}.stock`),
|
|
1029
1055
|
quantityMin,
|
|
1030
1056
|
quantityMax: normalizeMaximum(variant.quantity_max, quantityMin ?? 1, `${context}.quantity_max`),
|
|
1031
1057
|
imageUrl: optionalString(variant.image_url),
|
|
@@ -1294,11 +1320,6 @@ function normalizeStock(value, context) {
|
|
|
1294
1320
|
const stock = parseFiniteNumber(value, context);
|
|
1295
1321
|
return stock < 0 ? null : Math.floor(stock);
|
|
1296
1322
|
}
|
|
1297
|
-
function applyOrderable(stock, orderable, supplierBacked) {
|
|
1298
|
-
if (orderable !== true) return stock;
|
|
1299
|
-
if (supplierBacked === true) return null;
|
|
1300
|
-
return stock === 0 ? null : stock;
|
|
1301
|
-
}
|
|
1302
1323
|
function normalizeOptionalNonNegativeNumber(value) {
|
|
1303
1324
|
if (value === null || value === void 0 || value === "") return null;
|
|
1304
1325
|
const parsed = Number(value);
|
|
@@ -2821,7 +2842,8 @@ function toShopReviews(rows, labels) {
|
|
|
2821
2842
|
timestamp,
|
|
2822
2843
|
productTitle: row.product_title?.trim() || null,
|
|
2823
2844
|
verified: row.verified === true,
|
|
2824
|
-
automated: row.is_automated === true
|
|
2845
|
+
automated: row.is_automated === true,
|
|
2846
|
+
reply: row.reply?.trim() || null
|
|
2825
2847
|
};
|
|
2826
2848
|
}).sort((a, b) => b.timestamp - a.timestamp);
|
|
2827
2849
|
}
|
|
@@ -3190,6 +3212,7 @@ export {
|
|
|
3190
3212
|
startCartMutation,
|
|
3191
3213
|
stripMerchantHtmlImages,
|
|
3192
3214
|
submitContactTicket,
|
|
3215
|
+
subscriptionForVariant,
|
|
3193
3216
|
toShopReviews,
|
|
3194
3217
|
toStarCount,
|
|
3195
3218
|
useCart,
|