import { type PartialWithUndefined } from '@augment-vir/common'; import { type UniversalTestContext } from '@augment-vir/test'; import { type PGlite } from '@electric-sql/pglite'; import { PrismaPGliteAdapterFactory } from './prisma-pglite-adapter/pglite.js'; /** * Params for {@link createPgliteAdapter}. * * @category Internal */ export type PgliteAdapterParams = PartialWithUndefined<{ /** * Path to a Prisma config file (`prisma.config.ts`). * * @default join(process.cwd(), 'prisma.config.ts') */ prismaConfigPath: string; /** * This is the path to your PGlite parent directory. Inside of this directory will be created * the actual PGlite directories for each database name.. * * @default * - join('', '.not-committed', 'pglite') * - join(process.cwd(), '.not-committed', 'pglite') */ dbParentDirPath: string; /** * A optional name for the database. This allows separate prisma schemas to be used (for * different databases) with the same configurations otherwise. If this is provided, the final * database directory will be in `join(dbParentDirPath, , databaseName)` */ databaseName: string; /** * Overwrites `dbParentDirPath` and `testContext`, if either is provided, to provide a direct * path to the PGlite database folder rather than deducing the folder path from * `dbParentDirPath`. * * @default * undefined */ directDatabaseDirPath: string; /** * Either a `UniversalTestContext` instance (which a dir name is extracted from), or a direct * database dir name. This is primarily used for running unit tests with a new database per * test, but can also be used to override the default `'dev'` database dir name. If this is * provided, the final database directory will be in `join(dbParentDirPath, )`. * * @default undefined */ dbDirName: string | UniversalTestContext; /** * If set to true, any existing database at the database path will be deleted before setting up * a new fresh instance. * * @default false */ resetDatabase: boolean; }>; /** * Params for {@link PrismaPgliteAdapter}. * * @category Internal */ export type PrismaPgliteAdapterParams = { wasJustInitialized: boolean; databaseDirPath: string; }; /** * Extension of the core `PrismaPGlite` PGlite adapter that adds extra properties for external * convenience. * * @category Internal */ export declare class PrismaPgliteAdapter extends PrismaPGliteAdapterFactory { readonly wasJustInitialized: boolean; readonly databaseDirPath: string; constructor(pglite: PGlite, params: Readonly); } /** * Creates a PGlite adapter than can be used with the `PrismaClient` constructor. This will create a * new PGlite database on your file system, if one does not already exist, and push your schema to * it (similar to `prisma db push`). This _cannot_, however, push new migrations to an existing * PGlite database (as `prisma db push` does with a normal Postgres database). * * Requires Prisma v7 or later, where driver adapters are enabled by default (no preview feature is * required). * * @category Adapter * @example * * Usage in TypeScript: * * ```ts * import {PrismaClient} from '../generated/client.js'; * import {createPgliteAdapter} from 'prisma-pglite'; * * const prismaClient = new PrismaClient({ * adapter: await createPgliteAdapter({ * prismaConfigPath, * }), * }); * ``` * * @example * * Requirement in `schema.prisma`: * * ```prisma * generator jsClient { * provider = "prisma-client" * output = "../generated" * } * ``` */ export declare function createPgliteAdapter(params?: PgliteAdapterParams): Promise;