import { t as Id } from "./types-hGBnCpJj.mjs"; import { n as IdColumnCodec, r as IdGeneratingCodec } from "./adapter-types-B-GLKPOm.mjs"; import { n as IdsErrorCode, r as isIdsError, t as IdsError } from "./error-JLZfeGOx.mjs"; import { ConvertCustomConfig, PgCustomColumnBuilder } from "drizzle-orm/pg-core"; import { ConvertCustomConfig as ConvertCustomConfig$1, MySqlCustomColumnBuilder } from "drizzle-orm/mysql-core"; import { ConvertCustomConfig as ConvertCustomConfig$2, SQLiteCustomColumnBuilder } from "drizzle-orm/sqlite-core"; import { HasDefault, HasRuntimeDefault } from "drizzle-orm/column-builder"; //#region src/adapters/drizzle.d.ts /** * Drizzle custom column type that stores an `Id` as a canonical SQL string value in PostgreSQL. * * **Write path:** validates the value via `codec.safeParse` and throws * `IdsError("invalid_id")` if validation fails. * * **Read path:** normalises the raw DB string via `codec.safeParse()`, not strict * `is()`. Data at rest should already be canonical per ADR-0003, but `safeParse` * is a safe boundary in case stale non-canonical values exist. Throws if the * value from the database does not parse as a valid `Id`. * * @param codec - The brand-scoped codec used to parse values read from the database. * @param options - Optional column configuration. * @param options.columnType - SQL column type to use (default: `"text"`). Pass * `"varchar(30)"` or `"char(26)"` to match an existing DDL or index strategy. * The value is passed through verbatim — no validation is performed. * * @example * ```ts * import { idColumn } from "@smonn/ids/drizzle"; * import { createTimestampId } from "@smonn/ids"; * * const usr = createTimestampId("usr"); * // default: text column * export const users = pgTable("users", { id: idColumn(usr).primaryKey() }); * // explicit varchar column * export const orgs = pgTable("orgs", { id: idColumn(usr, { columnType: "varchar(30)" }).primaryKey() }); * ``` */ declare function idColumn(codec: IdColumnCodec, options?: { columnType?: string; }): PgCustomColumnBuilder; driverData: string; }>>; /** * Drizzle custom column type that stores an `Id` as a canonical `text` value in MySQL. * * **Write path:** validates the value via `codec.safeParse` and throws * `IdsError("invalid_id")` if validation fails. * * **Read path:** normalises the raw DB string via `codec.safeParse()`, not strict * `is()`. Throws `IdsError("invalid_id")` if the value from the database does not * parse as a valid `Id`. * * @example * ```ts * import { idColumnMysql } from "@smonn/ids/drizzle"; * import { createTimestampId } from "@smonn/ids"; * * const usr = createTimestampId("usr"); * export const users = mysqlTable("users", { id: idColumnMysql(usr).primaryKey() }); * // users.id is Id<"usr"> end-to-end * ``` */ declare function idColumnMysql(codec: IdColumnCodec): MySqlCustomColumnBuilder; driverData: string; }>>; /** * Drizzle custom column type that stores an `Id` as a canonical `text` value in SQLite. * * **Write path:** validates the value via `codec.safeParse` and throws * `IdsError("invalid_id")` if validation fails. * * **Read path:** normalises the raw DB string via `codec.safeParse()`, not strict * `is()`. Throws `IdsError("invalid_id")` if the value from the database does not * parse as a valid `Id`. * * @example * ```ts * import { idColumnSqlite } from "@smonn/ids/drizzle"; * import { createTimestampId } from "@smonn/ids"; * * const usr = createTimestampId("usr"); * export const users = sqliteTable("users", { id: idColumnSqlite(usr).primaryKey() }); * // users.id is Id<"usr"> end-to-end * ``` */ declare function idColumnSqlite(codec: IdColumnCodec): SQLiteCustomColumnBuilder; driverData: string; }>>; /** * Drizzle custom column type for a **nullable** `Id` column. * * Behaves identically to {@link idColumn} except that `null` and `undefined` * driver values are passed through as `null` rather than throwing. Use for * optional foreign keys, `LEFT JOIN` results, and any column that is * legitimately absent. * * **There is no `generatedNullableIdColumn`.** A column that auto-generates its own ID should * never be null at write time — that is the entire purpose of the generated variant. A nullable * column is one that the caller explicitly sets to `null`; it cannot simultaneously be * auto-generated. Use {@link nullableIdColumn} for optional foreign keys and {@link generatedIdColumn} * for primary keys that must always be present. The same reasoning applies to the MySQL and * SQLite equivalents ({@link nullableIdColumnMysql}, {@link nullableIdColumnSqlite}). * * @param codec - The brand-scoped codec used to parse values read from the database. * @param options - Optional column configuration. * @param options.columnType - SQL column type to use (default: `"text"`). Pass * `"varchar(30)"` or `"char(26)"` to match an existing DDL or index strategy. * The value is passed through verbatim — no validation is performed. * * @example * ```ts * import { nullableIdColumn } from "@smonn/ids/drizzle"; * import { createTimestampId } from "@smonn/ids"; * * const usr = createTimestampId("usr"); * // default: text column * export const posts = pgTable("posts", { * authorId: nullableIdColumn(usr), * }); * // posts.authorId is Id<"usr"> | null end-to-end * * // explicit char column * export const comments = pgTable("comments", { * authorId: nullableIdColumn(usr, { columnType: "char(26)" }), * }); * ``` */ declare function nullableIdColumn(codec: IdColumnCodec, options?: { columnType?: string; }): PgCustomColumnBuilder | null; driverData: string | null; }>>; /** * Drizzle custom column type for a **nullable** `Id` column in MySQL. * * Behaves identically to {@link idColumnMysql} except that `null` and `undefined` * driver values are passed through as `null` rather than throwing. Use for * optional foreign keys, `LEFT JOIN` results, and any column that is * legitimately absent. * * Column type is always `text` and cannot be overridden in MySQL. * * @param codec - The brand-scoped codec used to parse values read from the database. * * @example * ```ts * import { nullableIdColumnMysql } from "@smonn/ids/drizzle"; * import { createTimestampId } from "@smonn/ids"; * * const usr = createTimestampId("usr"); * export const posts = mysqlTable("posts", { * authorId: nullableIdColumnMysql(usr), * }); * // posts.authorId is Id<"usr"> | null end-to-end * ``` */ declare function nullableIdColumnMysql(codec: IdColumnCodec): MySqlCustomColumnBuilder | null; driverData: string | null; }>>; /** * Drizzle custom column type for a **nullable** `Id` column in SQLite. * * Behaves identically to {@link idColumnSqlite} except that `null` and `undefined` * driver values are passed through as `null` rather than throwing. Use for * optional foreign keys, `LEFT JOIN` results, and any column that is * legitimately absent. * * Column type is always `text` and cannot be overridden in SQLite. * * @param codec - The brand-scoped codec used to parse values read from the database. * * @example * ```ts * import { nullableIdColumnSqlite } from "@smonn/ids/drizzle"; * import { createTimestampId } from "@smonn/ids"; * * const usr = createTimestampId("usr"); * export const posts = sqliteTable("posts", { * authorId: nullableIdColumnSqlite(usr), * }); * // posts.authorId is Id<"usr"> | null end-to-end * ``` */ declare function nullableIdColumnSqlite(codec: IdColumnCodec): SQLiteCustomColumnBuilder | null; driverData: string | null; }>>; /** * Drizzle custom column type that stores an `Id` as a canonical SQL string value * in PostgreSQL, with a client-side `.$defaultFn` so inserts that omit the field receive * a freshly generated ID automatically. * * **Write path:** `.$defaultFn(() => codec.generate())` is wired — if the field is absent * on insert, Drizzle calls `codec.generate()` to produce a new `Id`. * * **Read path:** normalises the raw DB string via `codec.safeParse()`, not strict `is()`. * Throws `IdsError("invalid_id")` if the value from the database does not parse as a * valid `Id`. * * Requires a codec that exposes synchronous `generate()` — see {@link IdGeneratingCodec}. * Only the **Timestamp codec** and **Reverse Timestamp codec** qualify; Opaque, Signed, * Wrapped, and Digest codecs are a compile-time error. * * @param codec - The brand-scoped codec used to generate and parse values. * @param options - Optional column configuration. * @param options.columnType - SQL column type to use (default: `"text"`). Pass * `"varchar(30)"` or `"char(26)"` to match an existing DDL or index strategy. * The value is passed through verbatim — no validation is performed. * * @example * ```ts * import { generatedIdColumn } from "@smonn/ids/drizzle"; * import { createTimestampId } from "@smonn/ids"; * * const usr = createTimestampId("usr"); * export const users = pgTable("users", { id: generatedIdColumn(usr).primaryKey() }); * // id is auto-filled on insert — no hand-supplied id needed * ``` */ declare function generatedIdColumn(codec: IdGeneratingCodec, options?: { columnType?: string; }): HasRuntimeDefault; driverData: string; }>>>>; /** * Drizzle custom column type that stores an `Id` as a canonical `text` value * in MySQL, with a client-side `.$defaultFn` so inserts that omit the field receive * a freshly generated ID automatically. * * **Write path:** `.$defaultFn(() => codec.generate())` is wired — if the field is absent * on insert, Drizzle calls `codec.generate()` to produce a new `Id`. * * **Read path:** normalises the raw DB string via `codec.safeParse()`, not strict `is()`. * Throws `IdsError("invalid_id")` if the value from the database does not parse as a * valid `Id`. * * Requires a codec that exposes synchronous `generate()` — see {@link IdGeneratingCodec}. * Only the **Timestamp codec** and **Reverse Timestamp codec** qualify; Opaque, Signed, * Wrapped, and Digest codecs are a compile-time error. * * @param codec - The brand-scoped codec used to generate and parse values. * @param options - Optional column configuration. * @param options.columnType - SQL column type to use (default: `"text"`). Pass * `"varchar(30)"` or `"char(26)"` to match an existing DDL or index strategy. * The value is passed through verbatim — no validation is performed. * * @example * ```ts * import { generatedIdColumnMysql } from "@smonn/ids/drizzle"; * import { createTimestampId } from "@smonn/ids"; * * const usr = createTimestampId("usr"); * export const users = mysqlTable("users", { id: generatedIdColumnMysql(usr).primaryKey() }); * // id is auto-filled on insert — no hand-supplied id needed * ``` */ declare function generatedIdColumnMysql(codec: IdGeneratingCodec, options?: { columnType?: string; }): HasRuntimeDefault; driverData: string; }>>>>; /** * Drizzle custom column type that stores an `Id` as a canonical `text` value * in SQLite, with a client-side `.$defaultFn` so inserts that omit the field receive * a freshly generated ID automatically. * * **Write path:** `.$defaultFn(() => codec.generate())` is wired — if the field is absent * on insert, Drizzle calls `codec.generate()` to produce a new `Id`. * * **Read path:** normalises the raw DB string via `codec.safeParse()`, not strict `is()`. * Throws `IdsError("invalid_id")` if the value from the database does not parse as a * valid `Id`. * * Requires a codec that exposes synchronous `generate()` — see {@link IdGeneratingCodec}. * Only the **Timestamp codec** and **Reverse Timestamp codec** qualify; Opaque, Signed, * Wrapped, and Digest codecs are a compile-time error. * * @param codec - The brand-scoped codec used to generate and parse values. * @param options - Optional column configuration. * @param options.columnType - SQL column type to use (default: `"text"`). Pass * `"varchar(30)"` or `"char(26)"` to match an existing DDL or index strategy. * The value is passed through verbatim — no validation is performed. * * @example * ```ts * import { generatedIdColumnSqlite } from "@smonn/ids/drizzle"; * import { createTimestampId } from "@smonn/ids"; * * const usr = createTimestampId("usr"); * export const users = sqliteTable("users", { id: generatedIdColumnSqlite(usr).primaryKey() }); * // id is auto-filled on insert — no hand-supplied id needed * ``` */ declare function generatedIdColumnSqlite(codec: IdGeneratingCodec, options?: { columnType?: string; }): HasRuntimeDefault; driverData: string; }>>>>; //#endregion export { type IdColumnCodec, type IdGeneratingCodec, IdsError, type IdsErrorCode, generatedIdColumn, generatedIdColumnMysql, generatedIdColumnSqlite, idColumn, idColumnMysql, idColumnSqlite, isIdsError, nullableIdColumn, nullableIdColumnMysql, nullableIdColumnSqlite }; //# sourceMappingURL=drizzle.d.mts.map