@shoppexio/storefront-react 0.1.4 → 0.2.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 +47 -0
- package/README.md +8 -2
- package/dist/account.js +119 -125
- package/dist/account.js.map +1 -1
- package/dist/{chunk-D6XKDVAV.js → chunk-ZEFZPUAW.js} +152 -2
- package/dist/chunk-ZEFZPUAW.js.map +1 -0
- package/dist/index.d.ts +298 -20
- package/dist/index.js +245 -22
- package/dist/index.js.map +1 -1
- package/eject/account/account-page.tsx +8 -2
- package/eject/account/account-warranties.ts +9 -0
- package/eject/account/favorites.tsx +3 -0
- package/eject/account/messages/ar.json +2 -1
- package/eject/account/messages/de.json +2 -1
- package/eject/account/messages/en.json +2 -1
- package/eject/account/messages/es.json +2 -1
- package/eject/account/messages/fi.json +2 -1
- package/eject/account/messages/fr.json +2 -1
- package/eject/account/messages/hi.json +2 -1
- package/eject/account/messages/it.json +2 -1
- package/eject/account/messages/lt.json +2 -1
- package/eject/account/messages/nl.json +2 -1
- package/eject/account/messages/pl.json +2 -1
- package/eject/account/messages/pt.json +2 -1
- package/eject/account/messages/ru.json +2 -1
- package/eject/account/messages/tr.json +2 -1
- package/eject/account/messages/uk.json +2 -1
- package/eject/account/messages/zh.json +2 -1
- package/eject/account/orders.tsx +6 -1
- package/package.json +1 -1
- package/dist/chunk-D6XKDVAV.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -826,10 +826,16 @@ interface ShoppexSdk {
|
|
|
826
826
|
data?: SdkPage[];
|
|
827
827
|
message?: string;
|
|
828
828
|
}>;
|
|
829
|
+
/**
|
|
830
|
+
* On a failure, `status` is the HTTP status (404 for a page that does not
|
|
831
|
+
* exist) and is absent when the request never reached a server. SDK 1.0.87
|
|
832
|
+
* and later; earlier builds send no `status` at all.
|
|
833
|
+
*/
|
|
829
834
|
getPage(slug: string): Promise<{
|
|
830
835
|
success: boolean;
|
|
831
836
|
data?: SdkPage;
|
|
832
837
|
message?: string;
|
|
838
|
+
status?: number;
|
|
833
839
|
}>;
|
|
834
840
|
/** Merchant-configured navigation menus, keyed by slot (header/footer/…). */
|
|
835
841
|
getMenus(): Promise<{
|
|
@@ -896,7 +902,9 @@ interface ShoppexSdk {
|
|
|
896
902
|
* One page of the same feed, newest first. `cursor` is the previous page's
|
|
897
903
|
* `pagination.next_cursor`; omit it for the first page.
|
|
898
904
|
*/
|
|
899
|
-
getShopReviewsPage(cursor?: string | null
|
|
905
|
+
getShopReviewsPage(cursor?: string | null, options?: {
|
|
906
|
+
product?: string | null;
|
|
907
|
+
}): Promise<{
|
|
900
908
|
success: boolean;
|
|
901
909
|
data?: {
|
|
902
910
|
feedback: SdkShopReview[];
|
|
@@ -904,7 +912,16 @@ interface ShoppexSdk {
|
|
|
904
912
|
next_cursor: string | null;
|
|
905
913
|
has_more: boolean;
|
|
906
914
|
};
|
|
915
|
+
/** Counts over the whole list, or over one product's reviews when filtered. */
|
|
916
|
+
summary?: SdkShopReviewsSummary;
|
|
917
|
+
/**
|
|
918
|
+
* The product filter the API applied, echoed back. Absent from an API that
|
|
919
|
+
* predates the filter and ignored it; see `loadShopReviewsPage`.
|
|
920
|
+
*/
|
|
921
|
+
product?: string | null;
|
|
907
922
|
};
|
|
923
|
+
message?: string;
|
|
924
|
+
status?: number;
|
|
908
925
|
}>;
|
|
909
926
|
/** Starts an in-page sign-in. Sends the email and nothing else. */
|
|
910
927
|
requestOtp(email: string): Promise<SdkResponse<unknown>>;
|
|
@@ -1054,6 +1071,14 @@ interface ShoppexSdk {
|
|
|
1054
1071
|
/** Lists the buyer's reseller API keys without plaintext secrets. */
|
|
1055
1072
|
resellerApiKeys(): Promise<SdkResponse<unknown>>;
|
|
1056
1073
|
}
|
|
1074
|
+
interface SdkShopReviewsSummary {
|
|
1075
|
+
total: number;
|
|
1076
|
+
positive: number;
|
|
1077
|
+
neutral: number;
|
|
1078
|
+
negative: number;
|
|
1079
|
+
/** 1-5 average of the scores (5/3/1), null for an empty list. */
|
|
1080
|
+
average_score: number | null;
|
|
1081
|
+
}
|
|
1057
1082
|
interface SdkShopReview {
|
|
1058
1083
|
id: string;
|
|
1059
1084
|
/** 1-5, normalized by the SDK from the shop-feedback score (5/3/1). */
|
|
@@ -1255,6 +1280,42 @@ declare function badgesForCard(badges: readonly ProductBadge[]): ProductBadge[];
|
|
|
1255
1280
|
/** Badges the product page shows, in the merchant's order. */
|
|
1256
1281
|
declare function badgesForProductPage(badges: readonly ProductBadge[]): ProductBadge[];
|
|
1257
1282
|
|
|
1283
|
+
/**
|
|
1284
|
+
* The `/status` page model: the products the merchant gave an explicit service
|
|
1285
|
+
* status in the dashboard (`service_status` on the catalog wire).
|
|
1286
|
+
*
|
|
1287
|
+
* Nothing is derived here. A product without a status is not listed, and a
|
|
1288
|
+
* shop that set none gets `null`, so a theme can hide its status route and nav
|
|
1289
|
+
* link instead of showing an empty or invented board. The words for the four
|
|
1290
|
+
* states ("Undetected", "Updating", ...) belong to the theme.
|
|
1291
|
+
*/
|
|
1292
|
+
|
|
1293
|
+
declare const SERVICE_STATES: readonly ["operational", "updating", "detected", "offline"];
|
|
1294
|
+
type ServiceState = (typeof SERVICE_STATES)[number];
|
|
1295
|
+
interface ProductServiceStatus {
|
|
1296
|
+
state: ServiceState;
|
|
1297
|
+
/** The merchant's note ("Patch 4.2 in progress"); null when none. */
|
|
1298
|
+
note: string | null;
|
|
1299
|
+
/** ISO timestamp of the merchant's last change. */
|
|
1300
|
+
updatedAt: string;
|
|
1301
|
+
}
|
|
1302
|
+
interface StatusPageEntry {
|
|
1303
|
+
product: StorefrontProduct;
|
|
1304
|
+
status: ProductServiceStatus;
|
|
1305
|
+
}
|
|
1306
|
+
interface StatusPageModel {
|
|
1307
|
+
/** Entries in board order: the most urgent state first, then the merchant's shelf order. */
|
|
1308
|
+
entries: StatusPageEntry[];
|
|
1309
|
+
/** How many products are in each state; every state is present (0 when none). */
|
|
1310
|
+
counts: Record<ServiceState, number>;
|
|
1311
|
+
/** The states that have at least one product, in board order, for filter chips. */
|
|
1312
|
+
presentStates: ServiceState[];
|
|
1313
|
+
/** The latest change across all entries (ISO). */
|
|
1314
|
+
lastUpdatedAt: string;
|
|
1315
|
+
}
|
|
1316
|
+
declare function parseServiceStatus(value: unknown, context: string): ProductServiceStatus | null;
|
|
1317
|
+
declare function buildStatusPageModel(products: readonly StorefrontProduct[]): StatusPageModel | null;
|
|
1318
|
+
|
|
1258
1319
|
/**
|
|
1259
1320
|
* The `window.__SHOPPEX_INITIAL__` contract: catalog, store switches and addon
|
|
1260
1321
|
* slots, injected by the Shoppex storefront (or preview) worker immediately
|
|
@@ -1270,6 +1331,11 @@ declare function badgesForProductPage(badges: readonly ProductBadge[]): ProductB
|
|
|
1270
1331
|
interface StorefrontPriceVariant {
|
|
1271
1332
|
id: string;
|
|
1272
1333
|
label: string;
|
|
1334
|
+
/**
|
|
1335
|
+
* The merchant's one-line note on this option ("1 seat", "5 seats"). null
|
|
1336
|
+
* when the option has none.
|
|
1337
|
+
*/
|
|
1338
|
+
description: string | null;
|
|
1273
1339
|
/** What this option states about its term; `inherit` defers to the product. */
|
|
1274
1340
|
license: LicenseStatement;
|
|
1275
1341
|
/** Display unit price with the product percent discount already applied. */
|
|
@@ -1404,10 +1470,16 @@ type ProductType = 'PRODUCT' | 'SUBSCRIPTION' | 'INFO_CARD' | 'SERIALS' | 'PHYSI
|
|
|
1404
1470
|
*
|
|
1405
1471
|
* - `shipped`: a PHYSICAL product. Its digital `delivery_time` is null, which
|
|
1406
1472
|
* would otherwise read as instant, so the type decides first.
|
|
1407
|
-
* - `timed`: the merchant set a delivery time.
|
|
1408
|
-
*
|
|
1473
|
+
* - `timed`: the merchant set a positive delivery time. Fractions round UP: a
|
|
1474
|
+
* partial wait is still a wait.
|
|
1475
|
+
* - `instant`: the payload STATES a delivery time and it is `null` or `0`,
|
|
1476
|
+
* the merchant's written "no wait".
|
|
1477
|
+
* - `unspecified`: the payload carries no delivery time at all. Nobody gave a
|
|
1478
|
+
* promise, so none is shown; reading absence as "instant" would invent the
|
|
1479
|
+
* merchant's answer.
|
|
1409
1480
|
*
|
|
1410
|
-
* Parity with the hosted checkout's `apps/checkout/lib/delivery-promise.ts
|
|
1481
|
+
* Parity with the hosted checkout's `apps/checkout/lib/delivery-promise.ts`,
|
|
1482
|
+
* which draws the same line between a written answer and no answer.
|
|
1411
1483
|
*/
|
|
1412
1484
|
type DeliveryPromise = {
|
|
1413
1485
|
kind: 'shipped';
|
|
@@ -1417,8 +1489,34 @@ type DeliveryPromise = {
|
|
|
1417
1489
|
unit: DeliveryTimeUnit;
|
|
1418
1490
|
} | {
|
|
1419
1491
|
kind: 'instant';
|
|
1492
|
+
} | {
|
|
1493
|
+
kind: 'unspecified';
|
|
1494
|
+
};
|
|
1495
|
+
declare function resolveDeliveryPromise(product: Pick<StorefrontProduct, 'productType' | 'deliveryTimeStated' | 'deliveryTimeCount' | 'deliveryTimeUnit'>): DeliveryPromise;
|
|
1496
|
+
/**
|
|
1497
|
+
* What the buyer is handed, from the product's raw delivery type. null for a
|
|
1498
|
+
* type this package does not know yet.
|
|
1499
|
+
*/
|
|
1500
|
+
type ProductDeliverable = 'serials' | 'file' | 'service' | 'dynamic' | 'info_card' | 'subscription' | 'physical';
|
|
1501
|
+
/**
|
|
1502
|
+
* The "You receive" statement, only where the delivery type says what arrives:
|
|
1503
|
+
*
|
|
1504
|
+
* - `serials`: delivered text units. `unitLabel` is what the merchant calls
|
|
1505
|
+
* one (`label_singular`, e.g. "License key"), null to let the theme use its
|
|
1506
|
+
* own neutral word.
|
|
1507
|
+
* - `download`: a FILE product, delivered as a download link.
|
|
1508
|
+
*
|
|
1509
|
+
* Every other type returns null: a service, a generated item or an info card
|
|
1510
|
+
* does not state its contents on the wire, so a theme shows nothing rather
|
|
1511
|
+
* than guessing.
|
|
1512
|
+
*/
|
|
1513
|
+
type YouReceive = {
|
|
1514
|
+
kind: 'serials';
|
|
1515
|
+
unitLabel: string | null;
|
|
1516
|
+
} | {
|
|
1517
|
+
kind: 'download';
|
|
1420
1518
|
};
|
|
1421
|
-
declare function
|
|
1519
|
+
declare function resolveYouReceive(product: Pick<StorefrontProduct, 'deliverable' | 'unitLabelSingular'>): YouReceive | null;
|
|
1422
1520
|
/**
|
|
1423
1521
|
* How often a subscription product is charged, and how long it is free first.
|
|
1424
1522
|
*
|
|
@@ -1460,6 +1558,24 @@ interface StorefrontProduct {
|
|
|
1460
1558
|
price: number;
|
|
1461
1559
|
currency: string;
|
|
1462
1560
|
description: string | null;
|
|
1561
|
+
/**
|
|
1562
|
+
* One plain-text line the merchant wrote for under the title
|
|
1563
|
+
* (`short_description`). null when they wrote none; never derived from the
|
|
1564
|
+
* description.
|
|
1565
|
+
*/
|
|
1566
|
+
shortDescription: string | null;
|
|
1567
|
+
/** What the buyer is handed, from the raw delivery type. See `resolveYouReceive`. */
|
|
1568
|
+
deliverable: ProductDeliverable | null;
|
|
1569
|
+
/** The merchant's word for one delivered unit ("License key"); null when unset. */
|
|
1570
|
+
unitLabelSingular: string | null;
|
|
1571
|
+
/** The merchant's word for several delivered units ("License keys"); null when unset. */
|
|
1572
|
+
unitLabelPlural: string | null;
|
|
1573
|
+
/**
|
|
1574
|
+
* The merchant's explicit `/status` state for this product, set in the
|
|
1575
|
+
* dashboard. null when they set none: the product is then not on the status
|
|
1576
|
+
* board. See `buildStatusPageModel`.
|
|
1577
|
+
*/
|
|
1578
|
+
serviceStatus: ProductServiceStatus | null;
|
|
1463
1579
|
slug: string | null;
|
|
1464
1580
|
imageUrl: string | null;
|
|
1465
1581
|
/**
|
|
@@ -1602,7 +1718,12 @@ interface StorefrontProduct {
|
|
|
1602
1718
|
license: LicenseStatement;
|
|
1603
1719
|
/** Whether licensing is on at all; a stale term must not be advertised when it is off. */
|
|
1604
1720
|
licensingEnabled: boolean;
|
|
1605
|
-
/**
|
|
1721
|
+
/**
|
|
1722
|
+
* Whether the payload states a delivery time at all (`delivery_time` present,
|
|
1723
|
+
* `null` included). false makes the promise `unspecified`.
|
|
1724
|
+
*/
|
|
1725
|
+
deliveryTimeStated: boolean;
|
|
1726
|
+
/** Estimated delivery time as a whole positive count, rounded up; null for no wait. */
|
|
1606
1727
|
deliveryTimeCount: number | null;
|
|
1607
1728
|
/** Unit `deliveryTimeCount` is counted in: 'minutes' | 'hours' | 'days'. */
|
|
1608
1729
|
deliveryTimeUnit: DeliveryTimeUnit;
|
|
@@ -1626,6 +1747,11 @@ interface StorefrontSettings {
|
|
|
1626
1747
|
searchEnabled: boolean;
|
|
1627
1748
|
contactFormEnabled: boolean;
|
|
1628
1749
|
requireInvoiceForContact: boolean;
|
|
1750
|
+
/**
|
|
1751
|
+
* Sold-out products may offer "Notify me" (back-in-stock emails). A merchant
|
|
1752
|
+
* switch the backend enforces; see `canRequestStockAlert`.
|
|
1753
|
+
*/
|
|
1754
|
+
stockAlertsEnabled: boolean;
|
|
1629
1755
|
/**
|
|
1630
1756
|
* The merchant centres bundle cards. A shop-level presentation switch, not a
|
|
1631
1757
|
* theme setting: the Easy lane reads `ctx.shop.center_group_titles` and
|
|
@@ -1674,11 +1800,23 @@ interface StorefrontSettings {
|
|
|
1674
1800
|
*/
|
|
1675
1801
|
activeCurrency: string;
|
|
1676
1802
|
/**
|
|
1677
|
-
*
|
|
1678
|
-
*
|
|
1679
|
-
*
|
|
1803
|
+
* The payment methods the shop's connected gateways take (`store.payment_methods`),
|
|
1804
|
+
* cards first, then wallets, then crypto. The backend derives them from the
|
|
1805
|
+
* gateway codes, so a theme renders marks without a mapping of its own.
|
|
1806
|
+
* Merchant fact: an empty list renders no row rather than a reassuring default.
|
|
1680
1807
|
*/
|
|
1681
|
-
|
|
1808
|
+
paymentMethods: StorefrontPaymentMethod[];
|
|
1809
|
+
}
|
|
1810
|
+
type StorefrontPaymentMethodKind = 'card' | 'wallet' | 'crypto';
|
|
1811
|
+
/**
|
|
1812
|
+
* One payment method the checkout takes. `id` is a stable lower-case mark id
|
|
1813
|
+
* (`visa`, `paypal`, `bitcoin`, `usdt`, ...); `label` is its English name.
|
|
1814
|
+
* Unknown ids may appear as the platform adds gateways: render the label.
|
|
1815
|
+
*/
|
|
1816
|
+
interface StorefrontPaymentMethod {
|
|
1817
|
+
id: string;
|
|
1818
|
+
label: string;
|
|
1819
|
+
kind: StorefrontPaymentMethodKind;
|
|
1682
1820
|
}
|
|
1683
1821
|
/**
|
|
1684
1822
|
* The shop itself: the identity and the aggregate metrics the storefront
|
|
@@ -2660,6 +2798,52 @@ interface SupportChannel {
|
|
|
2660
2798
|
*/
|
|
2661
2799
|
declare function resolveSupportChannels(links: readonly SocialLink[]): SupportChannel[];
|
|
2662
2800
|
|
|
2801
|
+
/**
|
|
2802
|
+
* - `loading`: the saved set has not been read yet (render the heart idle).
|
|
2803
|
+
* - `signed_out`: the read answered 401; a press asks the buyer to sign in.
|
|
2804
|
+
* - `ready`: the saved set is known.
|
|
2805
|
+
* - `unavailable`: the read failed for another reason (5xx, no SDK support, a
|
|
2806
|
+
* changed contract, a buyer with no customer profile in this shop). The
|
|
2807
|
+
* feature cannot work on this page, so render no heart.
|
|
2808
|
+
*/
|
|
2809
|
+
type FavoritesStatus = 'loading' | 'signed_out' | 'ready' | 'unavailable';
|
|
2810
|
+
/** What one press did. `signed_out` means: send the buyer to sign in. */
|
|
2811
|
+
type FavoriteToggleResult = 'added' | 'removed' | 'signed_out' | 'failed';
|
|
2812
|
+
interface FavoritesSnapshot {
|
|
2813
|
+
status: FavoritesStatus;
|
|
2814
|
+
saved: ReadonlySet<string>;
|
|
2815
|
+
pending: ReadonlySet<string>;
|
|
2816
|
+
}
|
|
2817
|
+
interface FavoritesApi {
|
|
2818
|
+
status: FavoritesStatus;
|
|
2819
|
+
isFavorite(productUniqid: string): boolean;
|
|
2820
|
+
/** A write for this product is in flight; the heart should say so and ignore presses. */
|
|
2821
|
+
isPending(productUniqid: string): boolean;
|
|
2822
|
+
toggle(productUniqid: string): Promise<FavoriteToggleResult>;
|
|
2823
|
+
}
|
|
2824
|
+
/** Fired by the account panel after it removed a favorite, so hearts on the page follow. */
|
|
2825
|
+
declare const FAVORITES_CHANGED_EVENT = "sx:favorites-changed";
|
|
2826
|
+
declare function notifyFavoritesChanged(): void;
|
|
2827
|
+
/** The three SDK calls the store needs; injectable so the logic is testable without a page. */
|
|
2828
|
+
interface FavoritesTransport {
|
|
2829
|
+
list(): Promise<SdkResponse<unknown>>;
|
|
2830
|
+
add(productUniqid: string): Promise<SdkResponse<unknown>>;
|
|
2831
|
+
remove(productUniqid: string): Promise<SdkResponse<unknown>>;
|
|
2832
|
+
}
|
|
2833
|
+
declare const sdkFavoritesTransport: FavoritesTransport;
|
|
2834
|
+
interface FavoritesStore {
|
|
2835
|
+
getSnapshot(): FavoritesSnapshot;
|
|
2836
|
+
subscribe(listener: () => void): () => void;
|
|
2837
|
+
load(): Promise<void>;
|
|
2838
|
+
toggle(productUniqid: string): Promise<FavoriteToggleResult>;
|
|
2839
|
+
}
|
|
2840
|
+
declare function createFavoritesStore(transport: FavoritesTransport): FavoritesStore;
|
|
2841
|
+
declare function FavoritesProvider({ children, transport, }: {
|
|
2842
|
+
children: ReactNode;
|
|
2843
|
+
transport?: FavoritesTransport;
|
|
2844
|
+
}): react_jsx_runtime.JSX.Element;
|
|
2845
|
+
declare function useFavorites(): FavoritesApi;
|
|
2846
|
+
|
|
2663
2847
|
/**
|
|
2664
2848
|
* The merchant's navigation menus, and where they sit against theme content.
|
|
2665
2849
|
*
|
|
@@ -2888,6 +3072,8 @@ interface ShopReview {
|
|
|
2888
3072
|
productTitle: string | null;
|
|
2889
3073
|
/** True when the review is tied to a real completed purchase. */
|
|
2890
3074
|
verified: boolean;
|
|
3075
|
+
/** Left by the shop's review automation, not written by the buyer. */
|
|
3076
|
+
automated: boolean;
|
|
2891
3077
|
}
|
|
2892
3078
|
type ShopReviewsState = {
|
|
2893
3079
|
status: 'loading';
|
|
@@ -2925,14 +3111,62 @@ declare function toShopReviews(rows: readonly SdkShopReview[], labels: ShopRevie
|
|
|
2925
3111
|
* derive a number from them.
|
|
2926
3112
|
*/
|
|
2927
3113
|
declare function reviewsForProduct(reviews: readonly ShopReview[], productTitle: string): ShopReview[];
|
|
3114
|
+
/** One page of the shop's reviews, newest first. */
|
|
3115
|
+
interface ShopReviewsPageResult {
|
|
3116
|
+
reviews: ShopReview[];
|
|
3117
|
+
/** Pass to the next call; null on the last page. */
|
|
3118
|
+
nextCursor: string | null;
|
|
3119
|
+
/** Counts over the whole list (or the product's reviews), null when the API sent none. */
|
|
3120
|
+
summary: SdkShopReviewsSummary | null;
|
|
3121
|
+
}
|
|
3122
|
+
/**
|
|
3123
|
+
* One page of reviews from the feed, optionally for one product (its catalog
|
|
3124
|
+
* `id`). Throws when the request fails.
|
|
3125
|
+
*
|
|
3126
|
+
* A product page must never show another product's reviews, so a filtered
|
|
3127
|
+
* request also requires the API to echo the filter back: an API that predates
|
|
3128
|
+
* `product` ignores it and would answer with the whole shop's list.
|
|
3129
|
+
*/
|
|
3130
|
+
declare function loadShopReviewsPage(options: {
|
|
3131
|
+
cursor?: string | null;
|
|
3132
|
+
product?: string | null;
|
|
3133
|
+
labels: ShopReviewLabels;
|
|
3134
|
+
}): Promise<ShopReviewsPageResult>;
|
|
2928
3135
|
/**
|
|
2929
3136
|
* The newest WRITTEN reviews, at most `limit`, for a sample such as a home
|
|
2930
|
-
* section. Pages through the feed only until it has
|
|
2931
|
-
*
|
|
2932
|
-
*
|
|
2933
|
-
|
|
3137
|
+
* section or a product's review tab. Pages through the feed only until it has
|
|
3138
|
+
* enough. Automated entries and ratings without words are skipped, since a
|
|
3139
|
+
* sample of quotes needs quotes. Resolves null when a page request fails.
|
|
3140
|
+
*/
|
|
3141
|
+
declare function loadLatestWrittenReviews(limit: number, labels: ShopReviewLabels, options?: {
|
|
3142
|
+
product?: string | null;
|
|
3143
|
+
}): Promise<ShopReview[] | null>;
|
|
3144
|
+
type PagedShopReviewsState = {
|
|
3145
|
+
status: 'loading';
|
|
3146
|
+
} | {
|
|
3147
|
+
status: 'error';
|
|
3148
|
+
} | {
|
|
3149
|
+
status: 'ready';
|
|
3150
|
+
reviews: ShopReview[];
|
|
3151
|
+
summary: SdkShopReviewsSummary | null;
|
|
3152
|
+
hasMore: boolean;
|
|
3153
|
+
/** True while the next page is on its way. */
|
|
3154
|
+
loadingMore: boolean;
|
|
3155
|
+
/** Set when the NEXT page failed; the pages already shown stay. */
|
|
3156
|
+
moreFailed: boolean;
|
|
3157
|
+
};
|
|
3158
|
+
/**
|
|
3159
|
+
* The shop's reviews, one page at a time: the first page on mount (or when
|
|
3160
|
+
* `product` changes), the next only when `loadMore` is called. The summary is
|
|
3161
|
+
* the API's, so the score and breakdown describe the whole list, not the pages
|
|
3162
|
+
* loaded so far.
|
|
2934
3163
|
*/
|
|
2935
|
-
declare function
|
|
3164
|
+
declare function usePagedShopReviews(options: {
|
|
3165
|
+
product?: string | null;
|
|
3166
|
+
labels: ShopReviewLabels;
|
|
3167
|
+
}): PagedShopReviewsState & {
|
|
3168
|
+
loadMore: () => void;
|
|
3169
|
+
};
|
|
2936
3170
|
declare function averageRating(reviews: readonly ShopReview[]): number | null;
|
|
2937
3171
|
declare function useShopReviews(labels: ShopReviewLabels): ShopReviewsState;
|
|
2938
3172
|
|
|
@@ -3033,19 +3267,63 @@ type ShopPageState = {
|
|
|
3033
3267
|
status: 'ready';
|
|
3034
3268
|
page: ShopPageModel;
|
|
3035
3269
|
}
|
|
3036
|
-
/** The
|
|
3270
|
+
/** The API answered that no such page exists (404), or the page has no name. */
|
|
3037
3271
|
| {
|
|
3038
3272
|
status: 'missing';
|
|
3273
|
+
}
|
|
3274
|
+
/**
|
|
3275
|
+
* The page could not be loaded: the API failed or could not be reached, or
|
|
3276
|
+
* the page's body could not be rendered. Not "missing": the page may exist.
|
|
3277
|
+
*/
|
|
3278
|
+
| {
|
|
3279
|
+
status: 'error';
|
|
3039
3280
|
};
|
|
3040
3281
|
/**
|
|
3041
3282
|
* Loads one CMS page by slug.
|
|
3042
3283
|
*
|
|
3043
|
-
*
|
|
3044
|
-
*
|
|
3045
|
-
*
|
|
3284
|
+
* `missing` only when the API says so (404) or the page it returns has no name
|
|
3285
|
+
* to show; inventing a title from the slug would publish a heading the merchant
|
|
3286
|
+
* never wrote. Any other failure is `error`, so an outage never tells a buyer a
|
|
3287
|
+
* real page does not exist.
|
|
3046
3288
|
*/
|
|
3047
3289
|
declare function loadShopPage(slug: string): Promise<ShopPageState>;
|
|
3048
3290
|
|
|
3291
|
+
/**
|
|
3292
|
+
* "Notify me" on sold-out products: a buyer leaves an email and gets one email
|
|
3293
|
+
* when the product (or the chosen option) can be ordered again.
|
|
3294
|
+
*
|
|
3295
|
+
* The control appears only where it can work: the shop allows it
|
|
3296
|
+
* (`settings.stockAlertsEnabled`, a merchant switch enforced by the backend),
|
|
3297
|
+
* and the selection is sold out, not paused. A paused ("coming soon") product
|
|
3298
|
+
* is not a stock state, and an info card can never be bought, so neither
|
|
3299
|
+
* offers an alert.
|
|
3300
|
+
*
|
|
3301
|
+
* The endpoint answers the same for a new and a repeated request, so the UI
|
|
3302
|
+
* says "We'll email you" either way.
|
|
3303
|
+
*/
|
|
3304
|
+
|
|
3305
|
+
declare function canRequestStockAlert(settings: Pick<StorefrontSettings, 'stockAlertsEnabled'>, product: Pick<StorefrontProduct, 'onHold' | 'productType'>, soldOut: boolean): boolean;
|
|
3306
|
+
interface StockAlertRequest {
|
|
3307
|
+
/** The product's uniqid (`StorefrontProduct.id`). */
|
|
3308
|
+
productId: string;
|
|
3309
|
+
/** The sold-out option, or null for the product as a whole. */
|
|
3310
|
+
variantId: StorefrontPriceVariant['id'] | null;
|
|
3311
|
+
email: string;
|
|
3312
|
+
/**
|
|
3313
|
+
* The hidden honeypot input's value. Pass it through untouched: people leave
|
|
3314
|
+
* it empty, form bots fill it, and the server quietly ignores a filled one.
|
|
3315
|
+
*/
|
|
3316
|
+
honeypot?: string;
|
|
3317
|
+
}
|
|
3318
|
+
type StockAlertResult = {
|
|
3319
|
+
ok: true;
|
|
3320
|
+
} | {
|
|
3321
|
+
ok: false;
|
|
3322
|
+
status: number | null;
|
|
3323
|
+
message: string;
|
|
3324
|
+
};
|
|
3325
|
+
declare function requestStockAlert(request: StockAlertRequest): Promise<StockAlertResult>;
|
|
3326
|
+
|
|
3049
3327
|
/**
|
|
3050
3328
|
* The sentence that names the CAUSE rather than the symptom.
|
|
3051
3329
|
*
|
|
@@ -3123,4 +3401,4 @@ declare function useOnlineUserCount(): number | null;
|
|
|
3123
3401
|
*/
|
|
3124
3402
|
declare function resolveProductVideoEmbedSrc(value: unknown): string | null;
|
|
3125
3403
|
|
|
3126
|
-
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, 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 ProductAddon, type ProductAutomaticDeal, type ProductBadge, type ProductBadgeIconName, type ProductBundle, type ProductBundleItem, type ProductCardModel, type ProductCategoryRef, type ProductContentTab, type ProductCustomField, type ProductDetailModel, type ProductFaq, type ProductRatingModel, type ProductSubscription, type ProductType, QUOTE_UNAVAILABLE_CHECKOUT_ERROR, type RatingStars, type ResellerProgramSummary, type RewardProgramItem, type RewardProgramSummary, 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 SdkCustomerAffiliateLink, type SdkCustomerAffiliateSummary, type SdkCustomerDashboard, type SdkCustomerDashboardOrder, type SdkCustomerDeliverable, type SdkCustomerDeliveryStatus, type SdkCustomerDeliverySummary, type SdkCustomerLicense, type SdkCustomerLoyalty, type SdkCustomerLoyaltyRedeem, type SdkCustomerLoyaltyTransactionType, 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 ShopPageFaqItem, type ShopPageModel, type ShopPageState, type ShopReview, type ShopReviewLabels, type ShopReviewsState, type ShoppexSdk, type SocialLink, type SocialNetwork, type StockChip, type StockTone, type StorefrontAddon, type StorefrontCatalog, type StorefrontCategory, type StorefrontData, type StorefrontGroup, type StorefrontListingItem, type StorefrontPriceVariant, type StorefrontProduct, StorefrontProvider, type StorefrontSettings, type StorefrontShop, type StorefrontShopStats, type StorefrontSortKey, type SubscriptionIntervalUnit, type SupportChannel, type VolumeDiscountRule, accountOrderHref, accountRouteMessage, accountTabHref, accountTabLabelKey, averageRating, badgesForCard, badgesForProductPage, buildCartTotals, buildCartView, buildCustomFieldPayload, buildInitialCheckoutFieldValues, buildProductDetail, buildStorefrontCatalog, calculateDisplayLineTotal, calculateLinePricing, canonicalAccountPath, checkoutFieldKey, checkoutFieldWriteRepriced, checkoutNeedsDetails, clampQuantity, clearRecoveredQuoteCheckoutError, 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, missingRequiredCheckoutValues, optionalBoolean, optionalString, optionalStringWithDefault, paginateCatalogCards, parseAccountPath, parseCartQuoteLines, parseEnum, parseFiniteNumber, parseProductBadges, parseStorefrontSortKey, readCheckoutNeedsDetails, readStorefrontData, requireArray, requireBoolean, requireNumber, requireRecord, requireString, requireStringFromKeys, requireUnknownRecord, resolveAccountView, resolveBadgeForeground, resolveCartBoundsHeals, resolveCategorySelection, resolveCheckoutFields, resolveDeliveryPromise, resolveDisplayStock, resolveHideStockCounter, resolveLicenseTerm, resolveMenuLinksForSlot, resolvePayWhatYouWantMinimum, resolveProductVideoEmbedSrc, resolveQuantityBounds, resolveSupportChannels, resolveUnsellableLineIds, resolveVariantStock, reviewsForProduct, roundCurrency, sanitizeMerchantHtml, sortCatalogCards, startCartMutation, stripMerchantHtmlImages, submitContactTicket, toShopReviews, toStarCount, useCart, useNavigationLinks, useOnlineUserCount, useShopReviews, useStorefront, validateCheckoutFieldValue, validateCheckoutFields, validateContactSubmission, withRequiredAddons };
|
|
3404
|
+
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 ProductDetailModel, type ProductFaq, 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 SdkCustomerAffiliateLink, type SdkCustomerAffiliateSummary, type SdkCustomerDashboard, type SdkCustomerDashboardOrder, type SdkCustomerDeliverable, type SdkCustomerDeliveryStatus, type SdkCustomerDeliverySummary, type SdkCustomerLicense, type SdkCustomerLoyalty, type SdkCustomerLoyaltyRedeem, type SdkCustomerLoyaltyTransactionType, 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, 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 };
|