@shoppexio/storefront-react 0.4.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/dist/index.d.ts CHANGED
@@ -529,11 +529,67 @@ interface SdkCustomerSubscription {
529
529
  can_manage_payment_method: boolean;
530
530
  };
531
531
  /**
532
- * The hosted checkout of the open renewal invoice, when a renewal payment is
533
- * due. A plain link: the invoice already exists, so following it creates
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
- renewal_checkout_url?: string | null;
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;
537
593
  }
538
594
  /** One earned reward. `created_at` and `expires_at` are epoch SECONDS. */
539
595
  interface SdkCustomerRewardActivity {
@@ -814,6 +870,12 @@ interface SdkCustomerOrderDetail {
814
870
  taxPercentage: string;
815
871
  currency: string;
816
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;
817
879
  lineItems: Array<{
818
880
  id: string;
819
881
  productTitle: string;
@@ -822,6 +884,8 @@ interface SdkCustomerOrderDetail {
822
884
  quantity: number;
823
885
  total: string;
824
886
  deliveryText: string | null;
887
+ /** When the line was delivered; null until it was. */
888
+ deliveredAt: string | null;
825
889
  deliveryStatus: SdkCustomerDeliveryStatus;
826
890
  deliverySummary: SdkCustomerDeliverySummary | null;
827
891
  }>;
@@ -1072,6 +1136,8 @@ interface ShoppexSdk {
1072
1136
  page?: number;
1073
1137
  limit?: number;
1074
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';
1075
1141
  search?: string;
1076
1142
  }): Promise<SdkResponse<SdkCustomerOrderPage>>;
1077
1143
  /** One order, by the `uniqid` the list rows carry. */
@@ -1105,7 +1171,12 @@ interface ShoppexSdk {
1105
1171
  cancel_at_period_end?: boolean;
1106
1172
  reason?: string | null;
1107
1173
  }): Promise<SdkResponse<unknown>>;
1108
- pauseSubscription(uniqid: string): Promise<SdkResponse<unknown>>;
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. */
1109
1180
  resumeSubscription(uniqid: string): Promise<SdkResponse<unknown>>;
1110
1181
  /** The buyer's saved products. */
1111
1182
  favorites(): Promise<SdkResponse<unknown>>;
@@ -1478,6 +1549,11 @@ interface StorefrontPriceVariant {
1478
1549
  unit: SubscriptionIntervalUnit;
1479
1550
  count: number;
1480
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;
1481
1557
  }
1482
1558
  interface VolumeDiscountRule {
1483
1559
  quantity: number;
@@ -1657,7 +1733,7 @@ type YouReceive = {
1657
1733
  };
1658
1734
  declare function resolveYouReceive(product: Pick<StorefrontProduct, 'deliverable' | 'unitLabelSingular'>): YouReceive | null;
1659
1735
  /**
1660
- * How often a subscription product is charged, and how long it is free first.
1736
+ * How often a subscription product is charged, and the trial it starts with.
1661
1737
  *
1662
1738
  * PARITY CONTRACT. The Easy lane derives the same three facts from the same
1663
1739
  * flat wire fields in
@@ -1676,24 +1752,38 @@ interface ProductSubscription {
1676
1752
  intervalUnit: SubscriptionIntervalUnit | null;
1677
1753
  /** Intervals per charge, at least 1. */
1678
1754
  intervalCount: number;
1679
- /** Free-trial length in days; 0 when the merchant set none. */
1680
- trialDays: number;
1755
+ /** The trial the plan starts with; null when it has none. */
1756
+ trial: SubscriptionTrial | null;
1681
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
+ };
1682
1772
  /** The cadence as it reads next to a price: "per month", "every 3 months". */
1683
1773
  declare function formatSubscriptionCadence(subscription: ProductSubscription): string;
1684
- /** "7-day free trial" — the plan charges nothing for those days. */
1685
- declare function formatSubscriptionTrial(subscription: ProductSubscription): string;
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;
1686
1779
  /**
1687
1780
  * The subscription as the selected option bills it: an option with its own
1688
1781
  * interval (`billing_interval`, stored with its count or not at all) is charged
1689
- * at that cadence, every other one at the product's.
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.
1690
1785
  */
1691
- declare function subscriptionForVariant(subscription: ProductSubscription, variant: {
1692
- billingInterval: {
1693
- unit: SubscriptionIntervalUnit;
1694
- count: number;
1695
- } | null;
1696
- } | null | undefined): ProductSubscription;
1786
+ declare function subscriptionForVariant(subscription: ProductSubscription, variant: Pick<StorefrontPriceVariant, 'billingInterval' | 'ownTrial'> | null | undefined): ProductSubscription;
1697
1787
  /**
1698
1788
  * What a product image shows, from the backend's pixel analysis. `art` is a
1699
1789
  * cover, artwork or photo; `logo` is a flat mark, drawn on a contrasting plate.
@@ -3615,4 +3705,4 @@ declare function useOnlineUserCount(): number | null;
3615
3705
  */
3616
3706
  declare function resolveProductVideoEmbedSrc(value: unknown): string | null;
3617
3707
 
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 };
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,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 days = subscription.trialDays;
580
- return days > 0 ? `${days}-day free trial` : "";
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
- return own ? { ...subscription, intervalUnit: own.unit, intervalCount: own.count } : subscription;
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
- trialDays: normalizePositiveDays(product.trial_period) ?? 0
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`),