@shoppexio/storefront-react 0.3.0 → 0.4.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 +23 -0
- package/dist/account.css +4 -8
- package/dist/account.js +1257 -778
- package/dist/account.js.map +1 -1
- package/dist/index.d.ts +92 -8
- package/dist/index.js +15 -16
- package/dist/index.js.map +1 -1
- package/eject/account/account-downloads.ts +89 -1
- package/eject/account/account-referrals.ts +70 -1
- package/eject/account/account-reseller.ts +6 -140
- package/eject/account/downloads.tsx +73 -4
- package/eject/account/hosted-page.ts +45 -0
- package/eject/account/messages/ar.json +55 -29
- package/eject/account/messages/de.json +55 -29
- package/eject/account/messages/en.json +55 -29
- package/eject/account/messages/es.json +55 -29
- package/eject/account/messages/fi.json +55 -29
- package/eject/account/messages/fr.json +55 -29
- package/eject/account/messages/hi.json +55 -29
- package/eject/account/messages/it.json +55 -29
- package/eject/account/messages/lt.json +55 -29
- package/eject/account/messages/nl.json +55 -29
- package/eject/account/messages/pl.json +55 -29
- package/eject/account/messages/pt.json +55 -29
- package/eject/account/messages/ru.json +55 -29
- package/eject/account/messages/tr.json +55 -29
- package/eject/account/messages/uk.json +55 -29
- package/eject/account/messages/zh.json +55 -29
- package/eject/account/orders.tsx +88 -0
- package/eject/account/overview.tsx +6 -0
- package/eject/account/referrals.tsx +47 -5
- package/eject/account/reseller.tsx +59 -306
- package/eject/account/rewards.tsx +5 -0
- package/eject/account/shared.tsx +39 -1
- package/eject/account/subscriptions.tsx +75 -16
- 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,12 @@ interface SdkCustomerSubscription {
|
|
|
509
528
|
can_cancel: boolean;
|
|
510
529
|
can_manage_payment_method: boolean;
|
|
511
530
|
};
|
|
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.
|
|
535
|
+
*/
|
|
536
|
+
renewal_checkout_url?: string | null;
|
|
512
537
|
}
|
|
513
538
|
/** One earned reward. `created_at` and `expires_at` are epoch SECONDS. */
|
|
514
539
|
interface SdkCustomerRewardActivity {
|
|
@@ -555,6 +580,21 @@ type SdkCustomerAffiliateLedgerStatus = 'waiting_payment' | 'earned' | 'in_payou
|
|
|
555
580
|
* "money paths do not belong on the account API"), so this template renders
|
|
556
581
|
* what the buyer has earned and says where the payout lives.
|
|
557
582
|
*/
|
|
583
|
+
/** What a referral earns the affiliate. Amounts are USD, like the affiliate ledger. */
|
|
584
|
+
interface SdkCustomerAffiliateRates {
|
|
585
|
+
/** The affiliate's rate (link, affiliate or tier), else the shop default. */
|
|
586
|
+
percent: number;
|
|
587
|
+
/** Up to three products set to No Commission, by title; `disabled_product_count` is the full count. */
|
|
588
|
+
disabled_products: string[];
|
|
589
|
+
disabled_product_count: number;
|
|
590
|
+
/** Products paying their own rate instead of `percent`; 0 when the affiliate's own rate overrides them. */
|
|
591
|
+
custom_rate_product_count: number;
|
|
592
|
+
cap_usd: string | null;
|
|
593
|
+
minimum_order_usd: string | null;
|
|
594
|
+
binding_mode: 'PER_ORDER' | 'LIFETIME_FIRST' | 'LIFETIME_LAST';
|
|
595
|
+
/** Null keeps a referred buyer for good. */
|
|
596
|
+
binding_days: number | null;
|
|
597
|
+
}
|
|
558
598
|
interface SdkCustomerAffiliateSummary {
|
|
559
599
|
/** `not_enrolled` is the availability gate for the whole referrals panel. */
|
|
560
600
|
state: string;
|
|
@@ -571,6 +611,8 @@ interface SdkCustomerAffiliateSummary {
|
|
|
571
611
|
converted: string;
|
|
572
612
|
paid: string;
|
|
573
613
|
};
|
|
614
|
+
/** "Your rates" (`readAffiliateRatesSummary`); null until the main link is approved and active. */
|
|
615
|
+
rates: SdkCustomerAffiliateRates | null;
|
|
574
616
|
links: SdkCustomerAffiliateLink[];
|
|
575
617
|
commissions: Array<{
|
|
576
618
|
id: string;
|
|
@@ -654,6 +696,30 @@ interface SdkCustomerWarrantyClaim {
|
|
|
654
696
|
claim_status: 'REQUESTED';
|
|
655
697
|
};
|
|
656
698
|
}
|
|
699
|
+
/**
|
|
700
|
+
* The buyer's review of one order. `can_review` is the server's call (paid,
|
|
701
|
+
* reviews on, inside the edit window); a storefront never derives it.
|
|
702
|
+
*/
|
|
703
|
+
interface SdkCustomerOrderReview {
|
|
704
|
+
can_review: boolean;
|
|
705
|
+
already_submitted: boolean;
|
|
706
|
+
feedback_uniqid: string | null;
|
|
707
|
+
product_title: string | null;
|
|
708
|
+
score: 1 | 3 | 5 | null;
|
|
709
|
+
/** The automatic positive review the shop posts when the buyer left none. */
|
|
710
|
+
is_automated: boolean;
|
|
711
|
+
message: string | null;
|
|
712
|
+
submitted_at: string | null;
|
|
713
|
+
/** The name the review would show; null when the shop shows none. */
|
|
714
|
+
reviewer_name: string | null;
|
|
715
|
+
anonymous: boolean;
|
|
716
|
+
/**
|
|
717
|
+
* The hosted review page on the checkout host, null unless `can_review`. The
|
|
718
|
+
* review is written there, never posted from a storefront (#1152). Absent on
|
|
719
|
+
* a backend that predates it.
|
|
720
|
+
*/
|
|
721
|
+
review_url?: string | null;
|
|
722
|
+
}
|
|
657
723
|
interface SdkCustomerDashboard {
|
|
658
724
|
shop: {
|
|
659
725
|
name: string;
|
|
@@ -679,6 +745,8 @@ interface SdkCustomerDashboard {
|
|
|
679
745
|
hold: string;
|
|
680
746
|
currency: string;
|
|
681
747
|
enabled: boolean;
|
|
748
|
+
/** The shop takes top-ups; the account's "Top up" link to the hosted top-up page shows only then. */
|
|
749
|
+
topups_allowed: boolean;
|
|
682
750
|
} | null;
|
|
683
751
|
invoices: SdkCustomerDashboardOrder[];
|
|
684
752
|
rewards: SdkCustomerRewards;
|
|
@@ -1023,6 +1091,8 @@ interface ShoppexSdk {
|
|
|
1023
1091
|
*/
|
|
1024
1092
|
warranties(invoiceUniqid?: string): Promise<SdkResponse<SdkCustomerWarrantyList>>;
|
|
1025
1093
|
claimWarranty(uniqid: string, message?: string): Promise<SdkResponse<SdkCustomerWarrantyClaim>>;
|
|
1094
|
+
/** The buyer's review of one order, by the order's `uniqid`. */
|
|
1095
|
+
orderReview(uniqid: string): Promise<SdkResponse<SdkCustomerOrderReview>>;
|
|
1026
1096
|
/** Clears a license's hardware lock so the next activation claims it. */
|
|
1027
1097
|
resetLicenseHwid(uniqid: string): Promise<SdkResponse<unknown>>;
|
|
1028
1098
|
/** Renewal invoices for one subscription. */
|
|
@@ -1108,12 +1178,6 @@ interface ShoppexSdk {
|
|
|
1108
1178
|
page?: number;
|
|
1109
1179
|
per_page?: number;
|
|
1110
1180
|
}): 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
1181
|
/** Page-based wholesale order history. */
|
|
1118
1182
|
resellerOrders(options?: {
|
|
1119
1183
|
page?: number;
|
|
@@ -1138,7 +1202,7 @@ interface SdkShopReview {
|
|
|
1138
1202
|
id: string;
|
|
1139
1203
|
/** 1-5, normalized by the SDK from the shop-feedback score (5/3/1). */
|
|
1140
1204
|
rating: number;
|
|
1141
|
-
/**
|
|
1205
|
+
/** The name the buyer chose to post under, or "Anonymous". */
|
|
1142
1206
|
author?: string;
|
|
1143
1207
|
customer_name?: string;
|
|
1144
1208
|
comment?: string;
|
|
@@ -1147,6 +1211,8 @@ interface SdkShopReview {
|
|
|
1147
1211
|
/** True when the review is tied to a real completed purchase. */
|
|
1148
1212
|
verified?: boolean;
|
|
1149
1213
|
is_automated?: boolean;
|
|
1214
|
+
/** The shop's reply under the review; null when it has not replied. */
|
|
1215
|
+
reply?: string | null;
|
|
1150
1216
|
created_at: string;
|
|
1151
1217
|
}
|
|
1152
1218
|
type AddonBarPreset = 'brand_blue' | 'emerald' | 'sunset' | 'rose' | 'charcoal' | 'custom';
|
|
@@ -1407,6 +1473,11 @@ interface StorefrontPriceVariant {
|
|
|
1407
1473
|
quantityMax: number | null;
|
|
1408
1474
|
imageUrl: string | null;
|
|
1409
1475
|
isFeatured: boolean;
|
|
1476
|
+
/** The option's own billing cadence; null bills at the product's (`subscriptionForVariant`). */
|
|
1477
|
+
billingInterval: {
|
|
1478
|
+
unit: SubscriptionIntervalUnit;
|
|
1479
|
+
count: number;
|
|
1480
|
+
} | null;
|
|
1410
1481
|
}
|
|
1411
1482
|
interface VolumeDiscountRule {
|
|
1412
1483
|
quantity: number;
|
|
@@ -1612,6 +1683,17 @@ interface ProductSubscription {
|
|
|
1612
1683
|
declare function formatSubscriptionCadence(subscription: ProductSubscription): string;
|
|
1613
1684
|
/** "7-day free trial" — the plan charges nothing for those days. */
|
|
1614
1685
|
declare function formatSubscriptionTrial(subscription: ProductSubscription): string;
|
|
1686
|
+
/**
|
|
1687
|
+
* The subscription as the selected option bills it: an option with its own
|
|
1688
|
+
* interval (`billing_interval`, stored with its count or not at all) is charged
|
|
1689
|
+
* at that cadence, every other one at the product's.
|
|
1690
|
+
*/
|
|
1691
|
+
declare function subscriptionForVariant(subscription: ProductSubscription, variant: {
|
|
1692
|
+
billingInterval: {
|
|
1693
|
+
unit: SubscriptionIntervalUnit;
|
|
1694
|
+
count: number;
|
|
1695
|
+
} | null;
|
|
1696
|
+
} | null | undefined): ProductSubscription;
|
|
1615
1697
|
/**
|
|
1616
1698
|
* What a product image shows, from the backend's pixel analysis. `art` is a
|
|
1617
1699
|
* cover, artwork or photo; `logo` is a flat mark, drawn on a contrasting plate.
|
|
@@ -3204,6 +3286,8 @@ interface ShopReview {
|
|
|
3204
3286
|
verified: boolean;
|
|
3205
3287
|
/** Left by the shop's review automation, not written by the buyer. */
|
|
3206
3288
|
automated: boolean;
|
|
3289
|
+
/** The shop's reply under the review; null when it has not replied. */
|
|
3290
|
+
reply: string | null;
|
|
3207
3291
|
}
|
|
3208
3292
|
type ShopReviewsState = {
|
|
3209
3293
|
status: 'loading';
|
|
@@ -3531,4 +3615,4 @@ declare function useOnlineUserCount(): number | null;
|
|
|
3531
3615
|
*/
|
|
3532
3616
|
declare function resolveProductVideoEmbedSrc(value: unknown): string | null;
|
|
3533
3617
|
|
|
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 };
|
|
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 };
|
package/dist/index.js
CHANGED
|
@@ -579,6 +579,10 @@ function formatSubscriptionTrial(subscription) {
|
|
|
579
579
|
const days = subscription.trialDays;
|
|
580
580
|
return days > 0 ? `${days}-day free trial` : "";
|
|
581
581
|
}
|
|
582
|
+
function subscriptionForVariant(subscription, variant) {
|
|
583
|
+
const own = variant?.billingInterval;
|
|
584
|
+
return own ? { ...subscription, intervalUnit: own.unit, intervalCount: own.count } : subscription;
|
|
585
|
+
}
|
|
582
586
|
function parseSubscription(product, productType) {
|
|
583
587
|
if (productType !== "SUBSCRIPTION") return null;
|
|
584
588
|
const rawUnit = typeof product.recurring_interval === "string" ? product.recurring_interval.toUpperCase() : "";
|
|
@@ -590,6 +594,11 @@ function parseSubscription(product, productType) {
|
|
|
590
594
|
trialDays: normalizePositiveDays(product.trial_period) ?? 0
|
|
591
595
|
};
|
|
592
596
|
}
|
|
597
|
+
function parseVariantBillingInterval(variant) {
|
|
598
|
+
const unit = SUBSCRIPTION_INTERVAL_UNITS.find((entry) => entry === variant.billing_interval);
|
|
599
|
+
const count = normalizePositiveDays(variant.billing_interval_count);
|
|
600
|
+
return unit && count ? { unit, count } : null;
|
|
601
|
+
}
|
|
593
602
|
var PAYMENT_METHOD_KINDS = ["card", "wallet", "crypto"];
|
|
594
603
|
function parsePaymentMethods(value) {
|
|
595
604
|
if (!Array.isArray(value)) {
|
|
@@ -896,11 +905,7 @@ function parseProduct(value, index) {
|
|
|
896
905
|
imageUrl: resolveProductImage(product),
|
|
897
906
|
imageUrls: images.map((image) => image.url),
|
|
898
907
|
images,
|
|
899
|
-
stock:
|
|
900
|
-
normalizeStock(product.stock, `${context}.stock`),
|
|
901
|
-
product.orderable,
|
|
902
|
-
product.supplier_backed
|
|
903
|
-
),
|
|
908
|
+
stock: normalizeStock(product.stock, `${context}.stock`),
|
|
904
909
|
lowStockThreshold: normalizeLowStockThreshold(
|
|
905
910
|
normalizeOptionalNonNegativeNumber(product.quantity_warning)
|
|
906
911
|
),
|
|
@@ -1019,13 +1024,10 @@ function parsePriceVariants(value, productContext) {
|
|
|
1019
1024
|
label: requireStringFromKeys(variant, ["label", "title"], context),
|
|
1020
1025
|
description: optionalString(variant.description),
|
|
1021
1026
|
license: parseVariantLicense(variant),
|
|
1027
|
+
billingInterval: parseVariantBillingInterval(variant),
|
|
1022
1028
|
price: unitPrice,
|
|
1023
1029
|
baseUnitPrice: unitPrice,
|
|
1024
|
-
stock:
|
|
1025
|
-
normalizeStock(variant.stock, `${context}.stock`),
|
|
1026
|
-
variant.orderable,
|
|
1027
|
-
variant.supplier_backed
|
|
1028
|
-
),
|
|
1030
|
+
stock: normalizeStock(variant.stock, `${context}.stock`),
|
|
1029
1031
|
quantityMin,
|
|
1030
1032
|
quantityMax: normalizeMaximum(variant.quantity_max, quantityMin ?? 1, `${context}.quantity_max`),
|
|
1031
1033
|
imageUrl: optionalString(variant.image_url),
|
|
@@ -1294,11 +1296,6 @@ function normalizeStock(value, context) {
|
|
|
1294
1296
|
const stock = parseFiniteNumber(value, context);
|
|
1295
1297
|
return stock < 0 ? null : Math.floor(stock);
|
|
1296
1298
|
}
|
|
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
1299
|
function normalizeOptionalNonNegativeNumber(value) {
|
|
1303
1300
|
if (value === null || value === void 0 || value === "") return null;
|
|
1304
1301
|
const parsed = Number(value);
|
|
@@ -2821,7 +2818,8 @@ function toShopReviews(rows, labels) {
|
|
|
2821
2818
|
timestamp,
|
|
2822
2819
|
productTitle: row.product_title?.trim() || null,
|
|
2823
2820
|
verified: row.verified === true,
|
|
2824
|
-
automated: row.is_automated === true
|
|
2821
|
+
automated: row.is_automated === true,
|
|
2822
|
+
reply: row.reply?.trim() || null
|
|
2825
2823
|
};
|
|
2826
2824
|
}).sort((a, b) => b.timestamp - a.timestamp);
|
|
2827
2825
|
}
|
|
@@ -3190,6 +3188,7 @@ export {
|
|
|
3190
3188
|
startCartMutation,
|
|
3191
3189
|
stripMerchantHtmlImages,
|
|
3192
3190
|
submitContactTicket,
|
|
3191
|
+
subscriptionForVariant,
|
|
3193
3192
|
toShopReviews,
|
|
3194
3193
|
toStarCount,
|
|
3195
3194
|
useCart,
|