/** * Svelte bindings for Autumn billing integration * * @module */ import type { AutumnConvexApi } from "./types.js"; /** * Initialize Autumn for Svelte. * * This function sets up Autumn billing integration for your Svelte application. * It should be called in your root layout or App component. * * @param convexApi - The Autumn API from your Convex backend (e.g., api.autumn) * @returns The Autumn client instance that can be used to access billing methods * @example * ```svelte * * * * ``` */ export declare function setupAutumn({ convexApi, }: { /** Autumn Convex API object (e.g., api.autumn from generated types) */ convexApi: AutumnConvexApi; }): { readonly customer: import("./types.js").Customer | null | undefined; readonly isLoading: boolean; readonly error: Error | null | undefined; allowed: (params: import("./types.js").CheckParams) => import("./types.js").LocalCheckResult; check: (params: import("./types.js").CheckParams, options?: import("./types.js").RefetchOptions) => Promise; checkout: (params: import("./types.js").CheckoutParams, options?: import("./types.js").RefetchOptions) => Promise; track: (params: import("./types.js").TrackParams, options?: import("./types.js").RefetchOptions) => Promise; attach: (params: import("./types.js").AttachParams, options?: import("./types.js").RefetchOptions) => Promise; cancel: (params: import("./types.js").CancelParams, options?: import("./types.js").RefetchOptions) => Promise; openBillingPortal: (params?: import("./types.js").BillingPortalParams) => Promise; createEntity: (params: import("./types.js").CreateEntityParams, options?: import("./types.js").RefetchOptions) => Promise; getEntity: (params: import("./types.js").GetEntityParams) => Promise; setupPayment: (params?: import("./types.js").SetupPaymentParams, options?: import("./types.js").RefetchOptions) => Promise; createReferralCode: (params: import("./types.js").CreateReferralCodeParams, options?: import("./types.js").RefetchOptions) => Promise; redeemReferralCode: (params: import("./types.js").RedeemReferralCodeParams, options?: import("./types.js").RefetchOptions) => Promise; listProducts: () => Promise; usage: (params: import("./types.js").SetUsageParams) => Promise; query: (params: import("./types.js").QueryParams) => Promise; listEvents: (params: import("./types.js").EventListParams) => Promise; aggregateEvents: (params: import("./types.js").EventAggregateParams) => Promise; refetch: () => Promise; }; /** * Hook for accessing customer data and Autumn billing operations. * * Must be called after `setupAutumn()` has been called in a parent component. * * Note: Customer data is fetched once on initialization and automatically * refreshed after mutations (checkout, track, attach, cancel, createEntity). * Use `refetch()` to manually refresh customer data. * * @returns Customer data and billing methods * @returns {Customer | null | undefined} customer - Customer data (null if not found, undefined if loading) * @returns {boolean} isLoading - Whether customer data is currently loading * @returns {Error | null | undefined} error - Error if customer fetch failed * @returns {function(CheckParams): LocalCheckResult} allowed - Local check for feature access without consuming usage * @returns {function(CheckParams): Promise} check - Server-side check with usage tracking * @returns {function(CheckoutParams): Promise} checkout - Initiate checkout; returns a hosted url or a preview to confirm with attach * @returns {function(TrackParams): Promise} track - Track usage of a feature * @returns {function(AttachParams): Promise} attach - Attach a product to the customer * @returns {function(CancelParams): Promise} cancel - Cancel a product subscription * @returns {function(BillingPortalParams): Promise} openBillingPortal - Open Stripe billing portal * @returns {function(CreateEntityParams): Promise} createEntity - Create a new entity * @returns {function(GetEntityParams): Promise} getEntity - Get entity by ID * @returns {function(SetupPaymentParams): Promise} setupPayment - Setup payment method without charging * @returns {function(CreateReferralCodeParams): Promise} createReferralCode - Create a referral code * @returns {function(RedeemReferralCodeParams): Promise} redeemReferralCode - Redeem a referral code for rewards * @returns {function(): Promise} listProducts - List all available products * @returns {function(SetUsageParams): Promise} usage - Set usage to an absolute value (not a query - use customer.features for reading) * @returns {function(QueryParams): Promise} query - Query customer data with custom parameters * @returns {function(EventListParams): Promise} listEvents - List raw Autumn usage events * @returns {function(EventAggregateParams): Promise} aggregateEvents - Aggregate Autumn usage events * @returns {function(): Promise} refetch - Manually refresh customer data * * @example * ```svelte * * * * {#if isLoading} *

Loading...

* {:else if error} *

Error: {error.message}

* {:else if customer} *

Welcome {customer.name}!

*

Messages: {customer.features?.messages?.balance}

* {#if !canUpload} * * {/if} * {/if} * ``` * * @example * ```svelte * * * * * * ``` * * @example * ```svelte * * * * * * * * {#if messagesFeature} *

Usage: {messagesUsed} / {messagesTotal} (Remaining: {messagesRemaining})

* {/if} * ``` */ export declare function useCustomer(): { readonly customer: import("./types.js").Customer | null | undefined; readonly isLoading: boolean; readonly error: Error | null | undefined; allowed: (params: import("./types.js").CheckParams) => import("./types.js").LocalCheckResult; check: (params: import("./types.js").CheckParams, options?: import("./types.js").RefetchOptions) => Promise; checkout: (params: import("./types.js").CheckoutParams, options?: import("./types.js").RefetchOptions) => Promise; track: (params: import("./types.js").TrackParams, options?: import("./types.js").RefetchOptions) => Promise; attach: (params: import("./types.js").AttachParams, options?: import("./types.js").RefetchOptions) => Promise; cancel: (params: import("./types.js").CancelParams, options?: import("./types.js").RefetchOptions) => Promise; openBillingPortal: (params?: import("./types.js").BillingPortalParams) => Promise; createEntity: (params: import("./types.js").CreateEntityParams, options?: import("./types.js").RefetchOptions) => Promise; getEntity: (params: import("./types.js").GetEntityParams) => Promise; setupPayment: (params?: import("./types.js").SetupPaymentParams, options?: import("./types.js").RefetchOptions) => Promise; createReferralCode: (params: import("./types.js").CreateReferralCodeParams, options?: import("./types.js").RefetchOptions) => Promise; redeemReferralCode: (params: import("./types.js").RedeemReferralCodeParams, options?: import("./types.js").RefetchOptions) => Promise; listProducts: () => Promise; usage: (params: import("./types.js").SetUsageParams) => Promise; query: (params: import("./types.js").QueryParams) => Promise; listEvents: (params: import("./types.js").EventListParams) => Promise; aggregateEvents: (params: import("./types.js").EventAggregateParams) => Promise; refetch: () => Promise; }; /** * Check if Autumn has been set up in the current context. */ export declare function isAutumnSetup(): boolean; export type { Customer, Entity, Feature, Product, ProductItem, CheckParams, CheckResult, CheckoutParams, CheckoutResult, TrackParams, TrackResult, AttachParams, AttachResult, AttachFeatureOptions, CancelParams, BillingPortalParams, BillingPortalResult, CreateCustomerParams, CreateEntityParams, GetEntityParams, SetupPaymentParams, SetupPaymentResult, CreateReferralCodeParams, CreateReferralCodeResult, RedeemReferralCodeParams, RedeemReferralCodeResult, SetUsageParams, SetUsageResult, FeatureUsageData, QueryParams, QueryResult, EventRecord, EventListParams, EventListResult, EventAggregateParams, LocalCheckResult, RefetchOptions, AutumnConvexApi, AutumnActionResponse, } from "./types.js"; export { AutumnError, unwrapAutumnResponse } from "./types.js"; //# sourceMappingURL=index.svelte.d.ts.map