@dbml/connector
Version:
This package was created to fetch the schema JSON from many kind of databases.
96 lines (95 loc) • 2.18 kB
TypeScript
interface NoteInfo {
value: string;
}
interface TypeInfo {
type_name: string;
schemaName: string | null;
}
type DefaultType = 'string' | 'number' | 'boolean' | 'expression';
interface DefaultInfo {
type: DefaultType;
value: string;
}
interface Field {
name: string;
type: TypeInfo;
dbdefault: DefaultInfo | null;
not_null: boolean;
increment: boolean;
pk?: boolean;
unique?: boolean;
note: NoteInfo;
}
interface Table {
name: string;
schemaName: string;
note: NoteInfo;
}
interface FieldsDictionary {
[key: string]: Field[];
}
interface TableConstraint {
[fieldName: string]: {
pk?: boolean;
unique?: boolean;
};
}
interface TableConstraintsDictionary {
[tableIdentifier: string]: TableConstraint;
}
interface RefEndpoint {
tableName: string;
schemaName: string;
fieldNames: string[];
relation: '*' | '1';
}
interface Ref {
name: string;
endpoints: RefEndpoint[];
onDelete: string | null;
onUpdate: string | null;
}
interface EnumValue {
name: string;
}
interface Enum {
name: string;
schemaName: string;
values: EnumValue[];
}
interface IndexColumn {
type: 'column' | 'expression';
value: string;
}
interface Index {
name: string;
type: string;
unique?: boolean;
pk?: boolean;
columns: IndexColumn[];
}
interface IndexesDictionary {
[tableIdentifier: string]: Index[];
}
interface DatabaseSchema {
tables: Table[];
fields: FieldsDictionary;
enums: Enum[];
tableConstraints: TableConstraintsDictionary;
refs: Ref[];
indexes: IndexesDictionary;
}
interface BigQueryCredentials {
projectId: string;
credentials: {
clientEmail: string;
privateKey: string;
};
datasets: string[];
}
interface EnumValuesDict {
columns: string[];
enumValues: EnumValue[];
constraint_name: string;
}
export { NoteInfo, TypeInfo, DefaultType, DefaultInfo, Field, Table, FieldsDictionary, TableConstraint, TableConstraintsDictionary, RefEndpoint, Ref, EnumValue, Enum, IndexColumn, Index, IndexesDictionary, DatabaseSchema, BigQueryCredentials, EnumValuesDict, };