interface StashConfig { /** PostgreSQL connection string */ databaseUrl: string; /** Path to encryption client file. Defaults to `'./src/encryption/index.ts'`. */ client?: string; } /** The config shape after Zod validation, with all defaults applied. */ type ResolvedStashConfig = Required> & Omit; /** * Define a stash config with type checking. * Use this as the default export in your `stash.config.ts`. * * @example * ```ts * import { defineConfig } from '@cipherstash/cli' * * export default defineConfig({ * databaseUrl: process.env.DATABASE_URL!, * client: './src/encryption/index.ts', * }) * ``` */ declare function defineConfig(config: StashConfig): StashConfig; /** * Load and validate the `stash.config.ts` from the user's project. * * Searches from `process.cwd()` upward. Uses `jiti` to evaluate the * TypeScript config file at runtime without a separate compile step. * * Exits with code 1 if the config file is not found or fails validation. */ declare function loadStashConfig(): Promise; interface PermissionCheckResult { ok: boolean; missing: string[]; /** * Whether the connected role is a Postgres superuser. Managed Postgres * providers (Supabase, Neon, RDS, etc.) do not grant superuser, which means * `CREATE OPERATOR FAMILY` / `CREATE OPERATOR CLASS` in the EQL install * script will fail. Callers use this to auto-fall back to the * no-operator-family install variant (OPE index only) instead of aborting. */ isSuperuser: boolean; } declare class EQLInstaller { private readonly databaseUrl; constructor(options: { databaseUrl: string; }); /** * Check whether the connected database role has the permissions required * to install EQL. * * EQL installation requires: * - SUPERUSER or CREATEDB — for `CREATE EXTENSION IF NOT EXISTS pgcrypto` * - CREATE on the current database — for `CREATE SCHEMA eql_v2` * - CREATE on the public schema — for `CREATE TYPE public.eql_v2_encrypted` */ checkPermissions(): Promise; /** * Check whether the EQL extension is installed by looking for the `eql_v2` schema. */ isInstalled(): Promise; /** * Return the installed EQL version, or `null` if EQL is not installed. * * This is best-effort: if the schema exists but no version metadata is * available, `'unknown'` is returned. */ getInstalledVersion(): Promise; /** * Install the CipherStash EQL PostgreSQL extension. * * By default, uses the SQL bundled with this package. Pass `latest: true` * to fetch the latest version from GitHub instead. * * This method is intentionally "silent" — it does not produce any console * output. The calling CLI command is responsible for all user-facing output. */ install(options?: { excludeOperatorFamily?: boolean; supabase?: boolean; latest?: boolean; }): Promise; /** * Grant Supabase roles access to the eql_v2 schema. * * Supabase uses dedicated roles (anon, authenticated, service_role) that * don't own the schema, so explicit grants are required. Issues * {@link SUPABASE_PERMISSIONS_SQL} as a single multi-statement query — * Postgres accepts that and it keeps the SQL identical to what we'd write * into a Supabase migration file. */ private grantSupabasePermissions; /** * Load the EQL SQL install script bundled with this package. */ private loadBundledInstallScript; /** * Download the EQL SQL install script from GitHub. */ private downloadInstallScript; } /** * Load the bundled EQL install SQL. Used by the Drizzle migration path. */ declare function loadBundledEqlSql(options?: { excludeOperatorFamily?: boolean; supabase?: boolean; }): string; /** * Download the latest EQL install SQL from GitHub. Used by the Drizzle migration path * when `--latest` is passed. * * Supabase uses the same GitHub asset as the no-operator-family variant — * treating either flag as "no operator families" keeps the intent explicit * even though the underlying URL is the same. */ declare function downloadEqlSql(options?: { excludeOperatorFamily?: boolean; supabase?: boolean; } | boolean): Promise; export { EQLInstaller, type PermissionCheckResult, type StashConfig, defineConfig, downloadEqlSql, loadBundledEqlSql, loadStashConfig };