/** * Svelte implementation of Autumn billing client. * * Uses manual state management with Convex Actions for data fetching. * The createCustomer action calls external APIs and is not reactive like queries. */ import type { AutumnConvexApi, Customer, Entity, Product, CheckParams, CheckResult, CheckoutParams, CheckoutResult, TrackParams, TrackResult, AttachParams, AttachResult, CancelParams, BillingPortalParams, BillingPortalResult, CreateEntityParams, GetEntityParams, SetupPaymentParams, SetupPaymentResult, CreateReferralCodeParams, CreateReferralCodeResult, RedeemReferralCodeParams, RedeemReferralCodeResult, SetUsageParams, SetUsageResult, QueryParams, QueryResult, EventListParams, EventListResult, EventAggregateParams, LocalCheckResult, RefetchOptions } from "./types.js"; /** * Creates an Autumn billing client with Svelte reactivity. * * Provides reactive access to customer data and methods for interacting with * Autumn billing features including subscriptions, usage tracking, and checkout. * * @param options - Configuration object * @param options.convexApi - The Autumn Convex API to use for actions * @returns Autumn client API with reactive customer data and action methods * @example * ```ts * const autumn = createAutumnClient({ convexApi }); * console.log(autumn.customer?.email); * await autumn.checkout({ productId: 'prod_123' }); * ``` */ export declare function createAutumnClient({ convexApi, }: { convexApi: AutumnConvexApi; }): { readonly customer: Customer | null | undefined; readonly isLoading: boolean; readonly error: Error | null | undefined; allowed: (params: CheckParams) => LocalCheckResult; check: (params: CheckParams, options?: RefetchOptions) => Promise; checkout: (params: CheckoutParams, options?: RefetchOptions) => Promise; track: (params: TrackParams, options?: RefetchOptions) => Promise; attach: (params: AttachParams, options?: RefetchOptions) => Promise; cancel: (params: CancelParams, options?: RefetchOptions) => Promise; openBillingPortal: (params?: BillingPortalParams) => Promise; createEntity: (params: CreateEntityParams, options?: RefetchOptions) => Promise; getEntity: (params: GetEntityParams) => Promise; setupPayment: (params?: SetupPaymentParams, options?: RefetchOptions) => Promise; createReferralCode: (params: CreateReferralCodeParams, options?: RefetchOptions) => Promise; redeemReferralCode: (params: RedeemReferralCodeParams, options?: RefetchOptions) => Promise; listProducts: () => Promise; usage: (params: SetUsageParams) => Promise; query: (params: QueryParams) => Promise; listEvents: (params: EventListParams) => Promise; aggregateEvents: (params: EventAggregateParams) => Promise; refetch: () => Promise; }; /** * Sets the Autumn client in Svelte context. * * @param autumnClient - The Autumn client instance to set in context * @returns The client instance */ export declare function setAutumnContext(autumnClient: ReturnType): { readonly customer: Customer | null | undefined; readonly isLoading: boolean; readonly error: Error | null | undefined; allowed: (params: CheckParams) => LocalCheckResult; check: (params: CheckParams, options?: RefetchOptions) => Promise; checkout: (params: CheckoutParams, options?: RefetchOptions) => Promise; track: (params: TrackParams, options?: RefetchOptions) => Promise; attach: (params: AttachParams, options?: RefetchOptions) => Promise; cancel: (params: CancelParams, options?: RefetchOptions) => Promise; openBillingPortal: (params?: BillingPortalParams) => Promise; createEntity: (params: CreateEntityParams, options?: RefetchOptions) => Promise; getEntity: (params: GetEntityParams) => Promise; setupPayment: (params?: SetupPaymentParams, options?: RefetchOptions) => Promise; createReferralCode: (params: CreateReferralCodeParams, options?: RefetchOptions) => Promise; redeemReferralCode: (params: RedeemReferralCodeParams, options?: RefetchOptions) => Promise; listProducts: () => Promise; usage: (params: SetUsageParams) => Promise; query: (params: QueryParams) => Promise; listEvents: (params: EventListParams) => Promise; aggregateEvents: (params: EventAggregateParams) => Promise; refetch: () => Promise; }; /** * Retrieves the Autumn client from Svelte context. * * @returns The Autumn client instance */ export declare function getAutumnContext(): { readonly customer: Customer | null | undefined; readonly isLoading: boolean; readonly error: Error | null | undefined; allowed: (params: CheckParams) => LocalCheckResult; check: (params: CheckParams, options?: RefetchOptions) => Promise; checkout: (params: CheckoutParams, options?: RefetchOptions) => Promise; track: (params: TrackParams, options?: RefetchOptions) => Promise; attach: (params: AttachParams, options?: RefetchOptions) => Promise; cancel: (params: CancelParams, options?: RefetchOptions) => Promise; openBillingPortal: (params?: BillingPortalParams) => Promise; createEntity: (params: CreateEntityParams, options?: RefetchOptions) => Promise; getEntity: (params: GetEntityParams) => Promise; setupPayment: (params?: SetupPaymentParams, options?: RefetchOptions) => Promise; createReferralCode: (params: CreateReferralCodeParams, options?: RefetchOptions) => Promise; redeemReferralCode: (params: RedeemReferralCodeParams, options?: RefetchOptions) => Promise; listProducts: () => Promise; usage: (params: SetUsageParams) => Promise; query: (params: QueryParams) => Promise; listEvents: (params: EventListParams) => Promise; aggregateEvents: (params: EventAggregateParams) => Promise; refetch: () => Promise; }; /** * Checks if Autumn client exists in context. * * @returns True if Autumn client is available in context */ export declare function hasAutumnContext(): boolean; //# sourceMappingURL=client.svelte.d.ts.map