import { type Compilable, type Dialect, Kysely } from 'kysely'; import type * as AdminAuditLogs from './tables/adminAuditLogs.js'; import type * as BillingSettings from './tables/billingSettings.js'; import type * as EarlyAccess from './tables/earlyAccess.js'; import type * as EarnVaults from './tables/earnVaults.js'; import type * as EnabledBillingSources from './tables/enabledBillingSources.js'; import type * as FundingCatalog from './tables/fundingCatalog.js'; import type * as FundingDepositAddresses from './tables/fundingDepositAddresses.js'; import type * as FundingDepositRequestObservations from './tables/fundingDepositRequestObservations.js'; import type * as FundingDeposits from './tables/fundingDeposits.js'; import type * as FundingIdempotency from './tables/fundingIdempotency.js'; import type * as FundingTransferEvents from './tables/fundingTransferEvents.js'; import type * as FundingTransfers from './tables/fundingTransfers.js'; import type * as FundingTransferTransactions from './tables/fundingTransferTransactions.js'; import type * as Invitations from './tables/invitations.js'; import type * as InviteLinks from './tables/inviteLinks.js'; import type * as Memberships from './tables/memberships.js'; import type * as Organizations from './tables/organizations.js'; import type * as Projects from './tables/projects.js'; import type * as RequestUsage from './tables/requestUsage.js'; import type * as SponsoredTransactions from './tables/sponsoredTransactions.js'; import type * as StripeCustomers from './tables/stripeCustomers.js'; import type * as Users from './tables/users.js'; import type * as VerifiedTokenRequests from './tables/verifiedTokenRequests.js'; import type * as VerifiedTokens from './tables/verifiedTokens.js'; import type * as WebhookDeliveries from './tables/webhookDeliveries.js'; import type * as WebhookQueueCompletions from './tables/webhookQueueCompletions.js'; import type * as WebhookQueueEvents from './tables/webhookQueueEvents.js'; import type * as WebhookSubscriptions from './tables/webhookSubscriptions.js'; /** * Kysely schema with camelCase columns. {@link CamelCasePlugin} maps table * records, queries, and {@link migrations} DDL to snake_case storage columns. */ export type Database = { admin_audit_logs: AdminAuditLogs.Table; billing_settings: BillingSettings.Table; early_access: EarlyAccess.Table; earn_vaults: EarnVaults.Table; enabled_billing_sources: EnabledBillingSources.Table; funding_catalogs: FundingCatalog.CatalogTable; funding_chain_tokens: FundingCatalog.ChainTokenTable; funding_chains: FundingCatalog.ChainTable; funding_deposit_addresses: FundingDepositAddresses.Table; funding_deposit_request_observations: FundingDepositRequestObservations.Table; funding_deposits: FundingDeposits.Table; funding_idempotency_requests: FundingIdempotency.Table; funding_routes: FundingCatalog.RouteTable; funding_tokens: FundingCatalog.TokenTable; funding_transfer_events: FundingTransferEvents.Table; funding_transfer_transactions: FundingTransferTransactions.Table; funding_transfers: FundingTransfers.Table; invitations: Invitations.Table; invite_link_redemptions: InviteLinks.RedemptionTable; invite_links: InviteLinks.Table; memberships: Memberships.Table; migrations: { appliedAt: string; checksum: string; name: string; /** SQL as applied; null on rows written before the column existed. */ sql: string | null; }; organizations: Organizations.Table; projects: Projects.Table; request_usage_buckets: RequestUsage.BucketTable; request_usage_meter_events: RequestUsage.MeterEventTable; sponsored_transactions: SponsoredTransactions.Table; stripe_customers: StripeCustomers.Table; users: Users.Table; verified_token_lists: VerifiedTokens.ListTable; verified_token_requests: VerifiedTokenRequests.Table; verified_tokens: VerifiedTokens.Table; webhook_deliveries: WebhookDeliveries.Table; webhook_queue_completions: WebhookQueueCompletions.Table; webhook_queue_events: WebhookQueueEvents.Table; webhook_subscriptions: WebhookSubscriptions.Table; }; /** * A SQL-backed authoritative store: the underlying Kysely handle (table * repository modules query through it), schema migrations, and transactions. */ export type Db = { /** Closes the underlying connection/pool. */ close(): Promise; /** * Underlying Kysely handle. Transaction-scoped {@link Db} values carry the * transaction handle, so repositories called with `tx` run inside it. */ kysely: Kysely; /** Applies any pending schema migrations; safe to call repeatedly and concurrently. */ migrate(): Promise; /** * Runs `fn` in a transaction — commits on return, rolls back on throw. `fn` * receives a transaction-scoped {@link Db}; pass it (not the outer `Db`) to * repositories so every query inside runs in the transaction. */ transaction(fn: (tx: Db) => Promise): Promise; }; /** * A {@link Db}, or a factory for per-request Workers/Hyperdrive connections. * Node can pass a long-lived singleton. Resolve at the leaf with {@link get}. */ export type Source = Db | (() => Db); /** * Resolves a {@link Source} to a {@link Db}. Call at the request leaf so * factories create per-request instances; singletons resolve to themselves. * * @param source - The database or factory. * @returns The resolved {@link Db}. */ export declare function get(source: Source): Db; /** * One schema migration. `up` builds a single idempotent Kysely DDL statement; * {@link Db.migrate} compiles it for the checksum, then applies it. */ type Migration = { /** Unique, ordered migration name (e.g. `0001_organizations`). */ name: string; /** * Builds the migration's DDL against `db`. Use `.ifNotExists()` so the * statement is safe to re-run without a wrapping transaction. */ up: (db: Kysely) => Compilable & { execute(): Promise; }; }; /** * Ordered schema migrations for {@link Db.migrate}. Each `up` is one * idempotent statement; compiled-SQL FNV-1a checksums reject edited applied * migrations. */ export declare const migrations: readonly Migration[]; /** * Builds a {@link Db} for any Kysely {@link Dialect}. All backends share * migrations, repositories, and the required {@link CamelCasePlugin} mapping. * * @param dialect - The Kysely dialect for the target backend. * @returns The database. */ export declare function from(dialect: Dialect): Db; /** * Creates a Postgres-backed {@link Db} via Kysely's `PostgresDialect`. Optional * `schema` qualifies repository queries, scopes migrations, and caps the pool. * * @param options - Postgres options. * @returns The database. */ export declare function postgres(options: postgres.Options): Db; export declare namespace postgres { /** Options for {@link postgres}. */ type Options = { /** Postgres connection string (`postgresql://…`). */ connectionString: string; /** Schema to qualify and create during migration (isolates concurrent tests). */ schema?: string | undefined; }; } export {}; //# sourceMappingURL=Db.d.ts.map