import type { ColumnSpec, ColumnStorageType, EmbeddingSource, TableSpec, IndexSpec, ForeignKeySpec, UniqueSpec, CheckSpec } from './types.js'; import type { DefaultValue } from './defaults.js'; export type ColumnOptions = { id?: number; nullable?: boolean; primaryKey?: boolean; default?: DefaultValue; generated?: 'uuid' | 'now'; enumValues?: string[]; check?: (value: unknown) => boolean | string; min?: number; max?: number; minLength?: number; maxLength?: number; regex?: RegExp; /** Embedding generation source (only for `embedding` columns). */ embeddingSource?: EmbeddingSource; /** Encrypt this column's payload at rest (requires an encrypted database). */ encrypted?: boolean; /** Encrypt but keep queryable via deterministic tokens (encrypted database). */ encryptedIndexable?: boolean; }; type OptsNull = TOpts extends { nullable: true; } ? true : false; type OptsDefault = TOpts extends { default: infer D; } ? Exclude : null; type OptsGenerated = TOpts extends { generated: infer G; } ? Exclude : null; export declare function column(name: TName, storageType: TApp, opts?: TOpts): ColumnSpec, OptsDefault, OptsGenerated>; export declare function int(name: TName, opts?: TOpts): ColumnSpec, OptsDefault, OptsGenerated>; export declare function text(name: TName, opts?: TOpts): ColumnSpec, OptsDefault, OptsGenerated>; export declare function real(name: TName, opts?: TOpts): ColumnSpec, OptsDefault, OptsGenerated>; export declare function bool(name: TName, opts?: TOpts): ColumnSpec, OptsDefault, OptsGenerated>; export declare function json(name: TName, opts?: TOpts): ColumnSpec, OptsDefault, OptsGenerated>; export declare function timestamp(name: TName, opts?: TOpts): ColumnSpec, OptsDefault, OptsGenerated>; export declare function date(name: TName, opts?: TOpts): ColumnSpec, OptsDefault, OptsGenerated>; export declare function blob(name: TName, opts?: TOpts): ColumnSpec, OptsDefault, OptsGenerated>; /** Millisecond-precision date (days since epoch × 86400000). */ export declare function date64(name: TName, opts?: TOpts): ColumnSpec, OptsDefault, OptsGenerated>; /** Nanosecond-precision time-of-day (no date component). */ export declare function time64(name: TName, opts?: TOpts): ColumnSpec, OptsDefault, OptsGenerated>; /** SQL INTERVAL (months + days + nanoseconds). */ export declare function intervalCol(name: TName, opts?: TOpts): ColumnSpec, OptsDefault, OptsGenerated>; /** Fixed-point decimal (i128 unscaled value, precision, scale). */ export declare function decimal128(name: TName, opts?: TOpts): ColumnSpec, OptsDefault, OptsGenerated>; /** RFC 4122 UUID (16 bytes, big-endian for sort order). */ export declare function uuid(name: TName, opts?: TOpts): ColumnSpec, OptsDefault, OptsGenerated>; /** Native JSON value (parsed, validated, typed as JSON at the storage level). */ export declare function jsonNative(name: TName, opts?: TOpts): ColumnSpec, OptsDefault, OptsGenerated>; /** Variable-length array of homogeneous values (e.g. int[], text[]). */ export declare function arrayCol(name: TName, opts?: TOpts): ColumnSpec, OptsDefault, OptsGenerated>; /** A dense float-vector column of dimension `dim` for ANN (`annSearch`). * * Optional `embeddingSource` records how vectors are produced. * Default / omit = application-supplied. `generated_column_spec` materializes * transactionally when the runtime has the named provider. */ export declare function embedding(name: TName, dim: number, opts?: TOpts): ColumnSpec, OptsDefault, OptsGenerated>; /** Serialize kit `EmbeddingSource` to the snake_case JSON shape used by kit-core. */ export declare function embeddingSourceToJson(source: EmbeddingSource): Record; /** A learned-sparse (SPLADE) token-vector column for `sparseMatch`. */ export declare function sparse(name: TName, opts?: TOpts): ColumnSpec, OptsDefault, OptsGenerated>; export interface IndexOptions { name?: string; unique?: boolean; /** Create an FM substring index so `contains()` pushes down to the engine. */ fm?: boolean; /** Create an ANN index on an embedding column for `annSearch()`. */ ann?: boolean; /** ANN representation. `dense` preserves f32 vectors and ranks by cosine * distance. `product` selects product quantization (requires * `annPqNumSubvectors`). */ annQuantization?: 'binary_sign' | 'dense' | 'product'; /** ANN graph/structure algorithm. Defaults to `hnsw`. Orthogonal to * `annQuantization`. */ annAlgorithm?: 'hnsw' | 'diskann' | 'ivf'; /** Optional SQL predicate for a partial index. */ predicate?: string; /** HNSW graph degree. */ annM?: number; /** HNSW construction search width. */ annEfConstruction?: number; /** HNSW query search width. */ annEfSearch?: number; /** DiskANN max graph degree R. */ annDiskannR?: number; /** DiskANN build search-list size L. */ annDiskannL?: number; /** DiskANN query beam width. */ annDiskannBeamWidth?: number; /** DiskANN robust-prune alpha × 100 (120 = 1.2). */ annDiskannAlpha?: number; /** IVF inverted-list (centroid) count. */ annIvfNlist?: number; /** IVF probe count at query time. */ annIvfNprobe?: number; /** IVF k-means training sample cap. */ annIvfTrainingSamples?: number; /** Product-quantizer training sample cap. */ annPqTrainingSamples?: number; /** Product-quantizer deterministic training seed. */ annPqSeed?: number; /** Product-quantizer exact-rerank factor (0 disables). */ annPqRerankFactor?: number; /** Product-quantization sub-vector count (required when * `annQuantization: 'product'`). */ annPqNumSubvectors?: number; /** Product-quantization codebook bit width (default 8). */ annPqBits?: number; /** Create a sparse (SPLADE) index on a sparse column for `sparseMatch()`. */ sparse?: boolean; /** Create a MinHash/LSH set-similarity index to accelerate `setSimilarity()`. */ minhash?: boolean; minhashPermutations?: number; minhashBands?: number; /** Create a learned-range (PGM zonemap) index to accelerate range predicates * (`gt`/`gte`/`lt`/`lte`) on numeric/timestamp columns. */ learnedRange?: boolean; learnedRangeEpsilon?: number; } export interface UniqueOptions { name?: string; } export interface ForeignKeyOptions { name?: string; onDelete?: ForeignKeySpec['onDelete']; } export interface ForeignKeyReference { table: string; columns: string[]; } export declare function index(columns: string[], opts?: IndexOptions): IndexSpec; export declare function unique(columns: string[], opts?: UniqueOptions): UniqueSpec; export declare function foreignKey(columns: string[], references: ForeignKeyReference, opts?: ForeignKeyOptions): ForeignKeySpec; export declare function check(name: string, expr: CheckSpec['expr']): CheckSpec; export interface TableOptions { id?: number; columns: TColumns; primaryKey: string | string[]; indexes?: IndexSpec[]; foreignKeys?: ForeignKeySpec[]; unique?: UniqueSpec[]; checks?: CheckSpec[]; } type ColumnMap = { [K in TColumns[number] as K['name'] extends keyof TableSpec ? never : K['name']]: K; }; export declare function table(name: string, options: TableOptions): TableSpec & ColumnMap; export declare class Schema { private readonly byName; private readonly byId; constructor(tables: TableSpec[]); tablesList(): TableSpec[]; table(name: string): TableSpec; hasTable(name: string): boolean; } export {}; //# sourceMappingURL=schema.d.ts.map