UNPKG

everything-dev

Version:

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

31 lines • 1.66 kB
import { DatabaseError } from "./errors.cjs"; import { LoadedMigrations } from "./run-migrations.cjs"; import { Context, Effect, Layer } from "effect"; import { PgDatabase, PgQueryResultHKT } from "drizzle-orm/pg-core"; //#region src/db/layer.d.ts /** * The plugin author's whole database surface (ADR 0033): one call that * acquires the driver against the plugin's lifecycle scope, applies * migrations on boot (journal-scoped advisory lock, ADR 0019), detects * drift, and provides the typed drizzle database on the **plugin-owned tag** * — the swap seam. A different engine, a different drizzle setup, or a * totally different storage situation is the same interface: provide any * `Layer` for your own tag and nothing else in the plugin changes. * * `namespace: true` (the default) scopes the workspace into the * `plugin_<slug>` schema on the shared database; `namespace: false` keeps * the public topology (the api shell, or a dedicated database like auth's). * `migrations` is the workspace-bound loader Effect (`loadMigrations` from * this package, instantiated with the workspace's `import.meta.dirname` and * its bundle's `virtual:drizzle-migrations.sql` module); omit it to skip * boot migration entirely. */ declare function databaseLayer<Identifier, TSchema extends Record<string, unknown>>(tag: Context.Service<Identifier, PgDatabase<PgQueryResultHKT, TSchema>>, url: string, options: { pluginId: string; schema: TSchema; migrations?: Effect.Effect<LoadedMigrations, DatabaseError>; namespace?: boolean; }): Layer.Layer<Identifier, DatabaseError>; //#endregion export { databaseLayer }; //# sourceMappingURL=layer.d.cts.map