@aifeatures/react 0.9.0 → 0.10.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.cts CHANGED
@@ -2139,6 +2139,118 @@ declare namespace PlanPicker {
2139
2139
  var neverConsentGate: string;
2140
2140
  }
2141
2141
 
2142
+ /**
2143
+ * INTERNAL module — shared wire types + fetch classification for the
2144
+ * /v1/account surface (subscriptions Unit 8). Not exported from the package
2145
+ * index except for the payload TYPES (re-exported by the barrel).
2146
+ *
2147
+ * The one non-obvious rule lives here: DARK-PREFIX DETECTION. The whole
2148
+ * /v1/account prefix ships behind a config flag and re-darkening is a live
2149
+ * incident-response move (plan §Magic-link flow), so every route can answer
2150
+ * an EMPTY-BODY 404 indistinguishable from a path that doesn't exist. Live
2151
+ * routes that legitimately 404 (e.g. "Subscription not found") always carry
2152
+ * a JSON `{error}` body — so `404 with a completely EMPTY body` is classified
2153
+ * `unavailable`, and components map it to the login / "temporarily
2154
+ * unavailable" states instead of a dead error. A 404 that carries ANYTHING
2155
+ * (that JSON error, or an interposed proxy/CDN's HTML page) is an ordinary
2156
+ * refusal: the session is not implicated and must not be cleared.
2157
+ */
2158
+ interface ReviewLoginContext {
2159
+ review_product_id: string;
2160
+ review_return_path: string;
2161
+ }
2162
+ interface ReviewReturnContext {
2163
+ product_id: string;
2164
+ path: string | null;
2165
+ account_origin: string;
2166
+ status: 'available' | 'unavailable';
2167
+ }
2168
+ /** One order row from GET /v1/account/me (bounded receipt shelf). */
2169
+ interface AccountOrder {
2170
+ id: string;
2171
+ order_number: number | null;
2172
+ status: string;
2173
+ /** 'checkout' | 'cart' | 'subscription' — subscription = signup or renewal. */
2174
+ source: string;
2175
+ amount_total: number;
2176
+ shipping_total: number | null;
2177
+ tax_total: number | null;
2178
+ currency: string;
2179
+ created_at: string;
2180
+ line_items: Array<{
2181
+ name: string | null;
2182
+ quantity: number | null;
2183
+ unit_amount: number | null;
2184
+ }>;
2185
+ }
2186
+ /**
2187
+ * One subscription row, as serialized by the session surface
2188
+ * (`subscriberSubscriptionView`) — the manage-grant view
2189
+ * (`manageSubscriptionView`) is the same shape minus `product_id` /
2190
+ * `created_at` / `shipping_address`, plus `shipping_name` / `shipping_city`,
2191
+ * so the optional fields cover both doorways with one type.
2192
+ */
2193
+ interface AccountSubscription {
2194
+ id: string;
2195
+ /** Stripe status verbatim ('active', 'past_due', …) — render unmodeled
2196
+ * values generically, never throw on them. */
2197
+ status: string;
2198
+ product_id?: string;
2199
+ plan_title: string | null;
2200
+ plan_interval: string;
2201
+ plan_interval_count: number;
2202
+ /** Locked signup amount (minor units). */
2203
+ plan_amount: number;
2204
+ /** Current recurring amount mirrored from Stripe (falls back to plan_amount). */
2205
+ current_amount: number;
2206
+ currency: string;
2207
+ current_period_end: string | null;
2208
+ cancel_at_period_end: boolean;
2209
+ canceled_at: string | null;
2210
+ /** Terminal — no future invoice can arrive. "Ended — resubscribe" copy. */
2211
+ ended: boolean;
2212
+ is_test: boolean;
2213
+ created_at?: string;
2214
+ shipping_address?: {
2215
+ name?: string | null;
2216
+ address?: {
2217
+ line1?: string | null;
2218
+ line2?: string | null;
2219
+ city?: string | null;
2220
+ state?: string | null;
2221
+ postal_code?: string | null;
2222
+ country?: string | null;
2223
+ } | null;
2224
+ } | null;
2225
+ /** Manage-grant view only. */
2226
+ shipping_name?: string | null;
2227
+ shipping_city?: string | null;
2228
+ }
2229
+ /** Response of GET /v1/account/me. */
2230
+ interface AccountMePayload {
2231
+ customer: {
2232
+ email: string;
2233
+ name: string | null;
2234
+ };
2235
+ site: {
2236
+ name: string;
2237
+ };
2238
+ orders: AccountOrder[];
2239
+ subscriptions: AccountSubscription[];
2240
+ }
2241
+ /** The shipping_address input shape POST /subscriptions/:id/address accepts. */
2242
+ interface AccountShippingAddressInput {
2243
+ name?: string | null;
2244
+ address: {
2245
+ line1: string;
2246
+ line2?: string | null;
2247
+ city?: string | null;
2248
+ state?: string | null;
2249
+ postal_code?: string | null;
2250
+ country: string;
2251
+ };
2252
+ }
2253
+
2142
2254
  interface StoredSessionCustomer {
2143
2255
  email: string;
2144
2256
  name: string | null;
@@ -2156,8 +2268,8 @@ interface UseSessionOptions {
2156
2268
  * on mount (default true). Exactly ONE mounted instance must own the
2157
2269
  * consumption — the code is single-use server-side, so a second instance
2158
2270
  * exchanging it burns it and strands the reason on the wrong hook.
2159
- * AccountLogin sets this false when a parent session is passed in
2160
- * (AccountPage owns the URL there). Read once on mount.
2271
+ * AccountPage owns the URL; product widgets and AccountLogin set this
2272
+ * false. Read once on mount.
2161
2273
  */
2162
2274
  consumeUrlCode?: boolean;
2163
2275
  }
@@ -2174,6 +2286,7 @@ type LoginResult =
2174
2286
  };
2175
2287
  type VerifyResult = {
2176
2288
  ok: true;
2289
+ reviewReturn?: ReviewReturnContext;
2177
2290
  } | {
2178
2291
  ok: false;
2179
2292
  code: 'invalid_code' | 'rate_limited' | 'unavailable' | 'error';
@@ -2187,13 +2300,15 @@ interface UseSessionResult {
2187
2300
  token: string | null;
2188
2301
  /** Why signed_out, when there is a why (expired session, bad code). */
2189
2302
  reason: SessionReason;
2303
+ /** Present only after this instance exchanges a review login code. */
2304
+ reviewReturn?: ReviewReturnContext | null;
2190
2305
  /**
2191
2306
  * Request a magic link for `email` (uniform 200 — "sent" even for unknown
2192
2307
  * addresses, by server design). Inside the editor iframe this offers the
2193
2308
  * preview-session handshake to the host first and only falls back to the
2194
2309
  * real POST when nothing claims it.
2195
2310
  */
2196
- login: (email: string) => Promise<LoginResult>;
2311
+ login: (email: string, reviewContext?: ReviewLoginContext) => Promise<LoginResult>;
2197
2312
  /** POST-exchange a login code (single-use) for a session. */
2198
2313
  verifyCode: (code: string) => Promise<VerifyResult>;
2199
2314
  /** Delete the server session (best-effort) and clear the stored token. */
@@ -2254,6 +2369,8 @@ interface AccountLoginProps {
2254
2369
  * form and the page agree on status). Omit to run standalone.
2255
2370
  */
2256
2371
  session?: UseSessionResult;
2372
+ /** Product-page navigation to preserve through email sign-in and resend. */
2373
+ reviewContext?: ReviewLoginContext;
2257
2374
  /** Delay before the resend affordance appears (default 30s). */
2258
2375
  resendDelayMs?: number;
2259
2376
  className?: string;
@@ -2287,7 +2404,7 @@ interface AccountLoginProps {
2287
2404
  * (useSession.login) and signs straight in when the host claims it — the
2288
2405
  * check-your-email state is skipped.
2289
2406
  */
2290
- declare function AccountLogin({ apiUrl, session: sessionProp, resendDelayMs, className, style, renderForm, renderSent, renderUnavailable, }: AccountLoginProps): react_jsx_runtime.JSX.Element;
2407
+ declare function AccountLogin({ apiUrl, session: sessionProp, reviewContext, resendDelayMs, className, style, renderForm, renderSent, renderUnavailable, }: AccountLoginProps): react_jsx_runtime.JSX.Element;
2291
2408
  declare namespace AccountLogin {
2292
2409
  var neverConsentGate: string;
2293
2410
  }
@@ -2361,108 +2478,6 @@ declare namespace AccountPage {
2361
2478
  var neverConsentGate: string;
2362
2479
  }
2363
2480
 
2364
- /**
2365
- * INTERNAL module — shared wire types + fetch classification for the
2366
- * /v1/account surface (subscriptions Unit 8). Not exported from the package
2367
- * index except for the payload TYPES (re-exported by the barrel).
2368
- *
2369
- * The one non-obvious rule lives here: DARK-PREFIX DETECTION. The whole
2370
- * /v1/account prefix ships behind a config flag and re-darkening is a live
2371
- * incident-response move (plan §Magic-link flow), so every route can answer
2372
- * an EMPTY-BODY 404 indistinguishable from a path that doesn't exist. Live
2373
- * routes that legitimately 404 (e.g. "Subscription not found") always carry
2374
- * a JSON `{error}` body — so `404 with a completely EMPTY body` is classified
2375
- * `unavailable`, and components map it to the login / "temporarily
2376
- * unavailable" states instead of a dead error. A 404 that carries ANYTHING
2377
- * (that JSON error, or an interposed proxy/CDN's HTML page) is an ordinary
2378
- * refusal: the session is not implicated and must not be cleared.
2379
- */
2380
- /** One order row from GET /v1/account/me (bounded receipt shelf). */
2381
- interface AccountOrder {
2382
- id: string;
2383
- order_number: number | null;
2384
- status: string;
2385
- /** 'checkout' | 'cart' | 'subscription' — subscription = signup or renewal. */
2386
- source: string;
2387
- amount_total: number;
2388
- shipping_total: number | null;
2389
- tax_total: number | null;
2390
- currency: string;
2391
- created_at: string;
2392
- line_items: Array<{
2393
- name: string | null;
2394
- quantity: number | null;
2395
- unit_amount: number | null;
2396
- }>;
2397
- }
2398
- /**
2399
- * One subscription row, as serialized by the session surface
2400
- * (`subscriberSubscriptionView`) — the manage-grant view
2401
- * (`manageSubscriptionView`) is the same shape minus `product_id` /
2402
- * `created_at` / `shipping_address`, plus `shipping_name` / `shipping_city`,
2403
- * so the optional fields cover both doorways with one type.
2404
- */
2405
- interface AccountSubscription {
2406
- id: string;
2407
- /** Stripe status verbatim ('active', 'past_due', …) — render unmodeled
2408
- * values generically, never throw on them. */
2409
- status: string;
2410
- product_id?: string;
2411
- plan_title: string | null;
2412
- plan_interval: string;
2413
- plan_interval_count: number;
2414
- /** Locked signup amount (minor units). */
2415
- plan_amount: number;
2416
- /** Current recurring amount mirrored from Stripe (falls back to plan_amount). */
2417
- current_amount: number;
2418
- currency: string;
2419
- current_period_end: string | null;
2420
- cancel_at_period_end: boolean;
2421
- canceled_at: string | null;
2422
- /** Terminal — no future invoice can arrive. "Ended — resubscribe" copy. */
2423
- ended: boolean;
2424
- is_test: boolean;
2425
- created_at?: string;
2426
- shipping_address?: {
2427
- name?: string | null;
2428
- address?: {
2429
- line1?: string | null;
2430
- line2?: string | null;
2431
- city?: string | null;
2432
- state?: string | null;
2433
- postal_code?: string | null;
2434
- country?: string | null;
2435
- } | null;
2436
- } | null;
2437
- /** Manage-grant view only. */
2438
- shipping_name?: string | null;
2439
- shipping_city?: string | null;
2440
- }
2441
- /** Response of GET /v1/account/me. */
2442
- interface AccountMePayload {
2443
- customer: {
2444
- email: string;
2445
- name: string | null;
2446
- };
2447
- site: {
2448
- name: string;
2449
- };
2450
- orders: AccountOrder[];
2451
- subscriptions: AccountSubscription[];
2452
- }
2453
- /** The shipping_address input shape POST /subscriptions/:id/address accepts. */
2454
- interface AccountShippingAddressInput {
2455
- name?: string | null;
2456
- address: {
2457
- line1: string;
2458
- line2?: string | null;
2459
- city?: string | null;
2460
- state?: string | null;
2461
- postal_code?: string | null;
2462
- country: string;
2463
- };
2464
- }
2465
-
2466
2481
  interface AccountOrdersProps {
2467
2482
  /** The `orders` array from GET /v1/account/me (newest first, bounded). */
2468
2483
  orders: AccountOrder[];
@@ -2595,4 +2610,118 @@ interface ConsentPolicyDetailsProps {
2595
2610
  * facts around this section. It is not a complete legal policy. */
2596
2611
  declare function ConsentPolicyDetails({ className, style }: ConsentPolicyDetailsProps): react_jsx_runtime.JSX.Element;
2597
2612
 
2598
- export { AccountLogin, type AccountLoginFormContext, type AccountLoginProps, type AccountLoginSentContext, type AccountMePayload, type AccountOrder, AccountOrders, type AccountOrdersProps, AccountPage, type AccountPagePmBannerContext, type AccountPageProps, type AccountShippingAddressInput, type AccountSubscription, type AddCartLineInput, AddToCartButton, type AddToCartButtonProps, type AddToCartResult, AifeaturesCaptcha, type AifeaturesCaptchaProps, AifeaturesProvider, type AifeaturesProviderProps, BuyButton, type BuyButtonProps, CartCheckoutButton, type CartCheckoutButtonProps, type CartCheckoutLine, type CartConflictItem, type CartItemLine, type CartLine, type CartLineDisplay, type CartLineStatus, type CartSummary, type CartSummaryShipping, type CartSummaryShippingOption, ConsentBanner, type ConsentBannerDisclosureProps, type ConsentBannerProps, type ConsentCategory, type ConsentDisclosureStrings, type ConsentGrants, type ConsentIntegration, type ConsentLocale, type ConsentManifest, ConsentPolicyDetails, type ConsentPolicyDetailsProps, ConsentProvider, type ConsentProviderProps, type ConsentThemeTokens, CookieSettingsLink, type CookieSettingsLinkProps, GatedContent, type GatedContentProps, type GatedContentStrings, GatedScript, type GatedScriptProps, type LoginResult, MARKET_COUNTRIES, MAX_CART_LINES, type MarketCountry, OrderConfirmation, type OrderConfirmationProps, type OrderFulfillment, type OrderSession, type OrderSessionLineItem, type OrderSessionSubscription, type OrderStatus, PlanPicker, type PlanPickerOptionContext, type PlanPickerProps, PreferencesPanel, type PreferencesPanelProps, type PreferencesStrings, ProductPrice, type ProductPriceProps, type PublicOption, type PublicOptionValue, type PublicProduct, type PublicProductSubscription, type PublicSubscriptionPlan, type PublicVariant, type PublicVariantOptionValue, type SessionCustomer, type SessionReason, type SessionStatus, type ShippingOptionConflict, type StartCartCheckoutOptions, type StartCheckoutOptions, SubscriptionList, type SubscriptionListAuth, type SubscriptionListProps, type SubscriptionMutationState, type SubscriptionRowContext, type UseCartCheckoutOptions, type UseCartCheckoutResult, type UseCartItemsOptions, type UseCartItemsResult, type UseCartResult, type UseCartSummaryOptions, type UseCartSummaryResult, type UseCheckoutOptions, type UseCheckoutResult, type UseConsentResult, type UseMarketOptions, type UseMarketResult, type UseProductOptions, type UseProductResult, type UseSessionOptions, type UseSessionResult, VariantPicker, type VariantPickerProps, type VariantSelection, type VerifyResult, ZERO_DECIMAL_CURRENCIES, applySelectionToUrl, consentLocales, formatPrice, getOptions, getVariants, isMultiVariant, isValueAvailable, isValueInCatalog, planRecurringAmount, reanchorSelection, resolveVariant, searchFromSelection, selectedImages, selectedValues, selectionFromSearch, useAifeaturesApiUrl, useCart, useCartCheckout, useCartItems, useCartSummary, useCheckout, useConsent, useMarket, useProduct, useSession, valueSlug, variantPriceRange };
2613
+ interface ProductReview {
2614
+ id: string;
2615
+ rating: number;
2616
+ display_name: string;
2617
+ title: string | null;
2618
+ body: string;
2619
+ created_at: string;
2620
+ updated_at: string;
2621
+ verified_purchase: boolean;
2622
+ reply: string | null;
2623
+ reply_updated_at: string | null;
2624
+ }
2625
+ interface OwnProductReview extends ProductReview {
2626
+ revision: number;
2627
+ moderation_state: 'published' | 'hidden';
2628
+ withdrawn_at: string | null;
2629
+ product_id: string;
2630
+ product_path: string | null;
2631
+ product_name: string | null;
2632
+ product_available: boolean;
2633
+ }
2634
+ interface ReviewSummary {
2635
+ count: number;
2636
+ average: number | null;
2637
+ distribution: Record<1 | 2 | 3 | 4 | 5, number>;
2638
+ }
2639
+ interface ReviewAvailability {
2640
+ site_id: string;
2641
+ collection_available: boolean;
2642
+ editing_available: boolean;
2643
+ reason: string | null;
2644
+ turnstile_site_key: string | null;
2645
+ account_origin: string | null;
2646
+ }
2647
+
2648
+ interface UseProductReviewsOptions {
2649
+ apiUrl?: string;
2650
+ /** Optional site namespace; product IDs are already globally unique. */
2651
+ siteId?: string;
2652
+ sort?: 'newest' | 'highest' | 'lowest';
2653
+ rating?: 1 | 2 | 3 | 4 | 5;
2654
+ limit?: number;
2655
+ }
2656
+ interface UseProductReviewsResult {
2657
+ reviews: ProductReview[];
2658
+ summary: ReviewSummary | null;
2659
+ loading: boolean;
2660
+ loadingMore: boolean;
2661
+ error: string | null;
2662
+ /** The product is archived, inactive or removed; retry cannot restore it. */
2663
+ productUnavailable: boolean;
2664
+ hasMore: boolean;
2665
+ refresh: () => void;
2666
+ loadMore: () => void;
2667
+ }
2668
+ declare function useProductReviews(productId: string, options?: UseProductReviewsOptions): UseProductReviewsResult;
2669
+
2670
+ interface ProductRatingProps {
2671
+ productId: string;
2672
+ apiUrl?: string;
2673
+ siteId?: string;
2674
+ className?: string;
2675
+ style?: CSSProperties;
2676
+ render?: (context: {
2677
+ summary: ReviewSummary | null;
2678
+ loading: boolean;
2679
+ error: string | null;
2680
+ productUnavailable: boolean;
2681
+ retry: () => void;
2682
+ }) => ReactNode;
2683
+ }
2684
+ declare function ProductRating({ productId, apiUrl, siteId, className, style, render, }: ProductRatingProps): react_jsx_runtime.JSX.Element;
2685
+ declare namespace ProductRating {
2686
+ var neverConsentGate: string;
2687
+ }
2688
+
2689
+ interface ProductReviewsProps {
2690
+ productId: string;
2691
+ apiUrl?: string;
2692
+ siteId?: string;
2693
+ preview?: boolean;
2694
+ className?: string;
2695
+ style?: CSSProperties;
2696
+ renderReview?: (review: ProductReview) => ReactNode;
2697
+ }
2698
+ declare function ProductReviews(props: ProductReviewsProps): react_jsx_runtime.JSX.Element;
2699
+ declare namespace ProductReviews {
2700
+ var neverConsentGate: string;
2701
+ }
2702
+
2703
+ interface ProductReviewFormProps {
2704
+ productId: string;
2705
+ apiUrl?: string;
2706
+ preview?: boolean;
2707
+ className?: string;
2708
+ style?: CSSProperties;
2709
+ onSaved?: (review: OwnProductReview) => void;
2710
+ }
2711
+ declare function ProductReviewForm(props: ProductReviewFormProps): react_jsx_runtime.JSX.Element;
2712
+ declare namespace ProductReviewForm {
2713
+ var neverConsentGate: string;
2714
+ }
2715
+
2716
+ interface AccountReviewsProps {
2717
+ apiUrl?: string;
2718
+ className?: string;
2719
+ style?: CSSProperties;
2720
+ }
2721
+ /** Account discovery and withdrawal only. Editing always uses the product page. */
2722
+ declare function AccountReviews({ apiUrl: explicitApiUrl, ...props }: AccountReviewsProps): react_jsx_runtime.JSX.Element;
2723
+ declare namespace AccountReviews {
2724
+ var neverConsentGate: string;
2725
+ }
2726
+
2727
+ export { AccountLogin, type AccountLoginFormContext, type AccountLoginProps, type AccountLoginSentContext, type AccountMePayload, type AccountOrder, AccountOrders, type AccountOrdersProps, AccountPage, type AccountPagePmBannerContext, type AccountPageProps, AccountReviews, type AccountReviewsProps, type AccountShippingAddressInput, type AccountSubscription, type AddCartLineInput, AddToCartButton, type AddToCartButtonProps, type AddToCartResult, AifeaturesCaptcha, type AifeaturesCaptchaProps, AifeaturesProvider, type AifeaturesProviderProps, BuyButton, type BuyButtonProps, CartCheckoutButton, type CartCheckoutButtonProps, type CartCheckoutLine, type CartConflictItem, type CartItemLine, type CartLine, type CartLineDisplay, type CartLineStatus, type CartSummary, type CartSummaryShipping, type CartSummaryShippingOption, ConsentBanner, type ConsentBannerDisclosureProps, type ConsentBannerProps, type ConsentCategory, type ConsentDisclosureStrings, type ConsentGrants, type ConsentIntegration, type ConsentLocale, type ConsentManifest, ConsentPolicyDetails, type ConsentPolicyDetailsProps, ConsentProvider, type ConsentProviderProps, type ConsentThemeTokens, CookieSettingsLink, type CookieSettingsLinkProps, GatedContent, type GatedContentProps, type GatedContentStrings, GatedScript, type GatedScriptProps, type LoginResult, MARKET_COUNTRIES, MAX_CART_LINES, type MarketCountry, OrderConfirmation, type OrderConfirmationProps, type OrderFulfillment, type OrderSession, type OrderSessionLineItem, type OrderSessionSubscription, type OrderStatus, type OwnProductReview, PlanPicker, type PlanPickerOptionContext, type PlanPickerProps, PreferencesPanel, type PreferencesPanelProps, type PreferencesStrings, ProductPrice, type ProductPriceProps, ProductRating, type ProductRatingProps, type ProductReview, ProductReviewForm, type ProductReviewFormProps, ProductReviews, type ProductReviewsProps, type PublicOption, type PublicOptionValue, type PublicProduct, type PublicProductSubscription, type PublicSubscriptionPlan, type PublicVariant, type PublicVariantOptionValue, type ReviewAvailability, type ReviewSummary, type SessionCustomer, type SessionReason, type SessionStatus, type ShippingOptionConflict, type StartCartCheckoutOptions, type StartCheckoutOptions, SubscriptionList, type SubscriptionListAuth, type SubscriptionListProps, type SubscriptionMutationState, type SubscriptionRowContext, type UseCartCheckoutOptions, type UseCartCheckoutResult, type UseCartItemsOptions, type UseCartItemsResult, type UseCartResult, type UseCartSummaryOptions, type UseCartSummaryResult, type UseCheckoutOptions, type UseCheckoutResult, type UseConsentResult, type UseMarketOptions, type UseMarketResult, type UseProductOptions, type UseProductResult, type UseProductReviewsOptions, type UseProductReviewsResult, type UseSessionOptions, type UseSessionResult, VariantPicker, type VariantPickerProps, type VariantSelection, type VerifyResult, ZERO_DECIMAL_CURRENCIES, applySelectionToUrl, consentLocales, formatPrice, getOptions, getVariants, isMultiVariant, isValueAvailable, isValueInCatalog, planRecurringAmount, reanchorSelection, resolveVariant, searchFromSelection, selectedImages, selectedValues, selectionFromSearch, useAifeaturesApiUrl, useCart, useCartCheckout, useCartItems, useCartSummary, useCheckout, useConsent, useMarket, useProduct, useProductReviews, useSession, valueSlug, variantPriceRange };