import { kt as ColumnBuilder, on as MigrationAdapter } from "./index-DcuMZ9kb.mjs"; import { Dialect } from "kysely"; //#region src/dsl/columns/pg.d.ts /** * Declare a PostgreSQL ENUM type. * * @example * ```ts * export const taskStatus = pgEnum('task_status', 'todo', 'in_progress', 'done') * * export const tasks = table('tasks', { * id: uuid().primaryKey().defaultRandom(), * status: taskStatus().notNull().default('todo'), * }) * ``` * * The factory returns a column builder whose phantom type narrows to * the union of the declared values — `db.selectFrom('tasks').select('status')` * types `status: 'todo' | 'in_progress' | 'done'`. * * Schema-level state (the enum name + values) is attached to every * column the factory produces so introspection / drift / emit can pick * it up. The snapshot + emit pipeline learns about enum types in the * follow-up commit; for now adopters must run the * `CREATE TYPE AS ENUM (...)` DDL manually before any column * referencing the type is created. */ interface PgEnumBuilder { (): PgEnumColumnBuilder; /** The SQL identifier — used by emit + drift detection. */ readonly enumName: TName; /** Allowed literal values, in declaration order. */ readonly values: TValues; } declare class PgEnumColumnBuilder extends ColumnBuilder { /** The enum's SQL identifier — preserved for emit + drift detection. */ readonly enumName: TName; /** Allowed values — readonly to prevent mutation across columns. */ readonly values: TValues; constructor(enumName: TName, values: TValues); } declare function pgEnum(name: TName, ...values: TValues): PgEnumBuilder; declare function tsvector(): ColumnBuilder; declare function vector(dim?: number): ColumnBuilder; declare function citext(): ColumnBuilder; declare function money(): ColumnBuilder; declare function inet(): ColumnBuilder; declare function cidr(): ColumnBuilder; declare function xml(): ColumnBuilder; //#endregion //#region src/adapters/pg/adapter.d.ts /** * Minimal client returned by PgPoolLike.connect(). Matches the shape of * pg.PoolClient and @neondatabase/serverless's PoolClient. */ interface PgClientLike { query(sql: string, params?: readonly unknown[]): Promise<{ rows: R[]; rowCount: number | null; }>; release(): void; } /** * Pool-shaped contract that pgAdapter consumes. Both `pg.Pool` and * `@neondatabase/serverless`'s Pool match this structurally — no hard * dependency on the `pg` package. Adopters pick whichever pg-protocol- * compatible client fits their runtime (node-postgres / neon-serverless / * pg-cloudflare / etc). * * Edge runtimes with a different surface (Neon HTTP single-shot, * Cloudflare D1's batch-only model) have their own adapter packages that * implement MigrationAdapter directly — they don't reuse this shape. */ interface PgPoolLike { query(sql: string, params?: readonly unknown[]): Promise<{ rows: R[]; rowCount: number | null; }>; connect(): Promise; } interface PgAdapterOptions { /** * A pg-protocol-compatible Pool. Concretely: pg.Pool, neon-serverless Pool, * any other Pool that satisfies the {@link PgPoolLike} structural shape. */ pool: PgPoolLike; /** PG schema name to scope the introspector and validate at construction. Default 'public'. */ schema?: string; } /** * MigrationAdapter implementation backed by node-postgres. The pool is * caller-owned — close() does NOT end() the pool because adopters typically * share a single pool across the migrationAdapter and the KickDbClient. * * Lock semantics: single-row UPDATE WHERE locked_at IS NULL on * kick_migrations_lock. Only the row created by ensureMigrationTables() * exists, so the UPDATE either flips locked_at and returns rowCount=1 * (we won) or matches zero rows (someone else holds it). */ declare function pgAdapter(opts: PgAdapterOptions): MigrationAdapter; //#endregion //#region src/adapters/pg/dialect.d.ts interface PgDialectOptions { /** * pg-protocol-compatible pool. Both `pg.Pool` and * `@neondatabase/serverless`'s Pool match structurally; adopters * pick whichever runtime fits. */ pool: PgPoolLike; } /** * Construct the dialect that `createDbClient({ dialect })` consumes. * * @example * ```ts * import { createDbClient } from '@forinda/kickjs-db' * import { pgDialect, pgAdapter } from '@forinda/kickjs-db/pg' * import { Pool } from 'pg' * * const pool = new Pool({ connectionString: process.env.DATABASE_URL }) * * export const db = createDbClient({ * schema, * dialect: pgDialect({ pool }), * }) * * export const migrationAdapter = pgAdapter({ pool }) * ``` */ declare function pgDialect(opts: PgDialectOptions): Dialect; //#endregion export { PgAdapterOptions, PgClientLike, PgDialectOptions, PgEnumBuilder, PgEnumColumnBuilder, PgPoolLike, cidr, citext, inet, money, pgAdapter, pgDialect, pgEnum, tsvector, vector, xml }; //# sourceMappingURL=pg.d.mts.map