@dbml/core 2.2.0 → 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/export/DbmlExporter.js +15 -4
- package/lib/export/JsonExporter.js +1 -3
- package/lib/export/ModelExporter.js +1 -3
- package/lib/export/MysqlExporter.js +50 -42
- package/lib/export/PostgresExporter.js +64 -49
- package/lib/export/SqlServerExporter.js +52 -46
- package/lib/model_structure/database.js +73 -28
- package/lib/model_structure/dbState.js +1 -3
- package/lib/model_structure/element.js +13 -13
- package/lib/model_structure/endpoint.js +18 -14
- package/lib/model_structure/enum.js +18 -14
- package/lib/model_structure/enumValue.js +16 -12
- package/lib/model_structure/field.js +47 -13
- package/lib/model_structure/indexColumn.js +16 -12
- package/lib/model_structure/indexes.js +18 -14
- package/lib/model_structure/ref.js +19 -16
- package/lib/model_structure/schema.js +24 -36
- package/lib/model_structure/table.js +19 -15
- package/lib/model_structure/tableGroup.js +18 -14
- package/lib/model_structure/utils.js +5 -0
- package/lib/parse/Parser.js +2 -4
- package/lib/parse/buildParser.js +1 -3
- package/lib/parse/dbml/parser.pegjs +64 -20
- package/lib/parse/dbmlParser.js +1401 -899
- package/lib/parse/mssql/constraint_definition/actions.js +2 -2
- package/lib/parse/mssql/fk_definition/actions.js +10 -3
- package/lib/parse/mssql/keyword_parsers.js +0 -1
- package/lib/parse/mssql/statements/actions.js +9 -6
- package/lib/parse/mssql/statements/statement_types/alter_table/actions.js +11 -5
- package/lib/parse/mssql/statements/statement_types/create_index/actions.js +6 -1
- package/lib/parse/mssql/statements/statement_types/create_table/actions.js +12 -10
- package/lib/parse/mssql/utils.js +16 -1
- package/lib/parse/mysql/parser.pegjs +57 -34
- package/lib/parse/mysqlParser.js +270 -218
- package/lib/parse/postgresParser.js +12 -10
- package/lib/parse/postgresql/Base_rules.pegjs +45 -10
- package/lib/parse/postgresql/Commands/Alter_table/Alter_table.pegjs +2 -1
- package/lib/parse/postgresql/Commands/Create_table/Create_table_normal.pegjs +5 -3
- package/lib/parse/postgresql/Commands/Create_table/Create_table_of.pegjs +1 -1
- package/lib/parse/postgresql/Commands/Create_table/Create_table_partition_of.pegjs +1 -1
- package/lib/parse/postgresql/Commands/Create_type/Create_type_enum.pegjs +2 -2
- package/lib/parse/postgresql/InitializerUtils.pegjs +10 -0
- package/lib/parse/postgresql/parser.pegjs +2 -1
- package/lib/parse/schemarbParser.js +3 -3
- package/package.json +5 -3
- package/types/export/ModelExporter.d.ts +5 -0
- package/types/export/index.d.ts +5 -0
- package/types/import/index.d.ts +5 -0
- package/types/index.d.ts +5 -0
- package/types/model_structure/database.d.ts +195 -0
- package/types/model_structure/dbState.d.ts +14 -0
- package/types/model_structure/element.d.ts +21 -0
- package/types/model_structure/endpoint.d.ts +55 -0
- package/types/model_structure/enum.d.ts +67 -0
- package/types/model_structure/enumValue.d.ts +39 -0
- package/types/model_structure/field.d.ts +77 -0
- package/types/model_structure/indexColumn.d.ts +37 -0
- package/types/model_structure/indexes.d.ts +74 -0
- package/types/model_structure/ref.d.ts +66 -0
- package/types/model_structure/schema.d.ts +188 -0
- package/types/model_structure/table.d.ts +118 -0
- package/types/model_structure/tableGroup.d.ts +54 -0
- package/types/parse/Parser.d.ts +11 -0
- package/lib/export/Exporter.js +0 -80
- package/lib/export/SchemaExporter.js +0 -99
- package/lib/parse/dbml/multiline_content.txt +0 -7
- package/lib/parse/dbml/multiline_string.pegjs +0 -17
- package/lib/parse/dbml/parser1.json +0 -219
- package/lib/parse/dbml/parser1.pegjs +0 -702
- package/lib/parse/dbml/parser1_content.txt +0 -29
- package/lib/parse/dbml/test_multiline.js +0 -53
- package/lib/parse/dbml/test_parser1.js +0 -16
- package/lib/parse/mssql/base_utils.js +0 -28
- package/lib/parse/mssql/composite_parsers.js +0 -109
- package/lib/parse/mssql/statement_types/alter_table/actions.js +0 -29
- package/lib/parse/mssql/statement_types/alter_table/add/actions.js +0 -8
- package/lib/parse/mssql/statement_types/alter_table/add/index.js +0 -58
- package/lib/parse/mssql/statement_types/alter_table/index.js +0 -32
- package/lib/parse/mssql/statement_types/create_index/actions.js +0 -25
- package/lib/parse/mssql/statement_types/create_index/index.js +0 -50
- package/lib/parse/mssql/statement_types/create_table/actions.js +0 -95
- package/lib/parse/mssql/statement_types/create_table/index.js +0 -50
- package/lib/parse/mssql/statement_types/index.js +0 -13
- package/lib/schema/element.js +0 -84
- package/lib/schema/endpoint.js +0 -102
- package/lib/schema/enum.js +0 -102
- package/lib/schema/enumValue.js +0 -70
- package/lib/schema/field.js +0 -104
- package/lib/schema/indexes.js +0 -74
- package/lib/schema/ref.js +0 -93
- package/lib/schema/schema.js +0 -245
- package/lib/schema/table.js +0 -163
- package/lib/schema/tableGroup.js +0 -93
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { NormalizedDatabase } from './database';
|
|
2
|
+
import DbState from './dbState';
|
|
3
|
+
import Element, { Token } from './element';
|
|
4
|
+
import Enum from './enum';
|
|
5
|
+
interface RawEnumValue {
|
|
6
|
+
name: string;
|
|
7
|
+
token: Token;
|
|
8
|
+
note: string;
|
|
9
|
+
_enum: Enum;
|
|
10
|
+
}
|
|
11
|
+
declare class EnumValue extends Element {
|
|
12
|
+
name: string;
|
|
13
|
+
note: string;
|
|
14
|
+
_enum: Enum;
|
|
15
|
+
dbState: DbState;
|
|
16
|
+
constructor({ name, token, note, _enum }: RawEnumValue);
|
|
17
|
+
generateId(): void;
|
|
18
|
+
export(): {
|
|
19
|
+
name: string;
|
|
20
|
+
note: string;
|
|
21
|
+
};
|
|
22
|
+
exportParentIds(): {
|
|
23
|
+
enumId: number;
|
|
24
|
+
};
|
|
25
|
+
shallowExport(): {
|
|
26
|
+
name: string;
|
|
27
|
+
note: string;
|
|
28
|
+
};
|
|
29
|
+
normalize(model: NormalizedDatabase): void;
|
|
30
|
+
}
|
|
31
|
+
export interface NormalizedEnumValue {
|
|
32
|
+
[_id: number]: {
|
|
33
|
+
id: number;
|
|
34
|
+
name: string;
|
|
35
|
+
note: string;
|
|
36
|
+
enumId: number;
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
export default EnumValue;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { NormalizedDatabase } from './database';
|
|
2
|
+
import DbState from './dbState';
|
|
3
|
+
import Element, { Token } from './element';
|
|
4
|
+
import Endpoint from './endpoint';
|
|
5
|
+
import Enum from './enum';
|
|
6
|
+
import Table from './table';
|
|
7
|
+
interface RawField {
|
|
8
|
+
name: string;
|
|
9
|
+
type: any;
|
|
10
|
+
unique: boolean;
|
|
11
|
+
pk: boolean;
|
|
12
|
+
token: Token;
|
|
13
|
+
not_null: boolean;
|
|
14
|
+
note: string;
|
|
15
|
+
dbdefault: any;
|
|
16
|
+
increment: boolean;
|
|
17
|
+
table: Table;
|
|
18
|
+
}
|
|
19
|
+
declare class Field extends Element {
|
|
20
|
+
name: string;
|
|
21
|
+
type: any;
|
|
22
|
+
unique: boolean;
|
|
23
|
+
pk: boolean;
|
|
24
|
+
dbState: DbState;
|
|
25
|
+
not_null: boolean;
|
|
26
|
+
note: string;
|
|
27
|
+
dbdefault: any;
|
|
28
|
+
increment: boolean;
|
|
29
|
+
table: Table;
|
|
30
|
+
endpoints: Endpoint[];
|
|
31
|
+
_enum: Enum;
|
|
32
|
+
constructor({ name, type, unique, pk, token, not_null, note, dbdefault, increment, table }: RawField);
|
|
33
|
+
generateId(): void;
|
|
34
|
+
pushEndpoint(endpoint: any): void;
|
|
35
|
+
export(): {
|
|
36
|
+
name: string;
|
|
37
|
+
type: any;
|
|
38
|
+
unique: boolean;
|
|
39
|
+
pk: boolean;
|
|
40
|
+
not_null: boolean;
|
|
41
|
+
note: string;
|
|
42
|
+
dbdefault: any;
|
|
43
|
+
increment: boolean;
|
|
44
|
+
};
|
|
45
|
+
exportParentIds(): {
|
|
46
|
+
tableId: number;
|
|
47
|
+
enumId: number;
|
|
48
|
+
};
|
|
49
|
+
exportChildIds(): {
|
|
50
|
+
endpointIds: number[];
|
|
51
|
+
};
|
|
52
|
+
shallowExport(): {
|
|
53
|
+
name: string;
|
|
54
|
+
type: any;
|
|
55
|
+
unique: boolean;
|
|
56
|
+
pk: boolean;
|
|
57
|
+
not_null: boolean;
|
|
58
|
+
note: string;
|
|
59
|
+
dbdefault: any;
|
|
60
|
+
increment: boolean;
|
|
61
|
+
};
|
|
62
|
+
normalize(model: NormalizedDatabase): void;
|
|
63
|
+
}
|
|
64
|
+
export interface NormalizedField {
|
|
65
|
+
[_id: number]: {
|
|
66
|
+
id: number;
|
|
67
|
+
name: string;
|
|
68
|
+
type: any;
|
|
69
|
+
unique: boolean;
|
|
70
|
+
pk: boolean;
|
|
71
|
+
not_null: boolean;
|
|
72
|
+
note: string;
|
|
73
|
+
dbdefault: any;
|
|
74
|
+
increment: boolean;
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
export default Field;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { NormalizedDatabase } from './database';
|
|
2
|
+
import DbState from './dbState';
|
|
3
|
+
import Element from './element';
|
|
4
|
+
import Index from './indexes';
|
|
5
|
+
declare class IndexColumn extends Element {
|
|
6
|
+
type: any;
|
|
7
|
+
value: any;
|
|
8
|
+
index: Index;
|
|
9
|
+
dbState: DbState;
|
|
10
|
+
constructor({ type, value, index }: {
|
|
11
|
+
type: any;
|
|
12
|
+
value: any;
|
|
13
|
+
index: any;
|
|
14
|
+
});
|
|
15
|
+
generateId(): void;
|
|
16
|
+
export(): {
|
|
17
|
+
type: any;
|
|
18
|
+
value: any;
|
|
19
|
+
};
|
|
20
|
+
exportParentIds(): {
|
|
21
|
+
indexId: number;
|
|
22
|
+
};
|
|
23
|
+
shallowExport(): {
|
|
24
|
+
type: any;
|
|
25
|
+
value: any;
|
|
26
|
+
};
|
|
27
|
+
normalize(model: NormalizedDatabase): void;
|
|
28
|
+
}
|
|
29
|
+
export interface NormalizedIndexColumn {
|
|
30
|
+
[_id: number]: {
|
|
31
|
+
id: number;
|
|
32
|
+
type: any;
|
|
33
|
+
value: any;
|
|
34
|
+
indexId: number;
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
export default IndexColumn;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { NormalizedDatabase } from './database';
|
|
2
|
+
import DbState from './dbState';
|
|
3
|
+
import Element, { Token } from './element';
|
|
4
|
+
import IndexColumn from './indexColumn';
|
|
5
|
+
import Table from './table';
|
|
6
|
+
interface RawIndex {
|
|
7
|
+
columns: IndexColumn;
|
|
8
|
+
type: any;
|
|
9
|
+
unique: boolean;
|
|
10
|
+
pk: string;
|
|
11
|
+
name: string;
|
|
12
|
+
note: string;
|
|
13
|
+
table: Table;
|
|
14
|
+
token: Token;
|
|
15
|
+
}
|
|
16
|
+
declare class Index extends Element {
|
|
17
|
+
columns: IndexColumn[];
|
|
18
|
+
type: any;
|
|
19
|
+
unique: boolean;
|
|
20
|
+
pk: string;
|
|
21
|
+
name: string;
|
|
22
|
+
note: string;
|
|
23
|
+
table: Table;
|
|
24
|
+
dbState: DbState;
|
|
25
|
+
constructor({ columns, type, unique, pk, token, name, note, table }: RawIndex);
|
|
26
|
+
generateId(): void;
|
|
27
|
+
processIndexColumns(rawColumns: any): void;
|
|
28
|
+
pushIndexColumn(column: any): void;
|
|
29
|
+
checkIndexColumn(column: any): void;
|
|
30
|
+
export(): {
|
|
31
|
+
columns: {
|
|
32
|
+
type: any;
|
|
33
|
+
value: any;
|
|
34
|
+
}[];
|
|
35
|
+
name: string;
|
|
36
|
+
type: any;
|
|
37
|
+
unique: boolean;
|
|
38
|
+
pk: string;
|
|
39
|
+
note: string;
|
|
40
|
+
};
|
|
41
|
+
exportChild(): {
|
|
42
|
+
columns: {
|
|
43
|
+
type: any;
|
|
44
|
+
value: any;
|
|
45
|
+
}[];
|
|
46
|
+
};
|
|
47
|
+
exportChildIds(): {
|
|
48
|
+
columnIds: number[];
|
|
49
|
+
};
|
|
50
|
+
exportParentIds(): {
|
|
51
|
+
tableId: number;
|
|
52
|
+
};
|
|
53
|
+
shallowExport(): {
|
|
54
|
+
name: string;
|
|
55
|
+
type: any;
|
|
56
|
+
unique: boolean;
|
|
57
|
+
pk: string;
|
|
58
|
+
note: string;
|
|
59
|
+
};
|
|
60
|
+
normalize(model: NormalizedDatabase): void;
|
|
61
|
+
}
|
|
62
|
+
export interface NormalizedIndex {
|
|
63
|
+
[_id: number]: {
|
|
64
|
+
id: number;
|
|
65
|
+
name: string;
|
|
66
|
+
type: any;
|
|
67
|
+
unique: boolean;
|
|
68
|
+
pk: string;
|
|
69
|
+
note: string;
|
|
70
|
+
columnIds: number[];
|
|
71
|
+
tableId: number;
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
export default Index;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import Element, { Token } from './element';
|
|
2
|
+
import Endpoint from './endpoint';
|
|
3
|
+
import Schema from './schema';
|
|
4
|
+
import DbState from './dbState';
|
|
5
|
+
import Database, { NormalizedDatabase } from './database';
|
|
6
|
+
interface RawRef {
|
|
7
|
+
name: string;
|
|
8
|
+
endpoints: Endpoint[];
|
|
9
|
+
onDelete: any;
|
|
10
|
+
onUpdate: any;
|
|
11
|
+
token: Token;
|
|
12
|
+
schema: Schema;
|
|
13
|
+
}
|
|
14
|
+
declare class Ref extends Element {
|
|
15
|
+
name: string;
|
|
16
|
+
endpoints: Endpoint[];
|
|
17
|
+
onDelete: any;
|
|
18
|
+
onUpdate: any;
|
|
19
|
+
schema: Schema;
|
|
20
|
+
dbState: DbState;
|
|
21
|
+
id: number;
|
|
22
|
+
database: Database;
|
|
23
|
+
constructor({ name, endpoints, onDelete, onUpdate, token, schema }: RawRef);
|
|
24
|
+
generateId(): void;
|
|
25
|
+
processEndpoints(rawEndpoints: any): void;
|
|
26
|
+
equals(ref: any): any;
|
|
27
|
+
export(): {
|
|
28
|
+
endpoints: {
|
|
29
|
+
schemaName: string;
|
|
30
|
+
tableName: string;
|
|
31
|
+
fieldNames: string[];
|
|
32
|
+
relation: any;
|
|
33
|
+
}[];
|
|
34
|
+
name: string;
|
|
35
|
+
onDelete: any;
|
|
36
|
+
onUpdate: any;
|
|
37
|
+
};
|
|
38
|
+
shallowExport(): {
|
|
39
|
+
name: string;
|
|
40
|
+
onDelete: any;
|
|
41
|
+
onUpdate: any;
|
|
42
|
+
};
|
|
43
|
+
exportChild(): {
|
|
44
|
+
endpoints: {
|
|
45
|
+
schemaName: string;
|
|
46
|
+
tableName: string;
|
|
47
|
+
fieldNames: string[];
|
|
48
|
+
relation: any;
|
|
49
|
+
}[];
|
|
50
|
+
};
|
|
51
|
+
exportChildIds(): {
|
|
52
|
+
endpointIds: number[];
|
|
53
|
+
};
|
|
54
|
+
exportParentIds(): {
|
|
55
|
+
schemaId: number;
|
|
56
|
+
};
|
|
57
|
+
normalize(model: NormalizedDatabase): void;
|
|
58
|
+
}
|
|
59
|
+
export interface NormalizedRef {
|
|
60
|
+
[_id: number]: {
|
|
61
|
+
id: number;
|
|
62
|
+
endpointIds: number[];
|
|
63
|
+
schemaId: number;
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
export default Ref;
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
import Table from './table';
|
|
2
|
+
import Element, { Token } from './element';
|
|
3
|
+
import Enum from './enum';
|
|
4
|
+
import TableGroup from './tableGroup';
|
|
5
|
+
import Ref from './ref';
|
|
6
|
+
import Database, { NormalizedDatabase } from './database';
|
|
7
|
+
import DbState from './dbState';
|
|
8
|
+
export interface RawSchema {
|
|
9
|
+
name: string;
|
|
10
|
+
alias?: string;
|
|
11
|
+
note?: string;
|
|
12
|
+
tables?: Table[];
|
|
13
|
+
refs?: Ref[];
|
|
14
|
+
enums?: Enum[];
|
|
15
|
+
tableGroups?: TableGroup[];
|
|
16
|
+
token?: Token;
|
|
17
|
+
database: Database;
|
|
18
|
+
}
|
|
19
|
+
declare class Schema extends Element {
|
|
20
|
+
name: string;
|
|
21
|
+
alias: string;
|
|
22
|
+
note: string;
|
|
23
|
+
tables: Table[];
|
|
24
|
+
refs: Ref[];
|
|
25
|
+
enums: Enum[];
|
|
26
|
+
tableGroups: TableGroup[];
|
|
27
|
+
database: Database;
|
|
28
|
+
dbState: DbState;
|
|
29
|
+
constructor({ name, alias, note, tables, refs, enums, tableGroups, token, database }: RawSchema);
|
|
30
|
+
generateId(): void;
|
|
31
|
+
processTables(rawTables: any): void;
|
|
32
|
+
pushTable(table: any): void;
|
|
33
|
+
checkTable(table: any): void;
|
|
34
|
+
findTable(tableName: string): Table;
|
|
35
|
+
processEnums(rawEnums: any): void;
|
|
36
|
+
pushEnum(_enum: any): void;
|
|
37
|
+
checkEnum(_enum: any): void;
|
|
38
|
+
bindEnumToField(_enum: any): void;
|
|
39
|
+
processRefs(rawRefs: any): void;
|
|
40
|
+
pushRef(ref: any): void;
|
|
41
|
+
checkRef(ref: any): void;
|
|
42
|
+
processTableGroups(rawTableGroups: any): void;
|
|
43
|
+
pushTableGroup(tableGroup: any): void;
|
|
44
|
+
checkTableGroup(tableGroup: any): void;
|
|
45
|
+
checkSameId(schema: any): boolean;
|
|
46
|
+
export(): {
|
|
47
|
+
tables: {
|
|
48
|
+
fields: {
|
|
49
|
+
name: string;
|
|
50
|
+
type: any;
|
|
51
|
+
unique: boolean;
|
|
52
|
+
pk: boolean;
|
|
53
|
+
not_null: boolean;
|
|
54
|
+
note: string;
|
|
55
|
+
dbdefault: any;
|
|
56
|
+
increment: boolean;
|
|
57
|
+
}[];
|
|
58
|
+
indexes: {
|
|
59
|
+
columns: {
|
|
60
|
+
type: any;
|
|
61
|
+
value: any;
|
|
62
|
+
}[];
|
|
63
|
+
name: string;
|
|
64
|
+
type: any;
|
|
65
|
+
unique: boolean;
|
|
66
|
+
pk: string;
|
|
67
|
+
note: string;
|
|
68
|
+
}[];
|
|
69
|
+
name: string;
|
|
70
|
+
alias: string;
|
|
71
|
+
note: string;
|
|
72
|
+
headerColor: string;
|
|
73
|
+
}[];
|
|
74
|
+
enums: {
|
|
75
|
+
values: {
|
|
76
|
+
name: string;
|
|
77
|
+
note: string;
|
|
78
|
+
}[];
|
|
79
|
+
name: string;
|
|
80
|
+
note: string;
|
|
81
|
+
}[];
|
|
82
|
+
tableGroups: {
|
|
83
|
+
tables: {
|
|
84
|
+
tableName: string;
|
|
85
|
+
schemaName: string;
|
|
86
|
+
}[];
|
|
87
|
+
name: string;
|
|
88
|
+
}[];
|
|
89
|
+
refs: {
|
|
90
|
+
endpoints: {
|
|
91
|
+
schemaName: string;
|
|
92
|
+
tableName: string;
|
|
93
|
+
fieldNames: string[];
|
|
94
|
+
relation: any;
|
|
95
|
+
}[];
|
|
96
|
+
name: string;
|
|
97
|
+
onDelete: any;
|
|
98
|
+
onUpdate: any;
|
|
99
|
+
}[];
|
|
100
|
+
name: string;
|
|
101
|
+
note: string;
|
|
102
|
+
alias: string;
|
|
103
|
+
};
|
|
104
|
+
exportChild(): {
|
|
105
|
+
tables: {
|
|
106
|
+
fields: {
|
|
107
|
+
name: string;
|
|
108
|
+
type: any;
|
|
109
|
+
unique: boolean;
|
|
110
|
+
pk: boolean;
|
|
111
|
+
not_null: boolean;
|
|
112
|
+
note: string;
|
|
113
|
+
dbdefault: any;
|
|
114
|
+
increment: boolean;
|
|
115
|
+
}[];
|
|
116
|
+
indexes: {
|
|
117
|
+
columns: {
|
|
118
|
+
type: any;
|
|
119
|
+
value: any;
|
|
120
|
+
}[];
|
|
121
|
+
name: string;
|
|
122
|
+
type: any;
|
|
123
|
+
unique: boolean;
|
|
124
|
+
pk: string;
|
|
125
|
+
note: string;
|
|
126
|
+
}[];
|
|
127
|
+
name: string;
|
|
128
|
+
alias: string;
|
|
129
|
+
note: string;
|
|
130
|
+
headerColor: string;
|
|
131
|
+
}[];
|
|
132
|
+
enums: {
|
|
133
|
+
values: {
|
|
134
|
+
name: string;
|
|
135
|
+
note: string;
|
|
136
|
+
}[];
|
|
137
|
+
name: string;
|
|
138
|
+
note: string;
|
|
139
|
+
}[];
|
|
140
|
+
tableGroups: {
|
|
141
|
+
tables: {
|
|
142
|
+
tableName: string;
|
|
143
|
+
schemaName: string;
|
|
144
|
+
}[];
|
|
145
|
+
name: string;
|
|
146
|
+
}[];
|
|
147
|
+
refs: {
|
|
148
|
+
endpoints: {
|
|
149
|
+
schemaName: string;
|
|
150
|
+
tableName: string;
|
|
151
|
+
fieldNames: string[];
|
|
152
|
+
relation: any;
|
|
153
|
+
}[];
|
|
154
|
+
name: string;
|
|
155
|
+
onDelete: any;
|
|
156
|
+
onUpdate: any;
|
|
157
|
+
}[];
|
|
158
|
+
};
|
|
159
|
+
exportChildIds(): {
|
|
160
|
+
tableIds: number[];
|
|
161
|
+
enumIds: number[];
|
|
162
|
+
tableGroupIds: number[];
|
|
163
|
+
refIds: number[];
|
|
164
|
+
};
|
|
165
|
+
exportParentIds(): {
|
|
166
|
+
databaseId: number;
|
|
167
|
+
};
|
|
168
|
+
shallowExport(): {
|
|
169
|
+
name: string;
|
|
170
|
+
note: string;
|
|
171
|
+
alias: string;
|
|
172
|
+
};
|
|
173
|
+
normalize(model: NormalizedDatabase): void;
|
|
174
|
+
}
|
|
175
|
+
export interface NormalizedSchema {
|
|
176
|
+
[_id: number]: {
|
|
177
|
+
id: number;
|
|
178
|
+
name: string;
|
|
179
|
+
note: string;
|
|
180
|
+
alias: string;
|
|
181
|
+
tableIds: number[];
|
|
182
|
+
enumIds: number[];
|
|
183
|
+
tableGroupIds: number[];
|
|
184
|
+
refIds: number[];
|
|
185
|
+
databaseId: number;
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
export default Schema;
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import Element, { Token } from './element';
|
|
2
|
+
import Field from './field';
|
|
3
|
+
import Index from './indexes';
|
|
4
|
+
import Schema from './schema';
|
|
5
|
+
import DbState from './dbState';
|
|
6
|
+
import TableGroup from './tableGroup';
|
|
7
|
+
import { NormalizedDatabase } from './database';
|
|
8
|
+
interface RawTable {
|
|
9
|
+
name: string;
|
|
10
|
+
alias: string;
|
|
11
|
+
note: string;
|
|
12
|
+
fields: Field[];
|
|
13
|
+
indexes: Index[];
|
|
14
|
+
schema: Schema;
|
|
15
|
+
token: Token;
|
|
16
|
+
headerColor: string;
|
|
17
|
+
}
|
|
18
|
+
declare class Table extends Element {
|
|
19
|
+
name: string;
|
|
20
|
+
alias: string;
|
|
21
|
+
note: string;
|
|
22
|
+
fields: Field[];
|
|
23
|
+
indexes: Index[];
|
|
24
|
+
schema: Schema;
|
|
25
|
+
headerColor: string;
|
|
26
|
+
dbState: DbState;
|
|
27
|
+
id: number;
|
|
28
|
+
group: TableGroup;
|
|
29
|
+
constructor({ name, alias, note, fields, indexes, schema, token, headerColor }: RawTable);
|
|
30
|
+
generateId(): void;
|
|
31
|
+
processFields(rawFields: any): void;
|
|
32
|
+
pushField(field: any): void;
|
|
33
|
+
checkField(field: any): void;
|
|
34
|
+
processIndexes(rawIndexes: any): void;
|
|
35
|
+
pushIndex(index: any): void;
|
|
36
|
+
checkIndex(index: any): void;
|
|
37
|
+
findField(fieldName: any): Field;
|
|
38
|
+
checkSameId(table: any): boolean;
|
|
39
|
+
export(): {
|
|
40
|
+
fields: {
|
|
41
|
+
name: string;
|
|
42
|
+
type: any;
|
|
43
|
+
unique: boolean;
|
|
44
|
+
pk: boolean;
|
|
45
|
+
not_null: boolean;
|
|
46
|
+
note: string;
|
|
47
|
+
dbdefault: any;
|
|
48
|
+
increment: boolean;
|
|
49
|
+
}[];
|
|
50
|
+
indexes: {
|
|
51
|
+
columns: {
|
|
52
|
+
type: any;
|
|
53
|
+
value: any;
|
|
54
|
+
}[];
|
|
55
|
+
name: string;
|
|
56
|
+
type: any;
|
|
57
|
+
unique: boolean;
|
|
58
|
+
pk: string;
|
|
59
|
+
note: string;
|
|
60
|
+
}[];
|
|
61
|
+
name: string;
|
|
62
|
+
alias: string;
|
|
63
|
+
note: string;
|
|
64
|
+
headerColor: string;
|
|
65
|
+
};
|
|
66
|
+
exportChild(): {
|
|
67
|
+
fields: {
|
|
68
|
+
name: string;
|
|
69
|
+
type: any;
|
|
70
|
+
unique: boolean;
|
|
71
|
+
pk: boolean;
|
|
72
|
+
not_null: boolean;
|
|
73
|
+
note: string;
|
|
74
|
+
dbdefault: any;
|
|
75
|
+
increment: boolean;
|
|
76
|
+
}[];
|
|
77
|
+
indexes: {
|
|
78
|
+
columns: {
|
|
79
|
+
type: any;
|
|
80
|
+
value: any;
|
|
81
|
+
}[];
|
|
82
|
+
name: string;
|
|
83
|
+
type: any;
|
|
84
|
+
unique: boolean;
|
|
85
|
+
pk: string;
|
|
86
|
+
note: string;
|
|
87
|
+
}[];
|
|
88
|
+
};
|
|
89
|
+
exportChildIds(): {
|
|
90
|
+
fieldIds: number[];
|
|
91
|
+
indexIds: number[];
|
|
92
|
+
};
|
|
93
|
+
exportParentIds(): {
|
|
94
|
+
schemaId: number;
|
|
95
|
+
groupId: number;
|
|
96
|
+
};
|
|
97
|
+
shallowExport(): {
|
|
98
|
+
name: string;
|
|
99
|
+
alias: string;
|
|
100
|
+
note: string;
|
|
101
|
+
headerColor: string;
|
|
102
|
+
};
|
|
103
|
+
normalize(model: NormalizedDatabase): void;
|
|
104
|
+
}
|
|
105
|
+
export interface NormalizedTable {
|
|
106
|
+
[id: number]: {
|
|
107
|
+
id: number;
|
|
108
|
+
name: string;
|
|
109
|
+
alias: string;
|
|
110
|
+
note: string;
|
|
111
|
+
headerColor: string;
|
|
112
|
+
fieldIds: number[];
|
|
113
|
+
indexIds: number[];
|
|
114
|
+
schemaId: number;
|
|
115
|
+
groupId: number;
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
export default Table;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { NormalizedDatabase } from './database';
|
|
2
|
+
import DbState from './dbState';
|
|
3
|
+
import Element from './element';
|
|
4
|
+
import Schema from './schema';
|
|
5
|
+
import Table from './table';
|
|
6
|
+
declare class TableGroup extends Element {
|
|
7
|
+
name: string;
|
|
8
|
+
tables: Table[];
|
|
9
|
+
schema: Schema;
|
|
10
|
+
dbState: DbState;
|
|
11
|
+
id: number;
|
|
12
|
+
constructor({ name, token, tables, schema }: {
|
|
13
|
+
name: any;
|
|
14
|
+
token: any;
|
|
15
|
+
tables?: any[];
|
|
16
|
+
schema: any;
|
|
17
|
+
});
|
|
18
|
+
generateId(): void;
|
|
19
|
+
processTables(rawTables: any): void;
|
|
20
|
+
pushTable(table: any): void;
|
|
21
|
+
checkTable(table: any): void;
|
|
22
|
+
export(): {
|
|
23
|
+
tables: {
|
|
24
|
+
tableName: string;
|
|
25
|
+
schemaName: string;
|
|
26
|
+
}[];
|
|
27
|
+
name: string;
|
|
28
|
+
};
|
|
29
|
+
exportChild(): {
|
|
30
|
+
tables: {
|
|
31
|
+
tableName: string;
|
|
32
|
+
schemaName: string;
|
|
33
|
+
}[];
|
|
34
|
+
};
|
|
35
|
+
exportChildIds(): {
|
|
36
|
+
tableIds: number[];
|
|
37
|
+
};
|
|
38
|
+
exportParentIds(): {
|
|
39
|
+
schemaId: number;
|
|
40
|
+
};
|
|
41
|
+
shallowExport(): {
|
|
42
|
+
name: string;
|
|
43
|
+
};
|
|
44
|
+
normalize(model: NormalizedDatabase): void;
|
|
45
|
+
}
|
|
46
|
+
export interface NormalizedTableGroup {
|
|
47
|
+
[_id: number]: {
|
|
48
|
+
id: number;
|
|
49
|
+
name: string;
|
|
50
|
+
tableIds: number[];
|
|
51
|
+
schemaId: number;
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
export default TableGroup;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import Database, { RawDatabase } from '../model_structure/database';
|
|
2
|
+
declare class Parser {
|
|
3
|
+
static parseJSONToDatabase(rawDatabase: RawDatabase): Database;
|
|
4
|
+
static parseMySQLToJSON(str: string): RawDatabase;
|
|
5
|
+
static parsePostgresToJSON(str: string): RawDatabase;
|
|
6
|
+
static parseDBMLToJSON(str: string): RawDatabase;
|
|
7
|
+
static parseSchemaRbToJSON(str: string): RawDatabase;
|
|
8
|
+
static parseMSSQLToJSON(str: string): RawDatabase;
|
|
9
|
+
static parse(str: string, format: 'mysql' | 'postgres' | 'dbml' | 'schemarb' | 'mssql' | 'json'): Database;
|
|
10
|
+
}
|
|
11
|
+
export default Parser;
|