import type { EntityPhrase } from './dictionary.js'; import type { CollectionSchemaBase, EnumDef, Field } from './dsl.js'; export type Index = { name?: string; columns: Field | Field[]; unique?: boolean; }; export type ForeignKey = { columns: Field | Field[]; references: Field | Field[]; }; export interface TableSchemaOptions = Record, E extends Record = Record> { description?: string; paginated: boolean; actor?: boolean; generator?: string; autoIncrement?: Field; /** 本表用于关联显示的名称字段(如 name / username)。被外键引用时,自动用该字段做 label 展示。 */ label?: Field; /** Optimistic lock version column: updates auto-manage `version = version + 1` * and `WHERE version = ?` (value taken from the row). Must be an integer column. */ version?: Field; primaryKey?: Field | Field[]; indexes?: Index[]; foreignKeys?: Record; /** 引用的实体短语(词典条目):本表归属的实体;关联表等多实体场景不需要 */ phrase?: EntityPhrase; /** 本表引用的所有枚举定义(map,key 为枚举标识),显式声明供 gen-enums 收集 */ enums: E; columns: C; } export declare class TableSchema = Record, E extends Record = Record> implements CollectionSchemaBase { type: string; name: N; description?: string; /** 分页 */ paginated: boolean; /** 系统操作者(如小程序为 C 端用户,管理端为运营) */ actor?: boolean; /** id 生成器 */ generator?: string; /** 自增主键字段 */ autoIncrement?: Field; primaryKey?: Field | Field[]; indexes?: Index[]; /** 外键,引用其他表的字段 */ foreignKeys?: Record; /** 本表用于关联显示的名称字段(如 name / username)。被外键引用时,自动用该字段做 label 展示。 */ label?: Field; /** Optimistic lock version column: updates auto-manage `version = version + 1` * and `WHERE version = ?` (value taken from the row). Must be an integer column. */ version?: Field; /** 引用的实体短语(词典条目):本表归属的实体;关联表等多实体场景不需要 */ phrase?: EntityPhrase; /** 本表引用的所有枚举定义(map,key 为枚举标识),显式声明供 gen-enums 收集 */ enums: E; columns: C; constructor(name: N, options: TableSchemaOptions); /** True when the field is part of this table's primary key */ isPk(fieldRef: Field): boolean; } export declare function defineTable, E extends Record = Record>(name: N, schema: TableSchemaOptions): TableSchema;