UNPKG

alepha

Version:

Easy-to-use modern TypeScript framework for building many kind of applications.

1,153 lines 86.6 kB
import { Alepha, Middleware, Static, TNull, TObject, TOptional, TSchema, TUnion } from "alepha"; import { Page } from "alepha/orm"; import { DateTimeProvider } from "alepha/datetime"; import { PaymentService } from "alepha/api/payments"; import { CacheProvider } from "alepha/cache"; import { BuildExtraConfigColumns, SQL } from "drizzle-orm"; import { PgColumnBuilderBase, PgSequenceOptions, PgTableExtraConfigValue, UpdateDeleteAction } from "drizzle-orm/pg-core"; import "drizzle-orm/pg-core/foreign-keys"; import "drizzle-orm/pg-core/session"; import "alepha/crypto"; import "drizzle-kit/api"; import "drizzle-orm/d1"; import "drizzle-orm/sqlite-core"; //#region ../../src/orm/core/schemas/insertSchema.d.ts /** * Transforms a TObject schema for insert operations. * All default properties at the root level are made optional. * Generated columns are excluded entirely. * * @example * Before: { name: string; age: number(default=0); fullName: generated } * After: { name: string; age?: number; } */ type TObjectInsert<T extends TObject> = TObject<{ [K in keyof T["shape"] as T["shape"][K] extends { [PG_GENERATED]: any; } ? never : K]: T["shape"][K] extends { [PG_DEFAULT]: any; } | { [PG_ORGANIZATION]: any; } ? TOptional<Extract<T["shape"][K], TSchema>> : T["shape"][K]; }>; //#endregion //#region ../../src/orm/core/schemas/updateSchema.d.ts /** * Transforms a TObject schema for update operations. * All optional properties at the root level are made nullable (i.e., `T | null`). * Generated columns are excluded entirely. * * @example * Before: { name?: string; age: number; fullName: generated } * After: { name?: string | null; age: number; } */ type TObjectUpdate<T extends TObject> = TObject<{ [K in keyof T["shape"] as T["shape"][K] extends { [PG_GENERATED]: any; } ? never : K]: T["shape"][K] extends TOptional<infer U extends TSchema> ? TOptional<TUnion<[U, TNull]>> : T["shape"][K]; }>; //#endregion //#region ../../src/orm/core/primitives/$entity.d.ts interface EntityPrimitiveOptions<T extends TObject, Keys = keyof Static<T>> { /** * The database table name that will be created for this entity. * If not provided, name will be inferred from the $repository variable name. */ name: string; /** * TypeBox schema defining the table structure and column types. */ schema: T; /** * Database indexes to create for query optimization. */ indexes?: (Keys | { /** * Single column to index. */ column: Keys; /** * Whether this should be a unique index (enforces uniqueness constraint). */ unique?: boolean; /** * Custom name for the index. If not provided, generates name automatically. */ name?: string; /** * Partial index condition. Only rows matching this SQL expression are indexed. */ where?: SQL; } | { /** * Multiple columns for composite index (order matters for query optimization). */ columns: Keys[]; /** * Whether this should be a unique index (enforces uniqueness constraint). */ unique?: boolean; /** * Custom name for the index. If not provided, generates name automatically. */ name?: string; /** * Partial index condition. Only rows matching this SQL expression are indexed. */ where?: SQL; } | { /** * SQL expressions for expression-based indexes. * * Can include column references and SQL functions like `LOWER()`, `UPPER()`, etc. * Columns and expressions can be mixed together. * * @example * ```ts * // Case-insensitive unique username per realm * indexes: [{ * expressions: (self) => [self.realm, sql`LOWER(${self.username})`], * unique: true, * name: "users_realm_username_lower_idx", * }] * ``` */ expressions: (self: Record<Keys & string, any>) => (SQL | any)[]; /** * Whether this should be a unique index (enforces uniqueness constraint). */ unique?: boolean; /** * Custom name for the index. If not provided, generates name automatically. */ name: string; /** * Partial index condition. Only rows matching this SQL expression are indexed. */ where?: SQL; })[]; /** * Foreign key constraints to maintain referential integrity. */ foreignKeys?: Array<{ /** * Optional name for the foreign key constraint. */ name?: string; /** * Local columns that reference the foreign table. */ columns: Array<keyof Static<T>>; /** * Referenced columns in the foreign table. * Must be EntityColumn references from other entities. */ foreignColumns: Array<() => EntityColumn<any>>; }>; /** * Additional table constraints for data validation. * * Constraints enforce business rules at the database level, providing * an additional layer of data integrity beyond application validation. * * **Constraint Types**: * - **Unique constraints**: Prevent duplicate values across columns * - **Check constraints**: Enforce custom validation rules with SQL expressions * * @example * ```ts * constraints: [ * { * name: "unique_user_email", * columns: ["email"], * unique: true * }, * { * name: "valid_age_range", * columns: ["age"], * check: sql`age >= 0 AND age <= 150` * }, * { * name: "unique_user_username_per_tenant", * columns: ["tenantId", "username"], * unique: true * } * ] * ``` */ constraints?: Array<{ /** * Columns involved in this constraint. */ columns: Array<keyof Static<T>>; /** * Optional name for the constraint. */ name?: string; /** * Whether this is a unique constraint. */ unique?: boolean | {}; /** * SQL expression for check constraint validation. */ check?: SQL; }>; /** * Advanced Drizzle ORM configuration for complex table setups. */ config?: (self: BuildExtraConfigColumns<string, FromSchema<T>, "pg">) => PgTableExtraConfigValue[]; } declare class EntityPrimitive<T extends TObject = TObject> { readonly options: EntityPrimitiveOptions<T>; constructor(options: EntityPrimitiveOptions<T>); alias(alias: string): this; get cols(): EntityColumns<T>; get name(): string; get schema(): T; protected _insertSchema?: TObjectInsert<T>; get insertSchema(): TObjectInsert<T>; protected _updateSchema?: TObjectUpdate<T>; get updateSchema(): TObjectUpdate<T>; } /** * Convert a schema to columns. */ type FromSchema<T extends TObject> = { [key in keyof T["properties"]]: PgColumnBuilderBase; }; type EntityColumn<T extends TObject> = { name: string; entity: EntityPrimitive<T>; }; type EntityColumns<T extends TObject> = { [key in keyof T["properties"]]: EntityColumn<T>; }; //#endregion //#region ../../src/orm/core/constants/PG_SYMBOLS.d.ts declare const PG_DEFAULT: unique symbol; declare const PG_PRIMARY_KEY: unique symbol; declare const PG_CREATED_AT: unique symbol; declare const PG_UPDATED_AT: unique symbol; declare const PG_DELETED_AT: unique symbol; declare const PG_VERSION: unique symbol; declare const PG_IDENTITY: unique symbol; declare const PG_ENUM: unique symbol; declare const PG_REF: unique symbol; declare const PG_GENERATED: unique symbol; declare const PG_ORGANIZATION: unique symbol; /** * @deprecated Use `PG_IDENTITY` instead. */ declare const PG_SERIAL: unique symbol; type PgSymbols = { [PG_DEFAULT]: {}; [PG_PRIMARY_KEY]: {}; [PG_CREATED_AT]: {}; [PG_UPDATED_AT]: {}; [PG_DELETED_AT]: {}; [PG_VERSION]: {}; [PG_IDENTITY]: PgIdentityOptions; [PG_REF]: PgRefOptions; [PG_ENUM]: PgEnumOptions; [PG_GENERATED]: PgGeneratedOptions; [PG_ORGANIZATION]: PgOrganizationOptions; /** * @deprecated Use `PG_IDENTITY` instead. */ [PG_SERIAL]: {}; }; type PgSymbolKeys = keyof PgSymbols; interface PgOrganizationOptions { /** * Fail-closed tenant scoping. When `true`, the repository (a) refuses any * read/write with no resolved tenant instead of falling through to an * unfiltered "see/write everything" query, and (b) drops the * `OR organizationId IS NULL` "global row" escape — a scoped tenant never * sees NULL/global rows. Use for security-sensitive tables. Defaults to * `false` (the historic fail-open semantics). */ strict?: boolean; } type PgIdentityOptions = { mode: "always" | "byDefault"; } & PgSequenceOptions & { name?: string; }; interface PgEnumOptions { name?: string; description?: string; } interface PgGeneratedOptions { /** * SQL expression for the generated column. */ expression: SQL; /** * Storage mode for the generated column. * - `"stored"` — value is computed on write and stored on disk (default for PostgreSQL). * - `"virtual"` — value is computed on read (default for SQLite). */ mode?: "stored" | "virtual"; } interface PgRefOptions { ref: () => { name: string; entity: EntityPrimitive; }; actions?: { onUpdate?: UpdateDeleteAction; onDelete?: UpdateDeleteAction; }; } //#endregion //#region ../../src/orm/core/helpers/pgAttr.d.ts /** * Type representation. */ type PgAttr<T extends TSchema, TAttr extends PgSymbolKeys> = T & { [K in TAttr]: PgSymbols[K]; }; //#endregion //#region ../../src/orm/core/schemas/databaseEnvSchema.d.ts /** * Base database environment schema. * * Defines the `DATABASE_URL` connection string used by all ORM providers * to determine the database driver and connection target. * * Supported URL formats: * - `sqlite://:memory:` or `sqlite://./path/to/db` — SQLite (Node.js or Bun) * - `postgres://user:password@host:port/database` — PostgreSQL (Node.js or Bun) * - `pglite://:memory:` or `pglite://./path` — PGlite (embedded Postgres) * - `d1://BINDING_NAME` — Cloudflare D1 * - `hyperdrive://BINDING_NAME` — Cloudflare Hyperdrive */ declare const databaseEnvSchema: import("zod").ZodObject<{ DATABASE_URL: import("zod").ZodOptional<import("zod").ZodString>; DATABASE_SYNC: import("zod").ZodOptional<import("zod").ZodBoolean>; }, import("zod/v4/core").$strip>; declare module "alepha" { interface Env extends Partial<Static<typeof databaseEnvSchema>> {} } //#endregion //#region ../../src/api/subscriptions/schemas/planDefinitionSchema.d.ts declare const planDefinitionSchema: import("zod").ZodObject<{ id: import("zod").ZodString; name: import("zod").ZodString; description: import("zod").ZodOptional<import("zod").ZodString>; available: import("zod").ZodDefault<import("zod").ZodBoolean>; pricing: import("zod").ZodArray<import("zod").ZodObject<{ interval: import("zod").ZodEnum<{ monthly: "monthly"; yearly: "yearly"; }>; amount: import("zod").ZodInt; currency: import("zod").ZodString; }, import("zod/v4/core").$strip>>; trial: import("zod").ZodOptional<import("zod").ZodObject<{ days: import("zod").ZodInt; requirePaymentMethod: import("zod").ZodDefault<import("zod").ZodBoolean>; }, import("zod/v4/core").$strip>>; features: import("zod").ZodArray<import("zod").ZodString>; limits: import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodInt>; order: import("zod").ZodDefault<import("zod").ZodInt>; metadata: import("zod").ZodOptional<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodAny>>; }, import("zod/v4/core").$strip>; type PlanDefinition = Static<typeof planDefinitionSchema>; //#endregion //#region ../../src/api/subscriptions/schemas/subscriptionSettingsSchema.d.ts declare const subscriptionSettingsSchema: import("zod").ZodObject<{ trialDays: import("zod").ZodDefault<import("zod").ZodInt>; gracePeriodDays: import("zod").ZodDefault<import("zod").ZodInt>; dunningSchedule: import("zod").ZodArray<import("zod").ZodInt>; cancelAtPeriodEnd: import("zod").ZodDefault<import("zod").ZodBoolean>; prorateOnChange: import("zod").ZodDefault<import("zod").ZodBoolean>; }, import("zod/v4/core").$strip>; type SubscriptionSettings = Static<typeof subscriptionSettingsSchema>; //#endregion //#region ../../src/api/subscriptions/services/SubscriptionConfig.d.ts declare class SubscriptionConfig { protected readonly plans: import("alepha/api/parameters").ParameterPrimitive<import("zod").ZodObject<{ plans: import("zod").ZodArray<import("zod").ZodObject<{ id: import("zod").ZodString; name: import("zod").ZodString; description: import("zod").ZodOptional<import("zod").ZodString>; available: import("zod").ZodDefault<import("zod").ZodBoolean>; pricing: import("zod").ZodArray<import("zod").ZodObject<{ interval: import("zod").ZodEnum<{ monthly: "monthly"; yearly: "yearly"; }>; amount: import("zod").ZodInt; currency: import("zod").ZodString; }, import("zod/v4/core").$strip>>; trial: import("zod").ZodOptional<import("zod").ZodObject<{ days: import("zod").ZodInt; requirePaymentMethod: import("zod").ZodDefault<import("zod").ZodBoolean>; }, import("zod/v4/core").$strip>>; features: import("zod").ZodArray<import("zod").ZodString>; limits: import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodInt>; order: import("zod").ZodDefault<import("zod").ZodInt>; metadata: import("zod").ZodOptional<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodAny>>; }, import("zod/v4/core").$strip>>; }, import("zod/v4/core").$strip>>; protected readonly settings: import("alepha/api/parameters").ParameterPrimitive<import("zod").ZodObject<{ trialDays: import("zod").ZodDefault<import("zod").ZodInt>; gracePeriodDays: import("zod").ZodDefault<import("zod").ZodInt>; dunningSchedule: import("zod").ZodArray<import("zod").ZodInt>; cancelAtPeriodEnd: import("zod").ZodDefault<import("zod").ZodBoolean>; prorateOnChange: import("zod").ZodDefault<import("zod").ZodBoolean>; }, import("zod/v4/core").$strip>>; getPlans(): Promise<PlanDefinition[]>; getSettings(): Promise<SubscriptionSettings>; getPlan(planId: string): Promise<PlanDefinition>; getPlanPricing(planId: string, interval: "monthly" | "yearly"): Promise<{ interval: "monthly" | "yearly"; amount: number; currency: string; }>; } //#endregion //#region ../../src/api/subscriptions/entities/subscriptionEvents.d.ts declare const subscriptionEvents: import("alepha/orm").EntityPrimitive<import("zod").ZodObject<{ id: import("alepha/orm").PgAttr<import("alepha/orm").PgAttr<import("zod").ZodString, typeof import("alepha/orm").PG_PRIMARY_KEY>, typeof import("alepha/orm").PG_DEFAULT>; createdAt: import("alepha/orm").PgAttr<import("alepha/orm").PgAttr<import("zod").ZodString, typeof import("alepha/orm").PG_CREATED_AT>, typeof import("alepha/orm").PG_DEFAULT>; subscriptionId: import("alepha/orm").PgAttr<import("zod").ZodString, typeof import("alepha/orm").PG_REF>; organizationId: import("alepha/orm").PgAttr<import("zod").ZodOptional<import("zod").ZodString> | import("zod").ZodString, typeof import("alepha/orm").PG_ORGANIZATION>; type: import("zod").ZodEnum<{ activated: "activated"; cancelled: "cancelled"; created: "created"; expired: "expired"; past_due: "past_due"; payment_failed: "payment_failed"; payment_retried: "payment_retried"; plan_change_scheduled: "plan_change_scheduled"; plan_changed: "plan_changed"; reactivated: "reactivated"; renewed: "renewed"; resumed: "resumed"; suspended: "suspended"; trial_ended: "trial_ended"; trial_started: "trial_started"; }>; previousStatus: import("zod").ZodOptional<import("zod").ZodString>; newStatus: import("zod").ZodOptional<import("zod").ZodString>; previousPlanId: import("zod").ZodOptional<import("zod").ZodString>; newPlanId: import("zod").ZodOptional<import("zod").ZodString>; paymentIntentId: import("zod").ZodOptional<import("zod").ZodString>; amount: import("zod").ZodOptional<import("zod").ZodInt>; currency: import("zod").ZodOptional<import("zod").ZodString>; triggeredBy: import("zod").ZodOptional<import("zod").ZodString>; userId: import("zod").ZodOptional<import("zod").ZodString>; note: import("zod").ZodOptional<import("zod").ZodString>; }, import("zod/v4/core").$strip>>; type SubscriptionEventEntity = Static<typeof subscriptionEvents.schema>; //#endregion //#region ../../src/api/subscriptions/entities/subscriptions.d.ts declare const subscriptions: import("alepha/orm").EntityPrimitive<import("zod").ZodObject<{ id: import("alepha/orm").PgAttr<import("alepha/orm").PgAttr<import("zod").ZodString, typeof import("alepha/orm").PG_PRIMARY_KEY>, typeof import("alepha/orm").PG_DEFAULT>; version: import("alepha/orm").PgAttr<import("alepha/orm").PgAttr<import("zod").ZodInt, typeof import("alepha/orm").PG_VERSION>, typeof import("alepha/orm").PG_DEFAULT>; createdAt: import("alepha/orm").PgAttr<import("alepha/orm").PgAttr<import("zod").ZodString, typeof import("alepha/orm").PG_CREATED_AT>, typeof import("alepha/orm").PG_DEFAULT>; updatedAt: import("alepha/orm").PgAttr<import("alepha/orm").PgAttr<import("zod").ZodString, typeof import("alepha/orm").PG_UPDATED_AT>, typeof import("alepha/orm").PG_DEFAULT>; organizationId: import("alepha/orm").PgAttr<import("zod").ZodOptional<import("zod").ZodString> | import("zod").ZodString, typeof import("alepha/orm").PG_ORGANIZATION>; planId: import("zod").ZodString; interval: import("zod").ZodEnum<{ monthly: "monthly"; yearly: "yearly"; }>; status: import("zod").ZodEnum<{ active: "active"; cancelled: "cancelled"; expired: "expired"; past_due: "past_due"; suspended: "suspended"; trialing: "trialing"; }>; currentPeriodStart: import("zod").ZodString; currentPeriodEnd: import("zod").ZodString; trialStart: import("zod").ZodOptional<import("zod").ZodString>; trialEnd: import("zod").ZodOptional<import("zod").ZodString>; cancelledAt: import("zod").ZodOptional<import("zod").ZodString>; cancelReason: import("zod").ZodOptional<import("zod").ZodString>; cancelAtPeriodEnd: import("zod").ZodDefault<import("zod").ZodBoolean>; lastPaymentIntentId: import("zod").ZodOptional<import("zod").ZodString>; lastPaymentAt: import("zod").ZodOptional<import("zod").ZodString>; nextBillingAt: import("zod").ZodOptional<import("zod").ZodString>; dunningStartedAt: import("zod").ZodOptional<import("zod").ZodString>; dunningAttempt: import("zod").ZodDefault<import("zod").ZodInt>; dunningNextRetryAt: import("zod").ZodOptional<import("zod").ZodString>; pendingPlanId: import("zod").ZodOptional<import("zod").ZodString>; pendingInterval: import("zod").ZodOptional<import("zod").ZodEnum<{ monthly: "monthly"; yearly: "yearly"; }>>; metadata: import("zod").ZodOptional<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodAny>>; }, import("zod/v4/core").$strip>>; type SubscriptionEntity = Static<typeof subscriptions.schema>; //#endregion //#region ../../src/api/subscriptions/schemas/entitlementsSchema.d.ts declare const entitlementsSchema: import("zod").ZodObject<{ planId: import("zod").ZodString; planName: import("zod").ZodString; status: import("zod").ZodEnum<{ active: "active"; cancelled: "cancelled"; expired: "expired"; past_due: "past_due"; suspended: "suspended"; trialing: "trialing"; }>; features: import("zod").ZodArray<import("zod").ZodString>; limits: import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodInt>; trialEndsAt: import("zod").ZodOptional<import("zod").ZodString>; periodEndsAt: import("zod").ZodString; cancelledAt: import("zod").ZodOptional<import("zod").ZodString>; }, import("zod/v4/core").$strip>; type Entitlements = Static<typeof entitlementsSchema>; //#endregion //#region ../../src/api/subscriptions/schemas/subscriptionQuerySchema.d.ts declare const subscriptionQuerySchema: import("zod").ZodObject<{ page: import("zod").ZodOptional<import("zod").ZodDefault<import("zod").ZodInt>>; size: import("zod").ZodOptional<import("zod").ZodDefault<import("zod").ZodInt>>; sort: import("zod").ZodOptional<import("zod").ZodString>; status: import("zod").ZodOptional<import("zod").ZodEnum<{ active: "active"; cancelled: "cancelled"; expired: "expired"; past_due: "past_due"; suspended: "suspended"; trialing: "trialing"; }>>; planId: import("zod").ZodOptional<import("zod").ZodString>; organizationId: import("zod").ZodOptional<import("zod").ZodString>; }, import("zod/v4/core").$strip>; type SubscriptionQuery = Static<typeof subscriptionQuerySchema>; //#endregion //#region ../../src/api/subscriptions/schemas/subscriptionStatsSchema.d.ts declare const subscriptionStatsSchema: import("zod").ZodObject<{ total: import("zod").ZodInt; trialing: import("zod").ZodInt; active: import("zod").ZodInt; pastDue: import("zod").ZodInt; suspended: import("zod").ZodInt; cancelled: import("zod").ZodInt; expired: import("zod").ZodInt; trialConversionRate: import("zod").ZodNumber; churnRate: import("zod").ZodNumber; byPlan: import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodObject<{ active: import("zod").ZodInt; trialing: import("zod").ZodInt; total: import("zod").ZodInt; }, import("zod/v4/core").$strip>>; }, import("zod/v4/core").$strip>; type SubscriptionStats = Static<typeof subscriptionStatsSchema>; //#endregion //#region ../../src/api/subscriptions/services/SubscriptionService.d.ts interface SubscribeOptions { /** * Override plan/global trial days. */ trialDays?: number; /** * Go straight to active (requires payment). */ skipTrial?: boolean; /** * Metadata to attach to the subscription. */ metadata?: Record<string, unknown>; } interface CancelOptions { /** * Cancellation reason. */ reason?: string; /** * Cancel immediately instead of at period end. */ immediate?: boolean; /** * User who initiated the cancellation. */ cancelledBy?: string; } interface ChangePlanOptions { /** * Apply now (with proration) or at period end. */ immediate?: boolean; /** * Override settings.prorateOnChange. */ prorate?: boolean; } interface EventContext$2 { previousStatus?: string; newStatus?: string; previousPlanId?: string; newPlanId?: string; paymentIntentId?: string; amount?: number; currency?: string; triggeredBy?: string; userId?: string; note?: string; } declare class SubscriptionService { protected readonly alepha: Alepha; protected readonly log: import("alepha/logger").Logger; protected readonly dateTime: DateTimeProvider; protected readonly subscriptionRepo: import("alepha/orm").Repository<import("zod").ZodObject<{ id: import("alepha/orm").PgAttr<import("alepha/orm").PgAttr<import("zod").ZodString, typeof import("alepha/orm").PG_PRIMARY_KEY>, typeof import("alepha/orm").PG_DEFAULT>; version: import("alepha/orm").PgAttr<import("alepha/orm").PgAttr<import("zod").ZodInt, typeof import("alepha/orm").PG_VERSION>, typeof import("alepha/orm").PG_DEFAULT>; createdAt: import("alepha/orm").PgAttr<import("alepha/orm").PgAttr<import("zod").ZodString, typeof import("alepha/orm").PG_CREATED_AT>, typeof import("alepha/orm").PG_DEFAULT>; updatedAt: import("alepha/orm").PgAttr<import("alepha/orm").PgAttr<import("zod").ZodString, typeof import("alepha/orm").PG_UPDATED_AT>, typeof import("alepha/orm").PG_DEFAULT>; organizationId: import("alepha/orm").PgAttr<import("zod").ZodOptional<import("zod").ZodString> | import("zod").ZodString, typeof import("alepha/orm").PG_ORGANIZATION>; planId: import("zod").ZodString; interval: import("zod").ZodEnum<{ monthly: "monthly"; yearly: "yearly"; }>; status: import("zod").ZodEnum<{ active: "active"; cancelled: "cancelled"; expired: "expired"; past_due: "past_due"; suspended: "suspended"; trialing: "trialing"; }>; currentPeriodStart: import("zod").ZodString; currentPeriodEnd: import("zod").ZodString; trialStart: import("zod").ZodOptional<import("zod").ZodString>; trialEnd: import("zod").ZodOptional<import("zod").ZodString>; cancelledAt: import("zod").ZodOptional<import("zod").ZodString>; cancelReason: import("zod").ZodOptional<import("zod").ZodString>; cancelAtPeriodEnd: import("zod").ZodDefault<import("zod").ZodBoolean>; lastPaymentIntentId: import("zod").ZodOptional<import("zod").ZodString>; lastPaymentAt: import("zod").ZodOptional<import("zod").ZodString>; nextBillingAt: import("zod").ZodOptional<import("zod").ZodString>; dunningStartedAt: import("zod").ZodOptional<import("zod").ZodString>; dunningAttempt: import("zod").ZodDefault<import("zod").ZodInt>; dunningNextRetryAt: import("zod").ZodOptional<import("zod").ZodString>; pendingPlanId: import("zod").ZodOptional<import("zod").ZodString>; pendingInterval: import("zod").ZodOptional<import("zod").ZodEnum<{ monthly: "monthly"; yearly: "yearly"; }>>; metadata: import("zod").ZodOptional<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodAny>>; }, import("zod/v4/core").$strip>>; protected readonly eventRepo: import("alepha/orm").Repository<import("zod").ZodObject<{ id: import("alepha/orm").PgAttr<import("alepha/orm").PgAttr<import("zod").ZodString, typeof import("alepha/orm").PG_PRIMARY_KEY>, typeof import("alepha/orm").PG_DEFAULT>; createdAt: import("alepha/orm").PgAttr<import("alepha/orm").PgAttr<import("zod").ZodString, typeof import("alepha/orm").PG_CREATED_AT>, typeof import("alepha/orm").PG_DEFAULT>; subscriptionId: import("alepha/orm").PgAttr<import("zod").ZodString, typeof import("alepha/orm").PG_REF>; organizationId: import("alepha/orm").PgAttr<import("zod").ZodOptional<import("zod").ZodString> | import("zod").ZodString, typeof import("alepha/orm").PG_ORGANIZATION>; type: import("zod").ZodEnum<{ activated: "activated"; cancelled: "cancelled"; created: "created"; expired: "expired"; past_due: "past_due"; payment_failed: "payment_failed"; payment_retried: "payment_retried"; plan_change_scheduled: "plan_change_scheduled"; plan_changed: "plan_changed"; reactivated: "reactivated"; renewed: "renewed"; resumed: "resumed"; suspended: "suspended"; trial_ended: "trial_ended"; trial_started: "trial_started"; }>; previousStatus: import("zod").ZodOptional<import("zod").ZodString>; newStatus: import("zod").ZodOptional<import("zod").ZodString>; previousPlanId: import("zod").ZodOptional<import("zod").ZodString>; newPlanId: import("zod").ZodOptional<import("zod").ZodString>; paymentIntentId: import("zod").ZodOptional<import("zod").ZodString>; amount: import("zod").ZodOptional<import("zod").ZodInt>; currency: import("zod").ZodOptional<import("zod").ZodString>; triggeredBy: import("zod").ZodOptional<import("zod").ZodString>; userId: import("zod").ZodOptional<import("zod").ZodString>; note: import("zod").ZodOptional<import("zod").ZodString>; }, import("zod/v4/core").$strip>>; protected readonly config: SubscriptionConfig; /** * Find a subscription by organization ID. * Returns null if no subscription exists. */ getByOrganization(organizationId: string): Promise<SubscriptionEntity | null>; /** * Get a subscription by ID. Throws NotFoundError if not found. */ getSubscription(id: string): Promise<SubscriptionEntity>; /** * Returns true if the subscription currently grants access. * Accessible statuses: trialing, active, past_due (grace period), * or cancelled with cancelAtPeriodEnd before period end. */ isAccessible(sub: SubscriptionEntity): boolean; /** * Record a subscription event in the event log. */ recordEvent(subscriptionId: string, organizationId: string, type: SubscriptionEventEntity["type"], context?: EventContext$2): Promise<void>; /** * Compute the end of a billing interval from a start date. */ computeIntervalEnd(start: string, interval: "monthly" | "yearly"): string; /** * Create a new subscription for an organization. */ subscribe(organizationId: string, planId: string, interval: "monthly" | "yearly", options?: SubscribeOptions): Promise<SubscriptionEntity>; /** * Cancel a subscription. * If immediate, the subscription expires right away. * If at period end, the subscription remains accessible until the period ends. */ cancel(subscriptionId: string, options?: CancelOptions): Promise<void>; /** * Resume a cancelled subscription before its period ends. * Only valid for subscriptions cancelled with cancelAtPeriodEnd. */ resume(subscriptionId: string): Promise<void>; /** * Change the plan of a subscription. * If immediate, proration is calculated and the plan changes now. * If at period end, the change is scheduled for the next renewal. * Returns the net proration amount (positive = charge, negative = credit). */ changePlan(subscriptionId: string, newPlanId: string, newInterval?: "monthly" | "yearly", options?: ChangePlanOptions): Promise<number>; /** * Reactivate a suspended subscription (admin action). * Resets dunning state and starts a new billing period. */ reactivate(subscriptionId: string): Promise<void>; /** * Extend the trial period of a trialing subscription. */ extendTrial(subscriptionId: string, days: number): Promise<void>; /** * Check if an organization has access to a specific feature. */ can(organizationId: string, feature: string): Promise<boolean>; /** * Get the usage limit for a resource. * Returns -1 for unlimited, 0 for no access. */ limit(organizationId: string, resource: string): Promise<number>; /** * Get the full entitlements snapshot for an organization. */ getEntitlements(organizationId: string): Promise<Entitlements>; /** * Find subscriptions with pagination and filtering. */ findSubscriptions(query?: SubscriptionQuery): Promise<Page<SubscriptionEntity>>; /** * Get the event history for a subscription, ordered by most recent first. */ getHistory(subscriptionId: string): Promise<SubscriptionEventEntity[]>; /** * Get aggregated subscription statistics. */ getStats(): Promise<SubscriptionStats>; /** * Get revenue data from recent subscription events. * Sums amounts from renewed and activated events within the specified window. */ getRevenue(days?: number): Promise<{ total: number; count: number; }>; /** * Calculate proration for a mid-cycle plan change. * Returns the net amount: positive = charge, negative = credit. */ protected calculateProration(sub: SubscriptionEntity, newPlanId: string, newInterval: "monthly" | "yearly"): Promise<number>; } //#endregion //#region ../../src/api/subscriptions/controllers/AdminSubscriptionController.d.ts declare class AdminSubscriptionController { protected readonly url = "/subscriptions"; protected readonly group = "admin:subscriptions"; protected readonly service: SubscriptionService; protected readonly config: SubscriptionConfig; /** * Find subscriptions with pagination and filtering. */ readonly findSubscriptions: import("alepha/server").ActionPrimitiveFn<{ query: import("zod").ZodObject<{ page: import("zod").ZodOptional<import("zod").ZodDefault<import("zod").ZodInt>>; size: import("zod").ZodOptional<import("zod").ZodDefault<import("zod").ZodInt>>; sort: import("zod").ZodOptional<import("zod").ZodString>; status: import("zod").ZodOptional<import("zod").ZodEnum<{ active: "active"; cancelled: "cancelled"; expired: "expired"; past_due: "past_due"; suspended: "suspended"; trialing: "trialing"; }>>; planId: import("zod").ZodOptional<import("zod").ZodString>; organizationId: import("zod").ZodOptional<import("zod").ZodString>; }, import("zod/v4/core").$strip>; response: import("zod").ZodObject<{ content: import("zod").ZodArray<import("zod").ZodObject<{ id: PgAttr<PgAttr<import("zod").ZodString, typeof PG_PRIMARY_KEY>, typeof PG_DEFAULT>; version: PgAttr<PgAttr<import("zod").ZodInt, typeof PG_VERSION>, typeof PG_DEFAULT>; createdAt: PgAttr<PgAttr<import("zod").ZodString, typeof PG_CREATED_AT>, typeof PG_DEFAULT>; updatedAt: PgAttr<PgAttr<import("zod").ZodString, typeof PG_UPDATED_AT>, typeof PG_DEFAULT>; organizationId: PgAttr<import("zod").ZodOptional<import("zod").ZodString> | import("zod").ZodString, typeof PG_ORGANIZATION>; planId: import("zod").ZodString; interval: import("zod").ZodEnum<{ monthly: "monthly"; yearly: "yearly"; }>; status: import("zod").ZodEnum<{ active: "active"; cancelled: "cancelled"; expired: "expired"; past_due: "past_due"; suspended: "suspended"; trialing: "trialing"; }>; currentPeriodStart: import("zod").ZodString; currentPeriodEnd: import("zod").ZodString; trialStart: import("zod").ZodOptional<import("zod").ZodString>; trialEnd: import("zod").ZodOptional<import("zod").ZodString>; cancelledAt: import("zod").ZodOptional<import("zod").ZodString>; cancelReason: import("zod").ZodOptional<import("zod").ZodString>; cancelAtPeriodEnd: import("zod").ZodDefault<import("zod").ZodBoolean>; lastPaymentIntentId: import("zod").ZodOptional<import("zod").ZodString>; lastPaymentAt: import("zod").ZodOptional<import("zod").ZodString>; nextBillingAt: import("zod").ZodOptional<import("zod").ZodString>; dunningStartedAt: import("zod").ZodOptional<import("zod").ZodString>; dunningAttempt: import("zod").ZodDefault<import("zod").ZodInt>; dunningNextRetryAt: import("zod").ZodOptional<import("zod").ZodString>; pendingPlanId: import("zod").ZodOptional<import("zod").ZodString>; pendingInterval: import("zod").ZodOptional<import("zod").ZodEnum<{ monthly: "monthly"; yearly: "yearly"; }>>; metadata: import("zod").ZodOptional<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodAny>>; }, import("zod/v4/core").$strip>>; page: import("zod").ZodObject<{ number: import("zod").ZodInt; size: import("zod").ZodInt; offset: import("zod").ZodInt; numberOfElements: import("zod").ZodInt; totalElements: import("zod").ZodOptional<import("zod").ZodInt>; totalPages: import("zod").ZodOptional<import("zod").ZodInt>; isEmpty: import("zod").ZodBoolean; isFirst: import("zod").ZodBoolean; isLast: import("zod").ZodBoolean; }, import("zod/v4/core").$strip>; }, import("zod/v4/core").$strip>; }>; /** * Get a subscription by ID. */ readonly getSubscription: import("alepha/server").ActionPrimitiveFn<{ params: import("zod").ZodObject<{ id: import("zod").ZodString; }, import("zod/v4/core").$strip>; response: import("zod").ZodObject<{ id: PgAttr<PgAttr<import("zod").ZodString, typeof PG_PRIMARY_KEY>, typeof PG_DEFAULT>; version: PgAttr<PgAttr<import("zod").ZodInt, typeof PG_VERSION>, typeof PG_DEFAULT>; createdAt: PgAttr<PgAttr<import("zod").ZodString, typeof PG_CREATED_AT>, typeof PG_DEFAULT>; updatedAt: PgAttr<PgAttr<import("zod").ZodString, typeof PG_UPDATED_AT>, typeof PG_DEFAULT>; organizationId: PgAttr<import("zod").ZodOptional<import("zod").ZodString> | import("zod").ZodString, typeof PG_ORGANIZATION>; planId: import("zod").ZodString; interval: import("zod").ZodEnum<{ monthly: "monthly"; yearly: "yearly"; }>; status: import("zod").ZodEnum<{ active: "active"; cancelled: "cancelled"; expired: "expired"; past_due: "past_due"; suspended: "suspended"; trialing: "trialing"; }>; currentPeriodStart: import("zod").ZodString; currentPeriodEnd: import("zod").ZodString; trialStart: import("zod").ZodOptional<import("zod").ZodString>; trialEnd: import("zod").ZodOptional<import("zod").ZodString>; cancelledAt: import("zod").ZodOptional<import("zod").ZodString>; cancelReason: import("zod").ZodOptional<import("zod").ZodString>; cancelAtPeriodEnd: import("zod").ZodDefault<import("zod").ZodBoolean>; lastPaymentIntentId: import("zod").ZodOptional<import("zod").ZodString>; lastPaymentAt: import("zod").ZodOptional<import("zod").ZodString>; nextBillingAt: import("zod").ZodOptional<import("zod").ZodString>; dunningStartedAt: import("zod").ZodOptional<import("zod").ZodString>; dunningAttempt: import("zod").ZodDefault<import("zod").ZodInt>; dunningNextRetryAt: import("zod").ZodOptional<import("zod").ZodString>; pendingPlanId: import("zod").ZodOptional<import("zod").ZodString>; pendingInterval: import("zod").ZodOptional<import("zod").ZodEnum<{ monthly: "monthly"; yearly: "yearly"; }>>; metadata: import("zod").ZodOptional<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodAny>>; }, import("zod/v4/core").$strip>; }>; /** * Get aggregated subscription statistics. */ readonly getStats: import("alepha/server").ActionPrimitiveFn<{ response: import("zod").ZodObject<{ total: import("zod").ZodInt; trialing: import("zod").ZodInt; active: import("zod").ZodInt; pastDue: import("zod").ZodInt; suspended: import("zod").ZodInt; cancelled: import("zod").ZodInt; expired: import("zod").ZodInt; trialConversionRate: import("zod").ZodNumber; churnRate: import("zod").ZodNumber; byPlan: import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodObject<{ active: import("zod").ZodInt; trialing: import("zod").ZodInt; total: import("zod").ZodInt; }, import("zod/v4/core").$strip>>; }, import("zod/v4/core").$strip>; }>; /** * Get revenue data from recent subscription events. */ readonly getRevenue: import("alepha/server").ActionPrimitiveFn<{ query: import("zod").ZodObject<{ days: import("zod").ZodOptional<import("zod").ZodInt>; }, import("zod/v4/core").$strip>; response: import("zod").ZodObject<{ total: import("zod").ZodInt; count: import("zod").ZodInt; }, import("zod/v4/core").$strip>; }>; /** * Get Monthly Recurring Revenue breakdown. */ readonly getMrr: import("alepha/server").ActionPrimitiveFn<{ response: import("zod").ZodObject<{ total: import("zod").ZodInt; byPlan: import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodInt>; growth: import("zod").ZodInt; newMrr: import("zod").ZodInt; expansionMrr: import("zod").ZodInt; contractionMrr: import("zod").ZodInt; churnMrr: import("zod").ZodInt; }, import("zod/v4/core").$strip>; }>; /** * Force a plan change for a subscription (admin action). */ readonly adminChangePlan: import("alepha/server").ActionPrimitiveFn<{ params: import("zod").ZodObject<{ id: import("zod").ZodString; }, import("zod/v4/core").$strip>; body: import("zod").ZodObject<{ planId: import("zod").ZodString; interval: import("zod").ZodOptional<import("zod").ZodEnum<{ monthly: "monthly"; yearly: "yearly"; }>>; immediate: import("zod").ZodOptional<import("zod").ZodBoolean>; }, import("zod/v4/core").$strip>; response: import("zod").ZodObject<{ id: PgAttr<PgAttr<import("zod").ZodString, typeof PG_PRIMARY_KEY>, typeof PG_DEFAULT>; version: PgAttr<PgAttr<import("zod").ZodInt, typeof PG_VERSION>, typeof PG_DEFAULT>; createdAt: PgAttr<PgAttr<import("zod").ZodString, typeof PG_CREATED_AT>, typeof PG_DEFAULT>; updatedAt: PgAttr<PgAttr<import("zod").ZodString, typeof PG_UPDATED_AT>, typeof PG_DEFAULT>; organizationId: PgAttr<import("zod").ZodOptional<import("zod").ZodString> | import("zod").ZodString, typeof PG_ORGANIZATION>; planId: import("zod").ZodString; interval: import("zod").ZodEnum<{ monthly: "monthly"; yearly: "yearly"; }>; status: import("zod").ZodEnum<{ active: "active"; cancelled: "cancelled"; expired: "expired"; past_due: "past_due"; suspended: "suspended"; trialing: "trialing"; }>; currentPeriodStart: import("zod").ZodString; currentPeriodEnd: import("zod").ZodString; trialStart: import("zod").ZodOptional<import("zod").ZodString>; trialEnd: import("zod").ZodOptional<import("zod").ZodString>; cancelledAt: import("zod").ZodOptional<import("zod").ZodString>; cancelReason: import("zod").ZodOptional<import("zod").ZodString>; cancelAtPeriodEnd: import("zod").ZodDefault<import("zod").ZodBoolean>; lastPaymentIntentId: import("zod").ZodOptional<import("zod").ZodString>; lastPaymentAt: import("zod").ZodOptional<import("zod").ZodString>; nextBillingAt: import("zod").ZodOptional<import("zod").ZodString>; dunningStartedAt: import("zod").ZodOptional<import("zod").ZodString>; dunningAttempt: import("zod").ZodDefault<import("zod").ZodInt>; dunningNextRetryAt: import("zod").ZodOptional<import("zod").ZodString>; pendingPlanId: import("zod").ZodOptional<import("zod").ZodString>; pendingInterval: import("zod").ZodOptional<import("zod").ZodEnum<{ monthly: "monthly"; yearly: "yearly"; }>>; metadata: import("zod").ZodOptional<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodAny>>; }, import("zod/v4/core").$strip>; }>; /** * Force cancel a subscription (admin action). */ readonly adminCancel: import("alepha/server").ActionPrimitiveFn<{ params: import("zod").ZodObject<{ id: import("zod").ZodString; }, import("zod/v4/core").$strip>; body: import("zod").ZodObject<{ reason: import("zod").ZodOptional<import("zod").ZodString>; immediate: import("zod").ZodOptional<import("zod").ZodBoolean>; }, import("zod/v4/core").$strip>; response: import("zod").ZodObject<{ ok: import("zod").ZodBoolean; id: import("zod").ZodOptional<import("zod").ZodUnion<readonly [import("zod").ZodString, import("zod").ZodInt]>>; count: import("zod").ZodOptional<import("zod").ZodNumber>; }, import("zod/v4/core").$strip>; }>; /** * Reactivate a suspended subscription (admin action). */ readonly adminReactivate: import("alepha/server").ActionPrimitiveFn<{ params: import("zod").ZodObject<{ id: import("zod").ZodString; }, import("zod/v4/core").$strip>; response: import("zod").ZodObject<{ ok: import("zod").ZodBoolean; id: import("zod").ZodOptional<import("zod").ZodUnion<readonly [import("zod").ZodString, import("zod").ZodInt]>>; count: import("zod").ZodOptional<import("zod").ZodNumber>; }, import("zod/v4/core").$strip>; }>; /** * Extend the trial period for a trialing subscription (admin action). */ readonly adminExtendTrial: import("alepha/server").ActionPrimitiveFn<{ params: import("zod").ZodObject<{ id: import("zod").ZodString; }, import("zod/v4/core").$strip>; body: import("zod").ZodObject<{ days: import("zod").ZodInt; }, import("zod/v4/core").$strip>; response: import("zod").ZodObject<{ ok: import("zod").ZodBoolean; id: import("zod").ZodOptional<import("zod").ZodUnion<readonly [import("zod").ZodString, import("zod").ZodInt]>>; count: import("zod").ZodOptional<import("zod").ZodNumber>; }, import("zod/v4/core").$strip>; }>; } //#endregion //#region ../../src/api/subscriptions/controllers/SubscriptionController.d.ts declare class SubscriptionController { protected readonly url = "/subscriptions"; protected readonly group = "subscriptions"; protected readonly service: SubscriptionService; protected readonly config: SubscriptionConfig; /** * List available subscription plans with pricing. */ readonly getPlans: import("alepha/server").ActionPrimitiveFn<{ response: import("zod").ZodArray<import("zod").ZodObject<{ id: import("zod").ZodString; name: import("zod").ZodString; description: import("zod").ZodOptional<import("zod").ZodString>; pricing: import("zod").ZodArray<import("zod").ZodObject<{ interval: import("zod").ZodEnum<{ monthly: "monthly"; yearly: "yearly"; }>; amount: import("zod").ZodInt; currency: import("zod").ZodString; }, import("zod/v4/core").$strip>>; features: import("zod").ZodArray<import("zod").ZodString>; limits: import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodInt>; trial: import("zod").ZodOptional<import("zod").ZodObject<{ days: import("zod").ZodInt; requirePaymentMethod: import("zod").ZodBoolean; }, import("zod/v4/core").$strip>>; order: import("zod").ZodInt; }, import("zod/v4/core").$strip>>; }>; /** * Get the current organization's subscription. */ readonly getMySubscription: import("alepha/server").ActionPrimitiveFn<{ response: import("zod").ZodObject<{ id: PgAttr<PgAttr<import("zod").ZodString, typeof PG_PRIMARY_KEY>, typeof PG_DEFAULT>; version: PgAttr<PgAttr<import("zod").ZodInt, typeof PG_VERSION>, typeof PG_DEFAULT>; createdAt: PgAttr<PgAttr<import("zod").ZodString, typeof PG_CREATED_AT>, typeof PG_DEFAULT>; updatedAt: PgAttr<PgAttr<import("zod").ZodString, typeof PG_UPDATED_AT>, typeof PG_DEFAULT>; organizationId: PgAttr<import("zod").ZodOptional<import("zod").ZodString> | import("zod").ZodString, typeof PG_ORGANIZATION>; planId: import("zod").ZodString; interval: import("zod").ZodEnum<{ monthly: "monthly"; yearly: "yearly"; }>; status: import("zod").ZodEnum<{ active: "active"; cancelled: "cancelled"; expired: "expired"; past_due: "past_due"; suspended: "suspended"; trialing: "trialing"; }>; currentPeriodStart: import("zod").ZodString; currentPeriodEnd: import("zod").ZodString; trialStart: import("zod").ZodOptional<import("zod").ZodString>; trialEnd: import("zod").ZodOptional<import("zod").ZodString>; cancelledAt: import("zod").ZodOptional<import("zod").ZodString>; cancelReason: import("zod").ZodOptional<import("zod").ZodString>; cancelAtPeriodEnd: import("zod").ZodDefault<import("zod").ZodBoolean>; lastPaymentIntentId: import("zod").ZodOptional<import("zod").ZodString>; lastPaymentAt: import("zod").ZodOptional<import("zod").ZodString>; nextBillingAt: import("zod").ZodOptional<import("zod").ZodString>; dunningStartedAt: import("zod").ZodOptional<import("zod").ZodString>; dunningAttempt: import("zod").ZodDefault<import("zod").ZodInt>; dunningNextRetryAt: import("zod").ZodOptional<import("zod").ZodString>; pendingPlanId: import("zod").ZodOptional<import("zod").ZodString>; pendingInterval: import("zod").ZodOptional<import("zod").ZodEnum<{ monthly: "monthly"; yearly: "yearly"; }>>; metadata: import("zod").ZodOptional<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodAny>>; }, import("zod/v4/core").$strip>; }>; /** * Create a new subscription for the current organization. */ readonly subscribe: import("alepha/server").ActionPrimitiveFn<{ body: import("zod").ZodObject<{ planId: import("zod").ZodString; interval: import("zod").ZodEnum<{ monthly: "monthly"; yearly: "yearly"; }>; metadata: import("zod").ZodOptional<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodAny>>; }, import("zod/v4/core").$strip>; response: import("zod").ZodObject<{ id: PgAttr<PgAttr<import("zod").ZodString, typeof PG_PRIMARY_KEY>, typeof PG_DEFAULT>; version: PgAttr<PgAttr<import("zod").ZodInt, typeof PG_VERSION>, typeof PG_DEFAULT>; createdAt: PgAttr<PgAttr<import("zod").ZodString, typeof PG_CREATED_AT>, typeof PG_DEFAULT>; updatedAt: PgAttr<PgAttr<import("zod").ZodString, typeof PG_UPDATED_AT>, typeof PG_DEFAULT>; organizationId: PgAttr<import("zod").ZodOptional<import("zod").ZodString> | import("zod").ZodString, typeof PG_ORGANIZATION>; planId: import("zod").ZodString; interval: import("zod").ZodEnum<{ monthly: "monthly"; yearly: "yearly"; }>; status: import("zod").ZodEnum<{ active: "active"; cancelled: "cancelled"; expired: "expired"; past_due: "past_due"; suspended: "suspended"; trialing: "trialing"; }>; currentPeriodStart: import("zod").ZodString; currentPeriodEnd: import("zod").ZodString; trialStart: import("zod").ZodOptional<import("zod").ZodString>; trialEnd: import("zod").ZodOptional<import("zod").ZodString>; cancelledAt: import("zod").ZodOptional<import("zod").ZodString>; cancelReason: import("zod").ZodOptional<import("zod").ZodString>; cancelAtPeriodEnd: import("zod").ZodDefault<import("zod").ZodBoolean>; lastPaymentIntentId: import("zod").ZodOptional<import("zod").ZodString>; lastPaymentAt: import("zod").ZodOptional<import("zod").ZodString>; nextBillingAt: import("zod").ZodOptional<import("zod").ZodString>; dunningStartedAt: import("zod").ZodOptional<import("zod").ZodString>; dunningAttempt: import("zod").ZodDefault<import("zod").ZodInt>; dunningNextRetryAt: import("zod").ZodOptional<import("zod").ZodString>; pendingPlanId: import("zod"