everything-dev
Version:
A consolidated product package for building Module Federation apps with oRPC APIs.
40 lines • 1.78 kB
text/typescript
import { MigrationStorage } from "./core.mjs";
//#region src/db/identity.d.ts
/**
* The database identity of a workspace: everything downstream consumers need
* (drizzle-kit configs, migration runners, tooling CLIs) is a pure function of
* these values. Identity has one source of truth — the workspace's
* package.json — and must never be guessed from ambient process state
* (cwd, npm_package_name, shell env).
*/
interface WorkspaceIdentity {
readonly slug: string;
readonly secretName: string;
readonly journal: MigrationStorage;
readonly workspaceDir: string | undefined;
}
/**
* Walk up from a directory to the nearest ancestor containing a package.json.
* Returns the start directory when none is found.
*/
declare function findWorkspaceDir(startDir: string): string;
/**
* Derive workspace identity from a workspace directory.
*/
declare function workspaceIdentityFromWorkspaceDir(dir: string): WorkspaceIdentity;
/**
* Derive workspace identity from a module's own location.
*
* This is the primitive for drizzle.config.ts files: `import.meta.url` is the
* one module-identity fact that survives every config loader we run under —
* real ESM (Node/Bun) and drizzle-kit's bundled tsx CJS transform (which
* defines `import.meta.url` but NOT `import.meta.dirname`, leaving that
* `undefined` in evaluated configs).
*
* Pass the member expression itself (`workspaceIdentityFromModuleUrl(import.meta.url)`)
* so the transform substitutes the value; do not pass the `import.meta` object.
*/
declare function workspaceIdentityFromModuleUrl(moduleUrl: string): WorkspaceIdentity;
//#endregion
export { WorkspaceIdentity, findWorkspaceDir, workspaceIdentityFromModuleUrl, workspaceIdentityFromWorkspaceDir };
//# sourceMappingURL=identity.d.mts.map