import { PgSmartTagTags } from 'graphile-utils'; import { BaseSmartTags } from './base-smart-tags'; import { PgColumn } from './pg-column'; import { PgFkColumn } from './pg-fk-column'; // TODO: Consider adding a separate property for FKs for consistency. /** * Abstraction over a Postgres table. */ export interface PgTable { /** Name of the table. */ name: string; /** Optional display name to override the `name` in the generated GQL API. */ displayName?: string; /** Description of the table. */ readonly description?: string; /** Table's PK */ readonly pk: PgColumn; /** FKs to other tables. */ readonly fks: PgFkColumn[]; /** Virtual FKs to other tables (PostGraphile-specific). */ readonly virtualFks: PgFkColumn[]; /** Array of regular 'data' columns in the table. */ readonly columns: PgColumn[]; /** Builds a fully qualified table name - [schema].[table_name]. */ buildFullName(): string; /** * Builds an (ordered) array of SQL statements required for creating a table. */ buildStatements(): string[]; /** * Builds additional smart tags for PostGraphile. */ buildSmartTags(): TableSmartTags; } export interface TableSmartTags { tags?: PgSmartTagTags; description?: string; attribute?: { [attributeName: string]: BaseSmartTags; }; constraint?: { [constraintName: string]: BaseSmartTags; }; }