everything-dev
Version:
A consolidated product package for building Module Federation apps with oRPC APIs.
52 lines • 2.57 kB
text/typescript
import { WorkspaceIdentity } from "./identity.mjs";
//#region src/db/binding.d.ts
/**
* The zero-config local database root: a persistent, file-backed PGlite data
* dir (`.bos/db`). No ports, no docker — concurrent projects never collide.
* This is the *layout base*, not a driver target: multiple live PGlite
* instances on one data dir silently corrupt committed data (heap/index
* divergence — ADR 0044), so every workspace opens its own subdirectory via
* `pgliteDefaultUrlForSlug`. The literal remains exported for legacy-pin
* matching (the compose-era and shared-dir rewrite in `env/legacy-databases`)
* — never hand a driver the bare base.
*
* This default is a runtime-driver concern only: drizzle-kit commands
* (db:push/db:studio/db:migrate) need a real postgres DSN in the environment.
*
* Single-sourced in `defaults.json` (read by plain-node tooling like the
* regression env too) — never hardcode the literal elsewhere. Scaffolded
* templates and plugin secret defaults deliberately keep their own frozen
* copy: a database location is pinned at init, it must not silently follow
* a framework upgrade.
*/
declare const PGLITE_DEFAULT_URL: string;
/**
* The per-identity default: `<PGLITE_DEFAULT_URL>/<slug>` (e.g.
* `pglite:.bos/db/api`, `pglite:.bos/db/agent_connect`). The slug matches the
* `pluginMigrationSlug`/`normalizeDatabaseSlug` naming used for schemas,
* journals, and secret names — one workspace, one data dir, collisions
* impossible by package-name uniqueness (ADR 0044).
*/
declare function pgliteDefaultUrlForSlug(slug: string): string;
/**
* Resolve the connection URL for a workspace identity.
*
* Resolution order:
* 1. the canonical secret in the provided environment
* 2. the canonical secret in the nearest `.env` walked up from the
* workspace directory (existing environment wins — values are not
* overridden, matching dotenv semantics)
* 3. the per-identity default (`pgliteDefaultUrlForSlug(identity.slug)`) —
* consumed by the runtime driver (`createDatabaseDriver`), so boot
* migrations apply zero-config against the workspace's own
* `.bos/db/<slug>` data dir
*
* drizzle-kit commands need a postgres DSN; feeding them the pglite default
* fails loudly at connect time.
*/
declare function resolveDatabaseUrl(identity: WorkspaceIdentity, options?: {
env?: Record<string, string | undefined>;
}): string;
//#endregion
export { PGLITE_DEFAULT_URL, pgliteDefaultUrlForSlug, resolveDatabaseUrl };
//# sourceMappingURL=binding.d.mts.map