@shoppexio/storefront-react 0.4.0 → 0.6.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 +13 -0
- package/dist/account.css +22 -0
- package/dist/account.js +2311 -302
- package/dist/account.js.map +1 -1
- package/dist/index.d.ts +137 -18
- package/dist/index.js +29 -5
- package/dist/index.js.map +1 -1
- package/eject/account/account-payment-method.ts +7 -1
- package/eject/account/account-subscriptions.ts +162 -8
- package/eject/account/buyer-invoice-status.ts +100 -0
- package/eject/account/downloads.tsx +45 -13
- package/eject/account/messages/ar.json +114 -14
- package/eject/account/messages/de.json +114 -14
- package/eject/account/messages/en.json +114 -14
- package/eject/account/messages/es.json +114 -14
- package/eject/account/messages/fi.json +114 -14
- package/eject/account/messages/fr.json +114 -14
- package/eject/account/messages/hi.json +114 -14
- package/eject/account/messages/it.json +114 -14
- package/eject/account/messages/lt.json +114 -14
- package/eject/account/messages/nl.json +114 -14
- package/eject/account/messages/pl.json +114 -14
- package/eject/account/messages/pt.json +114 -14
- package/eject/account/messages/ru.json +114 -14
- package/eject/account/messages/tr.json +114 -14
- package/eject/account/messages/uk.json +114 -14
- package/eject/account/messages/zh.json +114 -14
- package/eject/account/orders.tsx +115 -41
- package/eject/account/reseller.tsx +3 -2
- package/eject/account/shared.tsx +21 -3
- package/eject/account/subscriptions.tsx +371 -49
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -529,11 +529,96 @@ interface SdkCustomerSubscription {
|
|
|
529
529
|
can_manage_payment_method: boolean;
|
|
530
530
|
};
|
|
531
531
|
/**
|
|
532
|
-
* The
|
|
533
|
-
*
|
|
534
|
-
* nothing. Optional only for deploy order; a missing value reads as null.
|
|
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.
|
|
535
534
|
*/
|
|
536
|
-
|
|
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
|
+
/** The running coupon term; null without one. Optional for deploy order. */
|
|
562
|
+
discount?: SdkCustomerSubscriptionDiscount | null;
|
|
563
|
+
}
|
|
564
|
+
/**
|
|
565
|
+
* `SubscriptionCouponTermView` on the dashboard wire: the code, what it takes off each payment,
|
|
566
|
+
* the payments it still discounts, and what the renewals cost. Every amount is the renewal-pricing
|
|
567
|
+
* function's, in `currency`.
|
|
568
|
+
*/
|
|
569
|
+
interface SdkCustomerSubscriptionDiscount {
|
|
570
|
+
code: string;
|
|
571
|
+
discount_type: 'PERCENTAGE' | 'FIXED';
|
|
572
|
+
/** The percent, or the fixed amount. */
|
|
573
|
+
discount_value: string;
|
|
574
|
+
/** The cap on one payment's discount; null without one. */
|
|
575
|
+
max_discount: string | null;
|
|
576
|
+
currency: string;
|
|
577
|
+
duration: 'ONCE' | 'REPEATING' | 'FOREVER';
|
|
578
|
+
/** ONCE: 1, REPEATING: N, FOREVER: null (every payment). */
|
|
579
|
+
payments_total: number | null;
|
|
580
|
+
/** Discounted payments completed; an open or voided renewal does not count. */
|
|
581
|
+
payments_used: number;
|
|
582
|
+
/** A discounted renewal. */
|
|
583
|
+
discounted_amount: string;
|
|
584
|
+
/** A renewal at the plan price, once the term ends. */
|
|
585
|
+
full_amount: string;
|
|
586
|
+
/** What each discounted renewal saves. */
|
|
587
|
+
discount_amount: string;
|
|
588
|
+
/** What the next renewal charges: `discounted_amount`, or `full_amount` once every discounted payment is issued. */
|
|
589
|
+
next_amount: string;
|
|
590
|
+
}
|
|
591
|
+
/** Why a buyer pauses (`SUBSCRIPTION_PAUSE_REASONS`). */
|
|
592
|
+
type SdkCustomerPauseReason = 'taking_a_break' | 'too_expensive' | 'not_using' | 'not_working' | 'other';
|
|
593
|
+
/** `PauseWire` on the dashboard wire. ISO instants. */
|
|
594
|
+
interface SdkCustomerPause {
|
|
595
|
+
state: 'scheduled' | 'paused';
|
|
596
|
+
starts_at: string;
|
|
597
|
+
/** Null: paused until someone resumes it (merchant and Developer API pauses). */
|
|
598
|
+
resume_at: string | null;
|
|
599
|
+
reason: SdkCustomerPauseReason | null;
|
|
600
|
+
}
|
|
601
|
+
/** `BuyerPauseView.pause_options`: the start, the lengths with their resume dates, and the pauses left after this one. */
|
|
602
|
+
interface SdkCustomerPauseOptions {
|
|
603
|
+
starts_at: string;
|
|
604
|
+
lengths: Array<{
|
|
605
|
+
days: 7 | 14 | 30 | 60 | 90;
|
|
606
|
+
resume_at: string;
|
|
607
|
+
}>;
|
|
608
|
+
reason_enabled: boolean;
|
|
609
|
+
pauses_left_after: number;
|
|
610
|
+
}
|
|
611
|
+
/** An open renewal invoice of a subscription (`CustomerOpenRenewal` on the dashboard wire). */
|
|
612
|
+
interface SdkCustomerOpenRenewal {
|
|
613
|
+
uniqid: string;
|
|
614
|
+
amount: string;
|
|
615
|
+
currency: string;
|
|
616
|
+
/** ISO instant: renewal date plus the shop's time to pay, or the hold end while on hold. */
|
|
617
|
+
pay_by: string;
|
|
618
|
+
pay_url: string;
|
|
619
|
+
/** The plan this invoice bills, which differs from `plan` while a scheduled interval change waits for it. */
|
|
620
|
+
interval: string;
|
|
621
|
+
interval_count: number;
|
|
537
622
|
}
|
|
538
623
|
/** One earned reward. `created_at` and `expires_at` are epoch SECONDS. */
|
|
539
624
|
interface SdkCustomerRewardActivity {
|
|
@@ -814,6 +899,12 @@ interface SdkCustomerOrderDetail {
|
|
|
814
899
|
taxPercentage: string;
|
|
815
900
|
currency: string;
|
|
816
901
|
createdAt: string;
|
|
902
|
+
/** The goods went to a gift recipient or wait for a reveal; absent from a backend older than the field. */
|
|
903
|
+
deliveryWithheld?: boolean;
|
|
904
|
+
/** What became of money an expired order took: NONE when none was recorded; null unless EXPIRED. */
|
|
905
|
+
expiredPayment?: 'NONE' | 'IN_REVIEW' | 'HELD' | 'SETTLED' | 'REFUNDED' | null;
|
|
906
|
+
/** When the paying attempt completed; kept on a disputed order, so the status decides whether it reads as paid. */
|
|
907
|
+
paidAt?: string | null;
|
|
817
908
|
lineItems: Array<{
|
|
818
909
|
id: string;
|
|
819
910
|
productTitle: string;
|
|
@@ -822,6 +913,8 @@ interface SdkCustomerOrderDetail {
|
|
|
822
913
|
quantity: number;
|
|
823
914
|
total: string;
|
|
824
915
|
deliveryText: string | null;
|
|
916
|
+
/** When the line was delivered; null until it was. */
|
|
917
|
+
deliveredAt: string | null;
|
|
825
918
|
deliveryStatus: SdkCustomerDeliveryStatus;
|
|
826
919
|
deliverySummary: SdkCustomerDeliverySummary | null;
|
|
827
920
|
}>;
|
|
@@ -1072,6 +1165,8 @@ interface ShoppexSdk {
|
|
|
1072
1165
|
page?: number;
|
|
1073
1166
|
limit?: number;
|
|
1074
1167
|
status?: string;
|
|
1168
|
+
/** One order-list group of the buyer status table: "paid" holds COMPLETED and AWAITING_STOCK. */
|
|
1169
|
+
statusGroup?: 'awaiting_payment' | 'paid' | 'refunded';
|
|
1075
1170
|
search?: string;
|
|
1076
1171
|
}): Promise<SdkResponse<SdkCustomerOrderPage>>;
|
|
1077
1172
|
/** One order, by the `uniqid` the list rows carry. */
|
|
@@ -1105,7 +1200,12 @@ interface ShoppexSdk {
|
|
|
1105
1200
|
cancel_at_period_end?: boolean;
|
|
1106
1201
|
reason?: string | null;
|
|
1107
1202
|
}): Promise<SdkResponse<unknown>>;
|
|
1108
|
-
|
|
1203
|
+
/** Pauses from `pause_options.starts_at` for one of its lengths, with a reason when the shop asks for one. */
|
|
1204
|
+
pauseSubscription(uniqid: string, options?: {
|
|
1205
|
+
length_days?: 7 | 14 | 30 | 60 | 90;
|
|
1206
|
+
reason?: SdkCustomerPauseReason | null;
|
|
1207
|
+
}): Promise<SdkResponse<unknown>>;
|
|
1208
|
+
/** "Resume now" on a paused plan; "Don't pause" on a scheduled pause. */
|
|
1109
1209
|
resumeSubscription(uniqid: string): Promise<SdkResponse<unknown>>;
|
|
1110
1210
|
/** The buyer's saved products. */
|
|
1111
1211
|
favorites(): Promise<SdkResponse<unknown>>;
|
|
@@ -1478,6 +1578,11 @@ interface StorefrontPriceVariant {
|
|
|
1478
1578
|
unit: SubscriptionIntervalUnit;
|
|
1479
1579
|
count: number;
|
|
1480
1580
|
} | null;
|
|
1581
|
+
/**
|
|
1582
|
+
* The option's own trial (`'none'`: the option has no trial); null starts it
|
|
1583
|
+
* with the product's (`subscriptionForVariant`).
|
|
1584
|
+
*/
|
|
1585
|
+
ownTrial: SubscriptionTrial | 'none' | null;
|
|
1481
1586
|
}
|
|
1482
1587
|
interface VolumeDiscountRule {
|
|
1483
1588
|
quantity: number;
|
|
@@ -1657,7 +1762,7 @@ type YouReceive = {
|
|
|
1657
1762
|
};
|
|
1658
1763
|
declare function resolveYouReceive(product: Pick<StorefrontProduct, 'deliverable' | 'unitLabelSingular'>): YouReceive | null;
|
|
1659
1764
|
/**
|
|
1660
|
-
* How often a subscription product is charged, and
|
|
1765
|
+
* How often a subscription product is charged, and the trial it starts with.
|
|
1661
1766
|
*
|
|
1662
1767
|
* PARITY CONTRACT. The Easy lane derives the same three facts from the same
|
|
1663
1768
|
* flat wire fields in
|
|
@@ -1676,24 +1781,38 @@ interface ProductSubscription {
|
|
|
1676
1781
|
intervalUnit: SubscriptionIntervalUnit | null;
|
|
1677
1782
|
/** Intervals per charge, at least 1. */
|
|
1678
1783
|
intervalCount: number;
|
|
1679
|
-
/**
|
|
1680
|
-
|
|
1784
|
+
/** The trial the plan starts with; null when it has none. */
|
|
1785
|
+
trial: SubscriptionTrial | null;
|
|
1681
1786
|
}
|
|
1787
|
+
/**
|
|
1788
|
+
* A free trial, or a paid intro: `price` in `currency` (the product currency,
|
|
1789
|
+
* as the wire states it) for the first `days`. The trial checkout bills
|
|
1790
|
+
* (`resolveProductTrial`).
|
|
1791
|
+
*/
|
|
1792
|
+
type SubscriptionTrial = {
|
|
1793
|
+
kind: 'free';
|
|
1794
|
+
days: number;
|
|
1795
|
+
} | {
|
|
1796
|
+
kind: 'paid';
|
|
1797
|
+
days: number;
|
|
1798
|
+
price: number;
|
|
1799
|
+
currency: string;
|
|
1800
|
+
};
|
|
1682
1801
|
/** The cadence as it reads next to a price: "per month", "every 3 months". */
|
|
1683
1802
|
declare function formatSubscriptionCadence(subscription: ProductSubscription): string;
|
|
1684
|
-
/**
|
|
1685
|
-
|
|
1803
|
+
/**
|
|
1804
|
+
* "7-day free trial" for a free trial, "$4.99 for 7 days" for a paid intro
|
|
1805
|
+
* (`formatAmount` prints its price); empty when the plan has no trial.
|
|
1806
|
+
*/
|
|
1807
|
+
declare function formatSubscriptionTrial(subscription: ProductSubscription, formatAmount: (amount: number, currency: string) => string): string;
|
|
1686
1808
|
/**
|
|
1687
1809
|
* The subscription as the selected option bills it: an option with its own
|
|
1688
1810
|
* interval (`billing_interval`, stored with its count or not at all) is charged
|
|
1689
|
-
* at that cadence, every other one at the product's.
|
|
1811
|
+
* at that cadence, every other one at the product's. An option with its own
|
|
1812
|
+
* trial ("No trial" included) starts with it, every other one with the
|
|
1813
|
+
* product's: the rule checkout's `resolveProductTrial` applies.
|
|
1690
1814
|
*/
|
|
1691
|
-
declare function subscriptionForVariant(subscription: ProductSubscription, variant:
|
|
1692
|
-
billingInterval: {
|
|
1693
|
-
unit: SubscriptionIntervalUnit;
|
|
1694
|
-
count: number;
|
|
1695
|
-
} | null;
|
|
1696
|
-
} | null | undefined): ProductSubscription;
|
|
1815
|
+
declare function subscriptionForVariant(subscription: ProductSubscription, variant: Pick<StorefrontPriceVariant, 'billingInterval' | 'ownTrial'> | null | undefined): ProductSubscription;
|
|
1697
1816
|
/**
|
|
1698
1817
|
* What a product image shows, from the backend's pixel analysis. `art` is a
|
|
1699
1818
|
* cover, artwork or photo; `logo` is a flat mark, drawn on a contrasting plate.
|
|
@@ -3615,4 +3734,4 @@ declare function useOnlineUserCount(): number | null;
|
|
|
3615
3734
|
*/
|
|
3616
3735
|
declare function resolveProductVideoEmbedSrc(value: unknown): string | null;
|
|
3617
3736
|
|
|
3618
|
-
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 SdkCustomerOrderDetail, type SdkCustomerOrderPage, type SdkCustomerOrderReview, 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, subscriptionForVariant, toShopReviews, toStarCount, useCart, useFavorites, useNavigationLinks, useOnlineUserCount, usePagedShopReviews, useShopReviews, useStorefront, validateCheckoutFieldValue, validateCheckoutFields, validateContactSubmission, withRequiredAddons };
|
|
3737
|
+
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 SdkCustomerSubscriptionDiscount, 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,13 +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"}`;
|
|
581
583
|
}
|
|
582
584
|
function subscriptionForVariant(subscription, variant) {
|
|
583
585
|
const own = variant?.billingInterval;
|
|
584
|
-
|
|
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
|
+
};
|
|
585
593
|
}
|
|
586
594
|
function parseSubscription(product, productType) {
|
|
587
595
|
if (productType !== "SUBSCRIPTION") return null;
|
|
@@ -591,7 +599,7 @@ function parseSubscription(product, productType) {
|
|
|
591
599
|
return {
|
|
592
600
|
intervalUnit: unit,
|
|
593
601
|
intervalCount: count,
|
|
594
|
-
|
|
602
|
+
trial: parseTrial(product)
|
|
595
603
|
};
|
|
596
604
|
}
|
|
597
605
|
function parseVariantBillingInterval(variant) {
|
|
@@ -599,6 +607,21 @@ function parseVariantBillingInterval(variant) {
|
|
|
599
607
|
const count = normalizePositiveDays(variant.billing_interval_count);
|
|
600
608
|
return unit && count ? { unit, count } : null;
|
|
601
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
|
+
}
|
|
602
625
|
var PAYMENT_METHOD_KINDS = ["card", "wallet", "crypto"];
|
|
603
626
|
function parsePaymentMethods(value) {
|
|
604
627
|
if (!Array.isArray(value)) {
|
|
@@ -1025,6 +1048,7 @@ function parsePriceVariants(value, productContext) {
|
|
|
1025
1048
|
description: optionalString(variant.description),
|
|
1026
1049
|
license: parseVariantLicense(variant),
|
|
1027
1050
|
billingInterval: parseVariantBillingInterval(variant),
|
|
1051
|
+
ownTrial: parseVariantTrial(variant),
|
|
1028
1052
|
price: unitPrice,
|
|
1029
1053
|
baseUnitPrice: unitPrice,
|
|
1030
1054
|
stock: normalizeStock(variant.stock, `${context}.stock`),
|