/** * Abstract base class for a loaded table. One subclass per engine. * * Holds the normalized table identity and definition, plus the * engine-agnostic Layer 2 rules as concrete methods. Engine-specific rules * (column-type validity, partition semantics) are abstract — each subclass * implements them, which is the lever that lets new engines plug in without * editing scattered switches. The cross-file rules are concrete here too; * they take the world by an interface so the cycle between this module and * `./world` is kept at type-level only. */ import { TableDefinition, Violation } from './model'; import type { World } from './world'; /** Fields required to construct any concrete table subclass. */ export interface TableTypeFields { /** Owning schema name (the folder name). */ readonly schema: string; /** Table name (the file name without `.json`). */ readonly name: string; /** `schema.table` identifier. */ readonly qualifiedName: string; /** Absolute path to the source file. */ readonly filePath: string; /** Whether the file passed Layer 1 structural validation. */ readonly structurallyValid: boolean; /** Normalized definition. */ readonly definition: TableDefinition; } /** * Base class for all engine-specific table types. * * Subclasses implement `isValidColumnType` (the engine's type registry) and * `partitionViolations` (the engine's partition semantics). Everything else * — primary-key checks, dupes, raw consistency, depends-on resolution, * foreign-key checks — is identical across engines and lives here. */ export declare abstract class TableTypeBase { /** Owning schema name. */ readonly schema: string; /** Table name. */ readonly name: string; /** `schema.table` identifier. */ readonly qualifiedName: string; /** Absolute path to the source file. */ readonly filePath: string; /** Whether the file passed Layer 1 structural validation. */ readonly structurallyValid: boolean; /** Normalized definition. */ readonly definition: TableDefinition; /** * Construct a table instance from the normalized fields produced by the * loader. * * @param fields The table identity plus its parsed, normalized definition. */ constructor(fields: TableTypeFields); /** * Build a violation pre-filled with this table's location fields. * * @param partial The fields specific to the rule firing (code, level, message, field). * @returns A full `Violation` with `schema`, `table`, and `path` set. */ protected violation(partial: Omit): Violation; /** * Whether this table declares a data column with the given name. * * @param name Column name to look up. * @returns True when `name` matches any column in `definition.columns`. */ protected hasColumn(name: string): boolean; /** * Find names that appear more than once in a list, preserving the order * of first duplication. * * @param names Names to scan. * @returns Duplicated names, each listed once. */ protected findDuplicates(names: string[]): string[]; /** * Whether `type` is a valid column-type string for this engine. * * @param type Column type string to check. * @returns True when the engine accepts the type. */ abstract isValidColumnType(type: string): boolean; /** * Engine-specific partition rules: duplicate detection plus the engine's * key/column resolution and type / transform / strategy legality. * * @returns Every partition-related violation this table produces. */ abstract partitionViolations(): Violation[]; /** * Engine-specific intra-table rules beyond column-type and partition checks * (e.g. Iceberg format-version / table properties, Postgres indexes). The * base engine has none; subclasses override to add them. * * @returns Engine-specific intra-table violations. Empty by default. */ engineSpecificViolations(): Violation[]; private primaryKeyViolations; private duplicateColumnViolations; private columnTypeViolations; /** * Diagnose a single column's type. The default emits a generic * `COLUMN_TYPE_VALID` error when the engine rejects the type. Engines whose * type grammar yields structured failures (Iceberg nested types) override * this to emit a precise code instead. * * @param type Column type string. * @param name Column name, for the message. * @param index Column index, for the `field` path. * @returns A violation, or null when the type is valid. */ protected columnTypeViolation(type: string, name: string, index: number): Violation | null; private rawConsistencyViolations; private nullabilityViolations; /** * All intra-table violations for this table (engine-agnostic rules plus * the engine-specific partition rules). * * @returns Every intra-table violation this table produces. */ intraTableViolations(): Violation[]; private dependsOnViolations; private foreignKeyViolations; /** * All cross-file violations for this table (`dependsOn` resolution plus * the full foreign-key suite). * * @param world The loaded dataset root. * @returns Every cross-file violation this table produces. */ crossFileViolations(world: World): Violation[]; }