UNPKG

autumn-js

Version:
890 lines (887 loc) 25.7 kB
import { O as OpenEnum, P as Plan, a as Balance } from './plan-CUExbmy9.mjs'; /** * The environment this customer was created in. */ declare const CustomerEnv: { readonly Sandbox: "sandbox"; readonly Live: "live"; }; /** * The environment this customer was created in. */ type CustomerEnv = OpenEnum<typeof CustomerEnv>; /** * The time interval for the purchase limit window. */ declare const CustomerPurchaseLimitInterval2: { readonly Hour: "hour"; readonly Day: "day"; readonly Week: "week"; readonly Month: "month"; }; /** * The time interval for the purchase limit window. */ type CustomerPurchaseLimitInterval2 = OpenEnum<typeof CustomerPurchaseLimitInterval2>; type CustomerPurchaseLimit2 = { /** * The time interval for the purchase limit window. */ interval: CustomerPurchaseLimitInterval2; /** * Number of intervals in the purchase limit window. */ intervalCount: number; /** * Maximum number of auto top-ups allowed within the interval. */ limit: number; }; declare const CustomerPurchaseLimitInterval1: { readonly Hour: "hour"; readonly Day: "day"; readonly Week: "week"; readonly Month: "month"; }; type CustomerPurchaseLimitInterval1 = OpenEnum<typeof CustomerPurchaseLimitInterval1>; type CustomerPurchaseLimit1 = { /** * The time interval for the purchase limit window. Null when no purchase limit is configured. */ interval: CustomerPurchaseLimitInterval1 | null; /** * Number of intervals in the purchase limit window. Null when no purchase limit is configured. */ intervalCount: number | null; /** * Maximum number of auto top-ups allowed within the interval. Null when no purchase limit is configured. */ limit: number | null; /** * Number of auto top-ups already consumed in the current window. */ count: number; /** * Unix ms timestamp when the current purchase window ends and the count resets. */ nextResetAt: number; }; /** * Response-only: whether the entry is a customer-level override or inherited from an attached plan's defaults. */ declare const AutoTopupSource: { readonly Customer: "customer"; readonly Plan: "plan"; }; /** * Response-only: whether the entry is a customer-level override or inherited from an attached plan's defaults. */ type AutoTopupSource = OpenEnum<typeof AutoTopupSource>; type CustomerAutoTopup = { /** * The ID of the feature (credit balance) to auto top-up. */ featureId: string; /** * Whether auto top-up is enabled. */ enabled: boolean; /** * When the balance drops below this threshold, an auto top-up will be purchased. */ threshold: number; /** * Amount of credits to add per auto top-up. */ quantity: number; /** * Optional rate limit to cap how often auto top-ups occur. Expand billing_controls.auto_topups.purchase_limit for a count of top ups and the next_reset_at. */ purchaseLimit?: CustomerPurchaseLimit1 | CustomerPurchaseLimit2 | undefined; /** * When true, auto top-up creates a send_invoice invoice instead of auto-charging. */ invoiceMode?: boolean | undefined; /** * Response-only: whether the entry is a customer-level override or inherited from an attached plan's defaults. */ source?: AutoTopupSource | undefined; }; /** * How overage_limit is interpreted: an absolute overage cap (default) or a percentage of the main-plan allowance. */ declare const CustomerLimitType: { readonly Absolute: "absolute"; readonly UsagePercentage: "usage_percentage"; }; /** * How overage_limit is interpreted: an absolute overage cap (default) or a percentage of the main-plan allowance. */ type CustomerLimitType = OpenEnum<typeof CustomerLimitType>; /** * Response-only: whether the entry is a customer-level override or inherited from an attached plan's defaults. */ declare const SpendLimitSource: { readonly Customer: "customer"; readonly Plan: "plan"; }; /** * Response-only: whether the entry is a customer-level override or inherited from an attached plan's defaults. */ type SpendLimitSource = OpenEnum<typeof SpendLimitSource>; type CustomerSpendLimit = { /** * Optional feature ID this spend limit applies to. */ featureId?: string | undefined; /** * Whether the overage spend limit is enabled. */ enabled: boolean; /** * How overage_limit is interpreted: an absolute overage cap (default) or a percentage of the main-plan allowance. */ limitType?: CustomerLimitType | undefined; /** * Overage cap for the feature: absolute units, or a percent (e.g. 120) when limit_type is usage_percentage. */ overageLimit?: number | undefined; /** * When true, overage for this feature is not posted to Stripe. Usage tracking and balance resets still behave normally. */ skipOverageBilling?: boolean | undefined; /** * Response-only: whether the entry is a customer-level override or inherited from an attached plan's defaults. */ source?: SpendLimitSource | undefined; }; /** * Interval for the cap, aligned to the customer's billing cycle. */ declare const CustomerUsageLimitInterval: { readonly Day: "day"; readonly Week: "week"; readonly Month: "month"; readonly Year: "year"; }; /** * Interval for the cap, aligned to the customer's billing cycle. */ type CustomerUsageLimitInterval = OpenEnum<typeof CustomerUsageLimitInterval>; /** * When set, only usage from events whose properties match counts toward this cap. Omit to count all usage of the feature. */ type CustomerFilter = { properties: { [k: string]: any; }; }; /** * Response-only: whether the entry is a customer-level override or inherited from an attached plan's defaults. */ declare const UsageLimitSource: { readonly Customer: "customer"; readonly Plan: "plan"; }; /** * Response-only: whether the entry is a customer-level override or inherited from an attached plan's defaults. */ type UsageLimitSource = OpenEnum<typeof UsageLimitSource>; type CustomerUsageLimit = { /** * The feature this usage limit applies to. */ featureId: string; /** * Whether this usage limit is enabled. */ enabled: boolean; /** * Maximum units allowed per interval. */ limit: number; /** * Interval for the cap, aligned to the customer's billing cycle. */ interval: CustomerUsageLimitInterval; /** * When set, only usage from events whose properties match counts toward this cap. Omit to count all usage of the feature. */ filter?: CustomerFilter | undefined; /** * Current usage already consumed in the active interval. Response-only; not stored on billing controls. */ usage?: number | undefined; /** * Response-only: whether the entry is a customer-level override or inherited from an attached plan's defaults. */ source?: UsageLimitSource | undefined; }; /** * Whether the threshold is an absolute count or a percentage of the usage allowance or remaining balance. */ declare const CustomerThresholdType: { readonly Usage: "usage"; readonly UsagePercentage: "usage_percentage"; readonly Remaining: "remaining"; readonly RemainingPercentage: "remaining_percentage"; }; /** * Whether the threshold is an absolute count or a percentage of the usage allowance or remaining balance. */ type CustomerThresholdType = OpenEnum<typeof CustomerThresholdType>; /** * Response-only: whether the entry is a customer-level override or inherited from an attached plan's defaults. */ declare const UsageAlertSource: { readonly Customer: "customer"; readonly Plan: "plan"; }; /** * Response-only: whether the entry is a customer-level override or inherited from an attached plan's defaults. */ type UsageAlertSource = OpenEnum<typeof UsageAlertSource>; type CustomerUsageAlert = { /** * The feature ID this alert applies to. */ featureId?: string | undefined; /** * Whether this usage alert is enabled. */ enabled: boolean; /** * The threshold value that triggers the alert. For usage or remaining, this is an absolute count. For usage_percentage or remaining_percentage, this is a percentage (0-100). */ threshold: number; /** * Whether the threshold is an absolute count or a percentage of the usage allowance or remaining balance. */ thresholdType: CustomerThresholdType; /** * Optional user-defined label to distinguish multiple alerts on the same feature. */ name?: string | undefined; /** * Response-only: whether the entry is a customer-level override or inherited from an attached plan's defaults. */ source?: UsageAlertSource | undefined; }; /** * Response-only: whether the entry is a customer-level override or inherited from an attached plan's defaults. */ declare const OverageAllowedSource: { readonly Customer: "customer"; readonly Plan: "plan"; }; /** * Response-only: whether the entry is a customer-level override or inherited from an attached plan's defaults. */ type OverageAllowedSource = OpenEnum<typeof OverageAllowedSource>; type CustomerOverageAllowed = { /** * The feature ID this overage allowed control applies to. */ featureId: string; /** * Whether overage is allowed for this feature. */ enabled: boolean; /** * Response-only: whether the entry is a customer-level override or inherited from an attached plan's defaults. */ source?: OverageAllowedSource | undefined; }; /** * Billing controls for the customer (auto top-ups, etc.) */ type CustomerBillingControls = { /** * List of auto top-up configurations per feature. */ autoTopups?: Array<CustomerAutoTopup> | undefined; /** * List of overage spend limits per feature (caps overage spend). */ spendLimits?: Array<CustomerSpendLimit> | undefined; /** * List of hard usage caps per feature, with current interval usage. */ usageLimits?: Array<CustomerUsageLimit> | undefined; /** * List of usage alert configurations per feature. */ usageAlerts?: Array<CustomerUsageAlert> | undefined; /** * List of overage allowed controls per feature. When enabled, usage can exceed balance. */ overageAllowed?: Array<CustomerOverageAllowed> | undefined; }; /** * Current status of the subscription. */ declare const CustomerStatus: { readonly Active: "active"; readonly Scheduled: "scheduled"; }; /** * Current status of the subscription. */ type CustomerStatus = OpenEnum<typeof CustomerStatus>; /** * Whether this subscription is attached at the customer level or entity level. */ declare const SubscriptionScope: { readonly Customer: "customer"; readonly Entity: "entity"; }; /** * Whether this subscription is attached at the customer level or entity level. */ type SubscriptionScope = OpenEnum<typeof SubscriptionScope>; type Subscription = { /** * The unique identifier of this subscription. If a subscription_id was provided at attach time, it is used; otherwise, falls back to the internal ID. */ id: string; plan?: Plan | undefined; /** * The unique identifier of the subscribed plan. */ planId: string; /** * Whether the plan was automatically enabled for the customer. */ autoEnable: boolean; /** * Whether this is an add-on plan rather than a base subscription. */ addOn: boolean; /** * Current status of the subscription. */ status: CustomerStatus; /** * Whether the subscription has overdue payments. */ pastDue: boolean; /** * Timestamp when the subscription was canceled, or null if not canceled. */ canceledAt: number | null; /** * Timestamp when the subscription will expire, or null if no expiry set. */ expiresAt: number | null; /** * Timestamp when the trial period ends, or null if not on trial. */ trialEndsAt: number | null; /** * Timestamp when the subscription started. */ startedAt: number; /** * Start timestamp of the current billing period. */ currentPeriodStart: number | null; /** * End timestamp of the current billing period. */ currentPeriodEnd: number | null; /** * Number of units of this subscription (for per-seat plans). */ quantity: number; /** * Whether this subscription is attached at the customer level or entity level. */ scope?: SubscriptionScope | undefined; }; /** * Whether this purchase is attached at the customer level or entity level. */ declare const PurchaseScope: { readonly Customer: "customer"; readonly Entity: "entity"; }; /** * Whether this purchase is attached at the customer level or entity level. */ type PurchaseScope = OpenEnum<typeof PurchaseScope>; type Purchase = { plan?: Plan | undefined; /** * The unique identifier of the purchased plan. */ planId: string; /** * Timestamp when the purchase expires, or null for lifetime access. */ expiresAt: number | null; /** * Timestamp when the purchase was made. */ startedAt: number; /** * Number of units purchased. */ quantity: number; /** * Whether this purchase is attached at the customer level or entity level. */ scope?: PurchaseScope | undefined; }; /** * Feature type: 'boolean' for on/off access, 'metered' for usage-tracked features, 'credit_system' for unified credit pools, 'ai_credit_system' for model-based token pricing. */ declare const CustomerFlagsType: { readonly Boolean: "boolean"; readonly Metered: "metered"; readonly CreditSystem: "credit_system"; readonly AiCreditSystem: "ai_credit_system"; }; /** * Feature type: 'boolean' for on/off access, 'metered' for usage-tracked features, 'credit_system' for unified credit pools, 'ai_credit_system' for model-based token pricing. */ type CustomerFlagsType = OpenEnum<typeof CustomerFlagsType>; type CustomerCreditSchema = { /** * ID of the metered feature that draws from this credit system. */ meteredFeatureId: string; /** * Credits consumed per unit of the metered feature. */ creditCost: number; }; type CustomerModelMarkups = { markup?: number | undefined; inputCost?: number | undefined; outputCost?: number | undefined; }; type CustomerProviderMarkups = { markup: number; }; /** * Display names for the feature in billing UI and customer-facing components. */ type CustomerDisplay = { /** * Singular form for UI display (e.g., 'API call', 'seat'). */ singular?: string | null | undefined; /** * Plural form for UI display (e.g., 'API calls', 'seats'). */ plural?: string | null | undefined; }; /** * The full feature object if expanded. */ type CustomerFeature = { /** * The unique identifier for this feature, used in /check and /track calls. */ id: string; /** * Human-readable name displayed in the dashboard and billing UI. */ name: string; /** * Feature type: 'boolean' for on/off access, 'metered' for usage-tracked features, 'credit_system' for unified credit pools, 'ai_credit_system' for model-based token pricing. */ type: CustomerFlagsType; /** * For metered features: true if usage resets periodically (API calls, credits), false if allocated persistently (seats, storage). */ consumable: boolean; /** * Event names that trigger this feature's balance. Allows multiple features to respond to a single event. */ eventNames?: Array<string> | undefined; /** * For credit_system features: maps metered features to their credit costs. */ creditSchema?: Array<CustomerCreditSchema> | undefined; /** * Per-model markup overrides for AI credit systems. */ modelMarkups?: { [k: string]: CustomerModelMarkups; } | null | undefined; /** * Default percentage markup for AI credit systems. Use -100 to make usage free. */ defaultMarkup?: number | undefined; /** * Per-provider default markup percentages for AI credit systems. */ providerMarkups?: { [k: string]: CustomerProviderMarkups; } | null | undefined; /** * Display names for the feature in billing UI and customer-facing components. */ display?: CustomerDisplay | undefined; /** * Whether the feature is archived and hidden from the dashboard. */ archived: boolean; }; type Flags = { /** * The unique identifier for this flag. */ id: string; /** * The plan ID this flag originates from, or null for standalone flags. */ planId: string | null; /** * Timestamp when this flag expires, or null for no expiration. */ expiresAt: number | null; /** * The feature ID this flag is for. */ featureId: string; /** * The full feature object if expanded. */ feature?: CustomerFeature | undefined; }; /** * Configuration for the customer. */ type CustomerConfig = { /** * Whether to disable the shared customer-level pool for entities. */ disablePooledBalance?: boolean | undefined; /** * Stops Autumn from posting usage-overage line items to Stripe for this customer. Check/track and balance resets still behave normally. When set, this overrides the organization-level disable_overage_billing setting. */ disableOverageBilling?: boolean | undefined; }; /** * Stripe processor connection for the customer. */ type Stripe = { /** * Stripe customer ID. */ id: string; }; /** * Vercel processor connection for the customer (public-safe subset). */ type Vercel = { /** * Vercel marketplace installation ID for this customer. */ installationId: string; /** * Vercel account ID associated with the installation. */ accountId: string; }; /** * RevenueCat processor connection for the customer. */ type Revenuecat = { /** * Customer's external ID, used as the RevenueCat app user ID. Null if the customer has no external ID set. */ id: string | null; }; /** * Payment processors this customer is connected to (Stripe, Vercel, RevenueCat). Omitted entirely when the customer has not been created in any processor. */ type Processors = { /** * Stripe processor connection for the customer. */ stripe?: Stripe | undefined; /** * Vercel processor connection for the customer (public-safe subset). */ vercel?: Vercel | undefined; /** * RevenueCat processor connection for the customer. */ revenuecat?: Revenuecat | undefined; }; /** * The billing processor that owns this invoice. */ declare const ProcessorType: { readonly Stripe: "stripe"; readonly Revenuecat: "revenuecat"; }; /** * The billing processor that owns this invoice. */ type ProcessorType = OpenEnum<typeof ProcessorType>; type Invoice = { /** * Array of plan IDs included in this invoice */ planIds: Array<string>; /** * The Stripe invoice ID */ stripeId: string; /** * The billing processor that owns this invoice. */ processorType: ProcessorType; /** * The status of the invoice */ status: string; /** * The total amount of the invoice */ total: number; /** * The currency code for the invoice */ currency: string; /** * Timestamp when the invoice was created */ createdAt: number; /** * URL to the Stripe-hosted invoice page */ hostedInvoiceUrl?: string | null | undefined; }; /** * The environment (sandbox/live) */ declare const CustomerEntityEnv: { readonly Sandbox: "sandbox"; readonly Live: "live"; }; /** * The environment (sandbox/live) */ type CustomerEntityEnv = OpenEnum<typeof CustomerEntityEnv>; type Entity = { /** * The unique identifier of the entity */ id: string | null; /** * The name of the entity */ name: string | null; /** * The customer ID this entity belongs to */ customerId?: string | null | undefined; /** * The feature ID this entity belongs to */ featureId?: string | null | undefined; /** * Unix timestamp when the entity was created */ createdAt: number; /** * The environment (sandbox/live) */ env: CustomerEntityEnv; }; type TrialsUsed = { planId: string; customerId: string; fingerprint?: string | null | undefined; }; /** * The type of reward */ declare const CustomerDiscountType: { readonly PercentageDiscount: "percentage_discount"; readonly FixedDiscount: "fixed_discount"; readonly FreeProduct: "free_product"; readonly InvoiceCredits: "invoice_credits"; readonly FeatureGrant: "feature_grant"; }; /** * The type of reward */ type CustomerDiscountType = OpenEnum<typeof CustomerDiscountType>; /** * How long the discount lasts */ declare const CustomerDurationType: { readonly OneOff: "one_off"; readonly Months: "months"; readonly Forever: "forever"; }; /** * How long the discount lasts */ type CustomerDurationType = OpenEnum<typeof CustomerDurationType>; type Discount = { /** * The unique identifier for this discount */ id: string; /** * The name of the discount or coupon */ name: string; /** * The type of reward */ type: CustomerDiscountType; /** * The discount value (percentage or fixed amount) */ discountValue: number; /** * How long the discount lasts */ durationType: CustomerDurationType; /** * Number of billing periods the discount applies for repeating durations */ durationValue?: number | null | undefined; /** * The currency code for fixed amount discounts */ currency?: string | null | undefined; /** * Timestamp when the discount becomes active */ start?: number | null | undefined; /** * Timestamp when the discount expires */ end?: number | null | undefined; /** * The Stripe subscription ID this discount is applied to */ subscriptionId?: string | null | undefined; /** * Total amount saved from this discount */ totalDiscountAmount?: number | null | undefined; }; type Rewards = { /** * Array of active discounts applied to the customer */ discounts: Array<Discount>; }; type ReferralCustomer = { id: string; name?: string | null | undefined; email?: string | null | undefined; }; type Referral = { programId: string; customer: ReferralCustomer; rewardApplied: boolean; createdAt: number; }; type Customer = { /** * Your unique identifier for the customer. */ id: string | null; /** * The name of the customer. */ name: string | null; /** * The email address of the customer. */ email: string | null; /** * Timestamp of customer creation in milliseconds since epoch. */ createdAt: number; /** * A unique identifier (eg. serial number) to de-duplicate customers across devices or browsers. For example: apple device ID. */ fingerprint: string | null; /** * Stripe customer ID. */ stripeId: string | null; /** * The environment this customer was created in. */ env: CustomerEnv; /** * The metadata for the customer. */ metadata: { [k: string]: any; }; /** * Whether to send email receipts to the customer. */ sendEmailReceipts: boolean; /** * Billing controls for the customer (auto top-ups, etc.) */ billingControls: CustomerBillingControls; /** * Active and scheduled recurring plans that this customer has attached. */ subscriptions: Array<Subscription>; /** * One-time purchases made by the customer. */ purchases: Array<Purchase>; /** * Feature balances keyed by feature ID, showing usage limits and remaining amounts. */ balances: { [k: string]: Balance; }; /** * Boolean feature flags keyed by feature ID, showing enabled access for on/off features. */ flags: { [k: string]: Flags; }; /** * Configuration for the customer. */ config?: CustomerConfig | undefined; /** * Payment processors this customer is connected to (Stripe, Vercel, RevenueCat). Omitted entirely when the customer has not been created in any processor. */ processors?: Processors | undefined; /** * Invoices for this customer. */ invoices?: Array<Invoice> | undefined; /** * Entities associated with this customer. */ entities?: Array<Entity> | undefined; /** * Trial usage history for this customer. */ trialsUsed?: Array<TrialsUsed> | undefined; /** * Rewards earned or applied for this customer. */ rewards?: Rewards | null | undefined; /** * Referral records for this customer. */ referrals?: Array<Referral> | undefined; /** * The customer's default payment method. */ paymentMethod?: any | null | undefined; }; export type { Customer as C };