import { type Compilable, type Dialect, Kysely } from 'kysely'; import type * as AdminAuditLogs from './tables/adminAuditLogs.js'; import type * as ApiKeyAdmissionBootstraps from './tables/apiKeyAdmissionBootstraps.js'; import type * as ApiKeyAdmissions from './tables/apiKeyAdmissions.js'; import type * as ApiKeyOwnerAdmissions from './tables/apiKeyOwnerAdmissions.js'; import type * as ApiKeyOwnerTombstones from './tables/apiKeyOwnerTombstones.js'; import type * as ApiKeyRevocations from './tables/apiKeyRevocations.js'; import type * as AuthAccounts from './tables/authAccounts.js'; import type * as AuthSessions from './tables/authSessions.js'; import type * as AuthVerifications from './tables/authVerifications.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 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 RewardAccounts from './tables/rewardAccounts.js'; import type * as RewardCampaignDistributors from './tables/rewardCampaignDistributors.js'; import type * as RewardCampaigns from './tables/rewardCampaigns.js'; import type * as RewardCredits from './tables/rewardCredits.js'; import type * as RewardEligibilityAssociations from './tables/rewardEligibilityAssociations.js'; import type * as RewardRuns from './tables/rewardRuns.js'; import type * as RewardTransactionAttempts from './tables/rewardTransactionAttempts.js'; import type * as RoutesCatalog from './tables/routesCatalog.js'; import type * as RoutesDepositAddresses from './tables/routesDepositAddresses.js'; import type * as RoutesDepositRequestObservations from './tables/routesDepositRequestObservations.js'; import type * as RoutesDeposits from './tables/routesDeposits.js'; import type * as RoutesIdempotency from './tables/routesIdempotency.js'; import type * as RoutesSubsidies from './tables/routesSubsidies.js'; import type * as RoutesTransferEvents from './tables/routesTransferEvents.js'; import type * as RoutesTransfers from './tables/routesTransfers.js'; import type * as RoutesTransferSubsidies from './tables/routesTransferSubsidies.js'; import type * as RoutesTransferSubsidyNonces from './tables/routesTransferSubsidyNonces.js'; import type * as RoutesTransferTransactions from './tables/routesTransferTransactions.js'; import type * as SponsorshipReconciliationCursors from './tables/sponsorshipReconciliationCursors.js'; import type * as SponsorshipAttributions from './tables/sponsorshipAttributions.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; api_key_admission_bootstraps: ApiKeyAdmissionBootstraps.Table; api_key_admissions: ApiKeyAdmissions.Table; api_key_owner_admissions: ApiKeyOwnerAdmissions.Table; api_key_owner_tombstones: ApiKeyOwnerTombstones.Table; api_key_revocations: ApiKeyRevocations.Table; auth_accounts: AuthAccounts.Table; auth_sessions: AuthSessions.Table; auth_verifications: AuthVerifications.Table; billing_settings: BillingSettings.Table; early_access: EarlyAccess.Table; earn_vaults: EarnVaults.Table; enabled_billing_sources: EnabledBillingSources.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; reward_accounts: RewardAccounts.Table; reward_campaign_distributors: RewardCampaignDistributors.Table; reward_campaigns: RewardCampaigns.Table; reward_credits: RewardCredits.Table; reward_eligibility_associations: RewardEligibilityAssociations.Table; reward_runs: RewardRuns.Table; reward_transaction_attempts: RewardTransactionAttempts.Table; routes_catalogs: RoutesCatalog.CatalogTable; routes_chain_tokens: RoutesCatalog.ChainTokenTable; routes_chains: RoutesCatalog.ChainTable; routes_deposit_addresses: RoutesDepositAddresses.Table; routes_deposit_request_observations: RoutesDepositRequestObservations.Table; routes_deposits: RoutesDeposits.Table; routes_idempotency_requests: RoutesIdempotency.Table; routes_routes: RoutesCatalog.RouteTable; routes_subsidies: RoutesSubsidies.Table; routes_tokens: RoutesCatalog.TokenTable; routes_transfer_events: RoutesTransferEvents.Table; routes_transfer_subsidies: RoutesTransferSubsidies.Table; routes_transfer_subsidy_nonces: RoutesTransferSubsidyNonces.Table; routes_transfer_transactions: RoutesTransferTransactions.Table; routes_transfers: RoutesTransfers.Table; sponsorship_reconciliation_cursors: SponsorshipReconciliationCursors.Table; sponsorship_attributions: SponsorshipAttributions.Table; 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 and scopes migrations. * * @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; /** Maximum connections held by this local pool; defaults to `1` with schema scoping. */ maxConnections?: number | undefined; /** Schema to qualify and create during migration (isolates concurrent tests). */ schema?: string | undefined; }; } export {}; //# sourceMappingURL=Db.d.ts.map