/** * Central schema management utility for rawsql-ts. * Converts user-defined table definitions into resolvers consumed by collectors and builders. * * @example * ```typescript * const manager = new SchemaManager({ * users: { * name: 'users', * columns: { * id: { name: 'id', isPrimaryKey: true }, * email: { name: 'email' } * } * } * }); * * const resolver = manager.createTableColumnResolver(); * const collector = new SchemaCollector(resolver); * const schemas = collector.collect(SelectQueryParser.parse('SELECT * FROM users')); * ``` * Related tests: packages/core/tests/transformers/SchemaCollector.test.ts */ /** * Database column metadata for schema mapping */ export interface ColumnDefinition { /** Column name in database */ name: string; /** Primary key indicator - used for UPDATE/DELETE query WHERE conditions */ isPrimaryKey?: boolean; /** Foreign key reference */ foreignKey?: { table: string; column: string; }; } /** * Table relationship definition */ export interface RelationshipDefinition { /** Type of relationship */ type: 'object' | 'array'; /** Target table name */ table: string; /** Caller-owned relationship property name */ propertyName: string; /** Optional: Override target table's primary key */ targetKey?: string; } /** * Complete table schema definition that users write */ export interface TableDefinition { /** Table name in database */ name: string; /** Human-readable entity name */ displayName?: string; /** Column definitions */ columns: Record; /** Relationships with other tables */ relationships?: RelationshipDefinition[]; } /** * Schema registry containing all table definitions */ export interface SchemaRegistry { [tableName: string]: TableDefinition; } /** * Central schema management utility for rawsql-ts * Converts user-defined schemas to resolvers consumed by schema-aware utilities */ export declare class SchemaManager { private schemas; constructor(schemas: SchemaRegistry); /** * Validate schema definitions for consistency * Ensures each table has a primary key (required for UPDATE/DELETE operations) * and validates relationship references */ private validateSchemas; /** * Get table column names for SqlParamInjector TableColumnResolver * @param tableName Name of the table * @returns Array of column names */ getTableColumns(tableName: string): string[]; /** * Create TableColumnResolver function for SqlParamInjector * @returns Function compatible with SqlParamInjector */ createTableColumnResolver(): (tableName: string) => string[]; /** * Get all table names in the schema * @returns Array of table names */ getTableNames(): string[]; /** * Get table definition by name * @param tableName Name of the table * @returns Table definition or undefined */ getTable(tableName: string): TableDefinition | undefined; /** * Get primary key column name for a table * Used by QueryBuilder.buildUpdateQuery for WHERE clause conditions * @param tableName Name of the table * @returns Primary key column name or undefined */ getPrimaryKey(tableName: string): string | undefined; /** * Get foreign key relationships for a table * @param tableName Name of the table * @returns Array of foreign key relationships */ getForeignKeys(tableName: string): Array<{ column: string; referencedTable: string; referencedColumn: string; }>; } /** * Create a SchemaManager instance from schema definitions * @param schemas Schema registry object * @returns SchemaManager instance */ export declare function createSchemaManager(schemas: SchemaRegistry): SchemaManager; /** * Create TableColumnResolver function from schema definitions * @param schemas Schema registry object * @returns TableColumnResolver function for SqlParamInjector */ export declare function createTableColumnResolver(schemas: SchemaRegistry): (tableName: string) => string[];