import { ColumnType } from '../types/column-types'; import { TypeMapper } from '../types/type-mapper'; import { CollationDefinition } from '../types/collation-builder'; /** * Identity column options */ export interface IdentityOptions { /** Sequence name (defaults to {table}_{column}_seq) */ name?: string; /** Start value for the sequence */ startWith?: number; /** Increment value */ incrementBy?: number; } /** * Column configuration */ export interface ColumnConfig { name: string; type: ColumnType; nullable: boolean; primaryKey: boolean; autoIncrement: boolean; unique: boolean; default?: any; length?: number; precision?: number; scale?: number; references?: { table: string; column: string; }; mapper?: TypeMapper; /** GENERATED ALWAYS AS IDENTITY configuration */ identity?: IdentityOptions; /** PostgreSQL ENUM type name */ enumTypeName?: string; /** PostgreSQL COLLATION name */ collation?: string; /** * Set when the column participates in an `ixNormalized` index. A transferable * hint (mirrored from the entity metadata) that the column has an * accent/case-insensitive `search_normalize()` index available. */ hasNormalizedIndex?: boolean; } /** * Column builder - fluent API for defining columns */ export declare class ColumnBuilder { protected config: Partial; constructor(name: string, type: ColumnType); /** * Mark column as NOT NULL */ notNull(): this; /** * Mark column as PRIMARY KEY */ primaryKey(): this; /** * Mark column as AUTO INCREMENT */ autoIncrement(): this; /** * Mark column as GENERATED ALWAYS AS IDENTITY (modern PostgreSQL identity columns) * This is the preferred way over serial/bigserial for auto-incrementing primary keys */ generatedAlwaysAsIdentity(options?: IdentityOptions): this; /** * Mark column as UNIQUE */ unique(): this; /** * Set default value */ default(value: any): this; /** * Set column length (for varchar, char) */ length(value: number): this; /** * Set precision and scale (for decimal, numeric) */ precision(precision: number, scale?: number): this; /** * Define foreign key reference */ references(table: string, column?: string): this; /** * Set custom type mapper for bidirectional transformation */ mapWith(mapper: TypeMapper): ColumnBuilder; /** * Convert this column to a PostgreSQL array type * * @example * // integer[] column * entity.property(e => e.permissions).hasType(integer('permissions').array()); * * // text[] column * entity.property(e => e.tags).hasType(text('tags').array()); */ array(): ColumnBuilder; /** * Override the TypeScript type for this column * * @example * // integer column typed as ADMIN_PERMISSION[] * entity.property(e => e.permissions).hasType(integer('permissions').array().hasTypescriptType()); */ hasTypescriptType(): ColumnBuilder; /** * Set the collation for this column */ hasCollation(collation: CollationDefinition): this; /** * Mark that this column has an `ixNormalized` (search_normalize) index. * Called internally when an index referencing this column is declared. * @internal */ markNormalizedIndex(): this; /** * Get the final column configuration */ build(): ColumnConfig; } /** * Column factory functions */ export declare const integer: (name: string) => ColumnBuilder; export declare const serial: (name: string) => ColumnBuilder; export declare const bigint: (name: string) => ColumnBuilder; export declare const bigserial: (name: string) => ColumnBuilder; export declare const smallint: (name: string) => ColumnBuilder; export declare const decimal: (name: string, precision?: number, scale?: number) => ColumnBuilder; export declare const numeric: (name: string, precision?: number, scale?: number) => ColumnBuilder; export declare const real: (name: string) => ColumnBuilder; export declare const doublePrecision: (name: string) => ColumnBuilder; export declare const varchar: (name: string, length?: number) => ColumnBuilder; export declare const char: (name: string, length?: number) => ColumnBuilder; export declare const text: (name: string) => ColumnBuilder; export declare const boolean: (name: string) => ColumnBuilder; export declare const timestamp: (name: string) => ColumnBuilder; export declare const timestamptz: (name: string) => ColumnBuilder; export declare const date: (name: string) => ColumnBuilder; export declare const time: (name: string) => ColumnBuilder; export declare const uuid: (name: string) => ColumnBuilder; export declare const json: (name: string) => ColumnBuilder; export declare const jsonb: (name: string) => ColumnBuilder; export declare const bytea: (name: string) => ColumnBuilder>; /** * Create an ENUM column * * @example * import { pgEnum, enumColumn } from 'linkgress-orm'; * * const statusEnum = pgEnum('order_status', ['pending', 'processing', 'completed', 'cancelled'] as const); * entity.property(e => e.status).hasType(enumColumn('status', statusEnum)); */ export declare function enumColumn(columnName: string, enumDef: T): ColumnBuilder; //# sourceMappingURL=column-builder.d.ts.map