import { DatabaseError } from "./errors.mjs";
import { LoadedMigrations } from "./run-migrations.mjs";
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.mts.map