pg-to-ts
Version:
Generate TypeScript-friendly interfaces and constants from (postgres) SQL database schema
21 lines (20 loc) • 1.01 kB
TypeScript
/**
* Generate typescript interface from table schema
* Created by xiamx on 2016-08-10.
*/
import { TableDefinition } from './schemaInterfaces';
import Options from './options';
export interface TableNames {
var: string;
type: string;
input: string;
}
/**
* generateTableInterface() leaves some references to be filled in later, when a more complete
* picture of the schema is available. This fills those references in:
* 'null as unknown /* users *\/' --> 'null as unknown as Users'.
*/
export declare function attachJoinTypes(tableTs: string, tableToNames: Record<string, TableNames>): string;
/** Returns [Table TypeScript, output variable name, set of TS types to import] */
export declare function generateTableInterface(tableName: string, tableDefinition: TableDefinition, schemaName: string, options: Options): [code: string, names: TableNames, typesToImport: Set<string>];
export declare function generateEnumType(enumObject: Record<string, string[]>, options: Options): string;