UNPKG

everything-dev

Version:

A consolidated product package for building Module Federation apps with oRPC APIs.

32 lines • 1.64 kB
import { PgDatabase, PgQueryResultHKT } from "drizzle-orm/pg-core"; //#region src/db/driver.d.ts interface DatabaseDriver<TSchema extends Record<string, unknown>> { readonly db: PgDatabase<PgQueryResultHKT, TSchema>; close(): Promise<void>; } /** * Resolve a plugin id to its data-schema name on a shared database. * * `plugin_<slug>` namespaces PLUGIN workspaces on the shared API database. * The api shell itself keeps the public-schema topology (what `bos db doctor` * checks, the drizzle-kit configs target, and every v1-upgraded database * already has) — callers resolving a data namespace must pass `undefined` for * it, never this function's `plugin_api`. */ declare function pluginSchemaName(pluginId: string): string; /** * Create a drizzle database driver for a plugin, choosing the engine by URL * scheme: `pglite:` / `:memory:` → embedded PGlite, anything else → postgres * (`pg.Pool`). * * Drivers stay externalized (never statically imported, never in the Module * Federation singleton share set) — they are loaded here via dynamic `import()` * only, and `drizzle-orm` appears as a runtime import for the `drizzle` entry * points. The `namespace` option expresses every topology the platform needs: * `plugin_<slug>` on a shared database, undefined for public-schema (api) or * dedicated-database (auth) workloads. */ declare function createDatabaseDriver<TSchema extends Record<string, unknown>>(url: string, schema: TSchema, namespace?: string): Promise<DatabaseDriver<TSchema>>; //#endregion export { DatabaseDriver, createDatabaseDriver, pluginSchemaName }; //# sourceMappingURL=driver.d.cts.map