//#region src/core/types.d.ts type FeatureType = 'boolean' | 'limit' | 'rate' | 'metered'; interface FeatureDefinition { type: T; default: T extends 'boolean' ? boolean : number; description?: string; } type FeatureRegistry = Record; /** * Infer the value type for a feature based on its definition */ type FeatureValue = T['type'] extends 'boolean' ? boolean : number; /** * Infer all feature values from a registry */ type FeatureValues = { [K in keyof T]: FeatureValue; }; /** * Partial feature values for plan creation/update */ type PartialFeatureValues = Partial>; type BillingInterval = 'monthly' | 'yearly' | 'one_time' | 'custom'; interface BillingConfig { interval: BillingInterval; intervalCount?: number; } /** * An additional price point for a plan in another currency */ interface PlanPrice { currency: string; amount: number; } interface Plan { id: string; name: string; description: string | null; price: number; currency: string; /** * Optional additional price points in other currencies. * The canonical price remains `price`/`currency`. */ prices?: PlanPrice[]; interval: BillingInterval; intervalCount: number; trialDays: number; features: PartialFeatureValues; isActive: boolean; sortOrder: number; metadata: Record | null; createdAt: Date; updatedAt: Date; } interface CreatePlanInput { name: string; description?: string | null; price: number; currency?: string; interval: BillingInterval; intervalCount?: number; trialDays?: number; features?: PartialFeatureValues; prices?: PlanPrice[]; isActive?: boolean; sortOrder?: number; metadata?: Record; } interface UpdatePlanInput { name?: string; description?: string | null; price?: number; currency?: string; interval?: BillingInterval; intervalCount?: number; trialDays?: number; features?: PartialFeatureValues; prices?: PlanPrice[]; isActive?: boolean; sortOrder?: number; metadata?: Record; } type SubscriptionStatus = 'trialing' | 'active' | 'past_due' | 'canceled' | 'incomplete' | 'incomplete_expired' | 'unpaid' | 'paused'; type SubscriberType = 'tenant' | 'user'; interface Subscription { id: string; subscriberId: string; subscriberType: SubscriberType; planId: string; status: SubscriptionStatus; currentPeriodStart: Date; currentPeriodEnd: Date; cancelAt: Date | null; canceledAt: Date | null; trialStart: Date | null; trialEnd: Date | null; gatewaySubscriptionId: string | null; gatewayCustomerId: string | null; /** * Seat/unit quantity for per-seat billing. * @default 1 */ quantity?: number; /** * IDs of add-ons attached to this subscription. */ addOns?: string[]; metadata: Record | null; createdAt: Date; updatedAt: Date; } interface SubscriptionWithPlan extends Subscription { plan: Plan; } interface CreateSubscriptionInput { subscriberId: string; subscriberType?: SubscriberType | undefined; planId: string; status?: SubscriptionStatus | undefined; currentPeriodStart?: Date | undefined; currentPeriodEnd?: Date | undefined; trialStart?: Date | null | undefined; trialEnd?: Date | null | undefined; gatewaySubscriptionId?: string | undefined; gatewayCustomerId?: string | undefined; quantity?: number | undefined; addOns?: string[] | undefined; metadata?: Record | undefined; } interface UpdateSubscriptionInput { planId?: string; status?: SubscriptionStatus; currentPeriodStart?: Date; currentPeriodEnd?: Date; cancelAt?: Date | null; canceledAt?: Date | null; trialStart?: Date | null; trialEnd?: Date | null; gatewaySubscriptionId?: string; gatewayCustomerId?: string; quantity?: number; addOns?: string[]; metadata?: Record; } interface UsageRecord { id: string; subscriberId: string; feature: string; count: number; periodStart: Date; periodEnd: Date; createdAt: Date; updatedAt: Date; } interface UsageStatus { feature: string; used: number; limit: number; remaining: number; percentage: number; unlimited: boolean; } type InvoiceStatus = 'draft' | 'open' | 'paid' | 'uncollectible' | 'void'; interface Invoice { id: string; subscriptionId: string; subscriberId: string; amount: number; currency: string; status: InvoiceStatus; /** * Sequential human-readable invoice number (e.g. `INV-000123`). * Generated when the database adapter implements `invoices.nextInvoiceNumber`. */ invoiceNumber?: string | null; /** * Sum of line item amounts before tax and discounts. */ subtotal?: number; /** * Tax rate applied (percentage), when uniform across line items. */ taxRate?: number; /** * Total tax amount. */ taxAmount?: number; /** * Total discount amount (e.g. from a coupon). */ discountAmount?: number; /** * Final amount: `subtotal + taxAmount - discountAmount`. */ total?: number; /** * When this invoice is a credit note, the ID of the invoice it credits. */ creditNoteOfId?: string | null; gatewayInvoiceId: string | null; paidAt: Date | null; dueDate: Date | null; lineItems: InvoiceLineItem[]; metadata: Record | null; createdAt: Date; updatedAt: Date; } interface InvoiceLineItem { description: string; quantity: number; unitPrice: number; amount: number; /** * Tax rate for this line item (percentage). */ taxRate?: number; /** * When true, `amount` already includes tax (tax-inclusive pricing). * Defaults to false (tax-exclusive: tax is added on top of `amount`). */ taxInclusive?: boolean; } interface CreateInvoiceInput { subscriptionId: string; amount: number; currency: string; status?: InvoiceStatus; invoiceNumber?: string; subtotal?: number; taxRate?: number; taxAmount?: number; discountAmount?: number; total?: number; creditNoteOfId?: string; gatewayInvoiceId?: string; paidAt?: Date; dueDate?: Date; lineItems?: InvoiceLineItem[]; metadata?: Record; } interface UpdateInvoiceInput { amount?: number; status?: InvoiceStatus; invoiceNumber?: string; subtotal?: number; taxRate?: number; taxAmount?: number; discountAmount?: number; total?: number; creditNoteOfId?: string; gatewayInvoiceId?: string; paidAt?: Date | null; dueDate?: Date | null; lineItems?: InvoiceLineItem[]; metadata?: Record; } /** * Invoice with full subscription and plan details for rendering */ interface InvoiceWithDetails extends Invoice { subscription: Subscription; plan: Plan; } interface SubscriptionsLogger { debug?(message: string, ...args: unknown[]): void; info?(message: string, ...args: unknown[]): void; warn?(message: string, ...args: unknown[]): void; error?(message: string, ...args: unknown[]): void; } /** No-op logger that silently discards all messages */ declare const noopLogger: SubscriptionsLogger; interface SubscriptionsOptions { /** * Default subscriber type for new subscriptions * @default 'tenant' */ subscriberType?: SubscriberType; /** * Default trial period in days * @default 0 */ trialDays?: number; /** * Grace period in days after subscription expires before access is revoked * @default 0 */ gracePeriodDays?: number; /** * Default currency for plans * @default 'USD' */ defaultCurrency?: string; /** * Cache TTL in seconds for subscription/permission lookups * @default 300 (5 minutes) */ cacheTtlSeconds?: number; /** * Optional logger. Defaults to no-op (silent). * Pass `console` for basic logging, or a structured logger. */ logger?: SubscriptionsLogger; } //#endregion export { SubscriptionsOptions as C, UsageRecord as D, UpdateSubscriptionInput as E, UsageStatus as O, SubscriptionsLogger as S, UpdatePlanInput as T, PlanPrice as _, CreateSubscriptionInput as a, SubscriptionStatus as b, FeatureType as c, Invoice as d, InvoiceLineItem as f, Plan as g, PartialFeatureValues as h, CreatePlanInput as i, noopLogger as k, FeatureValue as l, InvoiceWithDetails as m, BillingInterval as n, FeatureDefinition as o, InvoiceStatus as p, CreateInvoiceInput as r, FeatureRegistry as s, BillingConfig as t, FeatureValues as u, SubscriberType as v, UpdateInvoiceInput as w, SubscriptionWithPlan as x, Subscription as y }; //# sourceMappingURL=types-3EaBC58c.d.ts.map