import type { AuthQueryClient } from '@hasna/contracts/auth'; import pg from 'pg'; import type { DbAdapter, SqliteAdapter as Database } from './sqlite-adapter.js'; /** The environment shape the backend resolver reads. */ type Env = Record; /** Resolve the Postgres DSN from the standard env aliases. */ export declare function getCloudDatabaseUrl(env?: Env): string | undefined; /** * Resolve the server data backend from database configuration ALONE. * * `@hasna/contracts` 1.0.2 narrowed its published `ServerDataBackendSchema` to * `z.literal("postgresql")` — SQLite is legacy-import input, never a LIVE * backend, so the contract's health vocabulary only speaks the authoritative * arm. Economy's serve still runs a real on-box SQLite backend in local mode, * so the resolver keeps its own two-arm union and the runtime reports the * honest backend on `/health` (the contract schema is asserted against the * postgresql arm in `foundation-probe.contract.test.ts`). * * The retired deployment-mode axis stays gone: the only switch is the server's * data backend, `sqlite | postgresql`, and a present database URL is what * selects `postgresql`. Retired `STORAGE_MODE` / `MODE` variables are rejected * with a migration hint rather than normalized or silently mapped, so a * half-migrated deployment fails loudly at startup instead of quietly serving * the wrong store. * * The rejection stays local because economy also honours the bare `DATABASE_URL` * alias, which the contract's own resolver does not read — deferring to it * wholesale would silently downgrade such a deployment to sqlite. */ export type EconomyServerBackend = 'sqlite' | 'postgresql'; export declare function resolveEconomyServerBackend(env?: Env): EconomyServerBackend; /** True when the serve reads and writes PostgreSQL directly. */ export declare function isPostgresBackend(env?: Env): boolean; /** HMAC signing secret for API-key verification (server-held, never in a token). */ export declare function resolveSigningSecret(): string | undefined; /** * Open a pooled Postgres connection to the shared RDS. Returns a value typed as * the SQLite `Database` the query layer expects — safe because `SyncPgAdapter` * implements the identical `DbAdapter` surface those functions rely on. */ export declare function openCloudDatabase(dsn?: string | undefined): Database; /** A raw pg Pool for auxiliary async work (API-key store, migrations). */ export declare function createCloudPool(dsn?: string | undefined): pg.Pool; /** * Adapt a pg Pool to the `@hasna/contracts/auth` `AuthQueryClient` surface * (many/get/execute). This backs the `ApiKeyStore` without pulling in the * generic vendored kit — economy's storage is this pg pool. */ export declare function authClientFromPool(pool: pg.Pool): AuthQueryClient; /** Ordered PG migrations applied by the migration runner (index = version). */ export declare function cloudMigrations(): string[]; export type { DbAdapter }; //# sourceMappingURL=cloud.d.ts.map