@dbml/core 3.14.1 → 4.0.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 +38 -1
- package/lib/export/MysqlExporter.js +36 -1
- package/lib/export/OracleExporter.js +36 -1
- package/lib/export/PostgresExporter.js +36 -1
- package/lib/export/SqlServerExporter.js +36 -1
- package/lib/index.js +1 -1
- package/lib/model_structure/constraint.js +86 -0
- package/lib/model_structure/database.js +1 -0
- package/lib/model_structure/dbState.js +1 -0
- package/lib/model_structure/field.js +23 -1
- package/lib/model_structure/table.js +51 -17
- package/lib/model_structure/tablePartial.js +3 -0
- package/lib/parse/ANTLR/ASTGeneration/AST.js +18 -6
- package/lib/parse/ANTLR/ASTGeneration/constants.js +2 -1
- package/lib/parse/ANTLR/ASTGeneration/mssql/MssqlASTGen.js +53 -101
- package/lib/parse/ANTLR/ASTGeneration/mysql/MySQLASTGen.js +73 -19
- package/lib/parse/ANTLR/ASTGeneration/postgres/PostgresASTGen.js +50 -16
- package/lib/parse/ANTLR/parsers/postgresql/PostgreSQLParser.g4 +1 -1
- package/lib/parse/ANTLR/parsers/postgresql/PostgreSQLParser.interp +1 -1
- package/lib/parse/ANTLR/parsers/postgresql/PostgreSQLParser.js +2 -2
- package/lib/parse/ANTLR/parsers/postgresql/PostgreSQLParser.tokens +1314 -1314
- package/lib/parse/ANTLR/parsers/postgresql/PostgreSQLParserVisitor.js +1 -1
- package/lib/parse/schemarb/parser.pegjs +41 -0
- package/lib/parse/schemarbParser.js +568 -226
- package/package.json +3 -3
- package/types/model_structure/constraint.d.ts +52 -0
- package/types/model_structure/database.d.ts +2 -0
- package/types/model_structure/field.d.ts +7 -1
- package/types/model_structure/table.d.ts +8 -1
- package/types/model_structure/tablePartial.d.ts +4 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dbml/core",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"description": "> TODO: description",
|
|
5
5
|
"author": "Holistics <dev@holistics.io>",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"prepublish": "npm run build"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@dbml/parse": "^
|
|
35
|
+
"@dbml/parse": "^4.0.0",
|
|
36
36
|
"antlr4": "^4.13.1",
|
|
37
37
|
"lodash": "^4.17.15",
|
|
38
38
|
"parsimmon": "^1.13.0",
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
"^lodash-es$": "lodash"
|
|
63
63
|
}
|
|
64
64
|
},
|
|
65
|
-
"gitHead": "
|
|
65
|
+
"gitHead": "defacb4ec78893de46225948499feea5bf2932e2",
|
|
66
66
|
"engines": {
|
|
67
67
|
"node": ">=16"
|
|
68
68
|
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { NormalizedDatabase } from './database';
|
|
2
|
+
import Element, { Token } from './element';
|
|
3
|
+
import Field from './field';
|
|
4
|
+
import Table from './table';
|
|
5
|
+
import TablePartial from './tablePartial';
|
|
6
|
+
|
|
7
|
+
interface RawConstraint {
|
|
8
|
+
token: Token;
|
|
9
|
+
name: string;
|
|
10
|
+
expression: string;
|
|
11
|
+
table: Table;
|
|
12
|
+
column?: Field | null;
|
|
13
|
+
injectedPartial?: TablePartial | null;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
declare class Constraint extends Element {
|
|
17
|
+
name: string;
|
|
18
|
+
expression: string;
|
|
19
|
+
table: Table;
|
|
20
|
+
column: Field | null;
|
|
21
|
+
injectedPartial: TablePartial | null;
|
|
22
|
+
|
|
23
|
+
constructor({ token, name, expression, table, column, injectedPartial }: RawConstraint);
|
|
24
|
+
generateId(): void;
|
|
25
|
+
export(): {
|
|
26
|
+
name: string;
|
|
27
|
+
expression: string;
|
|
28
|
+
};
|
|
29
|
+
exportParentIds(): {
|
|
30
|
+
tableId: number;
|
|
31
|
+
columnId: number | null;
|
|
32
|
+
injectedPartialId: number | null;
|
|
33
|
+
};
|
|
34
|
+
shallowExport(): {
|
|
35
|
+
name: string;
|
|
36
|
+
expression: string;
|
|
37
|
+
};
|
|
38
|
+
normalize(model: NormalizedDatabase): void;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export interface NormalizedConstraint {
|
|
42
|
+
[_id: number]: {
|
|
43
|
+
id: number;
|
|
44
|
+
name: string;
|
|
45
|
+
expression: string;
|
|
46
|
+
tableId: number;
|
|
47
|
+
columnId: number | null;
|
|
48
|
+
injectedPartialId: number | null;
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export default Constraint;
|
|
@@ -11,6 +11,7 @@ import { NormalizedEnumValue } from './enumValue';
|
|
|
11
11
|
import { NormalizedField } from './field';
|
|
12
12
|
import { NormalizedIndexColumn } from './indexColumn';
|
|
13
13
|
import { NormalizedIndex } from './indexes';
|
|
14
|
+
import { NormalizedConstraint } from './constraint';
|
|
14
15
|
import TablePartial, { NormalizedTablePartial } from './tablePartial';
|
|
15
16
|
export interface Project {
|
|
16
17
|
note: RawNote;
|
|
@@ -299,6 +300,7 @@ export interface NormalizedDatabase {
|
|
|
299
300
|
enumValues: NormalizedEnumValue;
|
|
300
301
|
indexes: NormalizedIndex;
|
|
301
302
|
indexColumns: NormalizedIndexColumn;
|
|
303
|
+
constraints: NormalizedConstraint;
|
|
302
304
|
fields: NormalizedField;
|
|
303
305
|
records: NormalizedRecords;
|
|
304
306
|
tablePartials: NormalizedTablePartial;
|
|
@@ -5,6 +5,7 @@ import Endpoint from './endpoint';
|
|
|
5
5
|
import Enum from './enum';
|
|
6
6
|
import Table from './table';
|
|
7
7
|
import TablePartial from './tablePartial';
|
|
8
|
+
import Constraint from './constraint';
|
|
8
9
|
interface RawField {
|
|
9
10
|
name: string;
|
|
10
11
|
type: any;
|
|
@@ -15,6 +16,7 @@ interface RawField {
|
|
|
15
16
|
note: RawNote;
|
|
16
17
|
dbdefault: any;
|
|
17
18
|
increment: boolean;
|
|
19
|
+
constraints?: any[];
|
|
18
20
|
table: Table;
|
|
19
21
|
}
|
|
20
22
|
declare class Field extends Element {
|
|
@@ -28,14 +30,16 @@ declare class Field extends Element {
|
|
|
28
30
|
noteToken: Token;
|
|
29
31
|
dbdefault: any;
|
|
30
32
|
increment: boolean;
|
|
33
|
+
constraints: Constraint[];
|
|
31
34
|
table: Table;
|
|
32
35
|
endpoints: Endpoint[];
|
|
33
36
|
_enum: Enum;
|
|
34
37
|
injectedPartial?: TablePartial;
|
|
35
38
|
injectedToken: Token;
|
|
36
|
-
constructor({ name, type, unique, pk, token, not_null, note, dbdefault, increment, table }: RawField);
|
|
39
|
+
constructor({ name, type, unique, pk, token, not_null, note, dbdefault, increment, constraints, table }: RawField);
|
|
37
40
|
generateId(): void;
|
|
38
41
|
pushEndpoint(endpoint: any): void;
|
|
42
|
+
processConstraints(constraints: any[]): void;
|
|
39
43
|
export(): {
|
|
40
44
|
name: string;
|
|
41
45
|
type: any;
|
|
@@ -64,6 +68,7 @@ declare class Field extends Element {
|
|
|
64
68
|
dbdefault: any;
|
|
65
69
|
increment: boolean;
|
|
66
70
|
injectedPartialId?: number;
|
|
71
|
+
constraintIds: number[];
|
|
67
72
|
};
|
|
68
73
|
normalize(model: NormalizedDatabase): void;
|
|
69
74
|
}
|
|
@@ -82,6 +87,7 @@ export interface NormalizedField {
|
|
|
82
87
|
endpointIds: number[];
|
|
83
88
|
enumId: number;
|
|
84
89
|
injectedPartialId?: number;
|
|
90
|
+
constraintIds: number[];
|
|
85
91
|
};
|
|
86
92
|
}
|
|
87
93
|
export default Field;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import Element, { RawNote, Token } from './element';
|
|
2
2
|
import Field from './field';
|
|
3
3
|
import Index from './indexes';
|
|
4
|
+
import Constraint from './constraint';
|
|
4
5
|
import Schema from './schema';
|
|
5
6
|
import DbState from './dbState';
|
|
6
7
|
import TableGroup from './tableGroup';
|
|
@@ -13,6 +14,7 @@ interface RawTable {
|
|
|
13
14
|
note: RawNote;
|
|
14
15
|
fields: Field[];
|
|
15
16
|
indexes: Index[];
|
|
17
|
+
constraints?: any[];
|
|
16
18
|
schema: Schema;
|
|
17
19
|
token: Token;
|
|
18
20
|
headerColor: string;
|
|
@@ -26,6 +28,7 @@ declare class Table extends Element {
|
|
|
26
28
|
noteToken: Token;
|
|
27
29
|
fields: Field[];
|
|
28
30
|
indexes: Index[];
|
|
31
|
+
constraints: Constraint[];
|
|
29
32
|
schema: Schema;
|
|
30
33
|
headerColor: string;
|
|
31
34
|
dbState: DbState;
|
|
@@ -33,7 +36,7 @@ declare class Table extends Element {
|
|
|
33
36
|
group: TableGroup;
|
|
34
37
|
partials: TablePartial[];
|
|
35
38
|
|
|
36
|
-
constructor({ name, alias, note, fields, indexes, schema, token, headerColor }: RawTable);
|
|
39
|
+
constructor({ name, alias, note, fields, indexes, constraints, schema, token, headerColor }: RawTable);
|
|
37
40
|
generateId(): void;
|
|
38
41
|
processFields(rawFields: any): void;
|
|
39
42
|
pushField(field: any): void;
|
|
@@ -41,6 +44,8 @@ declare class Table extends Element {
|
|
|
41
44
|
processIndexes(rawIndexes: any): void;
|
|
42
45
|
pushIndex(index: any): void;
|
|
43
46
|
checkIndex(index: any): void;
|
|
47
|
+
processConstraints(constraints: any[]): void;
|
|
48
|
+
pushConstraint(constraint: any): void;
|
|
44
49
|
findField(fieldName: any): Field;
|
|
45
50
|
checkSameId(table: any): boolean;
|
|
46
51
|
processPartials(): void;
|
|
@@ -98,6 +103,7 @@ declare class Table extends Element {
|
|
|
98
103
|
exportChildIds(): {
|
|
99
104
|
fieldIds: number[];
|
|
100
105
|
indexIds: number[];
|
|
106
|
+
constraintIds: number[];
|
|
101
107
|
};
|
|
102
108
|
exportParentIds(): {
|
|
103
109
|
schemaId: number;
|
|
@@ -122,6 +128,7 @@ export interface NormalizedTable {
|
|
|
122
128
|
headerColor: string;
|
|
123
129
|
fieldIds: number[];
|
|
124
130
|
indexIds: number[];
|
|
131
|
+
constraintIds: number[];
|
|
125
132
|
schemaId: number;
|
|
126
133
|
groupId: number;
|
|
127
134
|
partials: TablePartial[];
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import Element, { RawNote, Token } from './element';
|
|
2
2
|
import Field from './field';
|
|
3
3
|
import Index from './indexes';
|
|
4
|
+
import Constraint from './constraint';
|
|
4
5
|
import DbState from './dbState';
|
|
5
6
|
import { NormalizedDatabase } from './database';
|
|
6
7
|
|
|
@@ -9,6 +10,7 @@ interface RawTablePartial {
|
|
|
9
10
|
note: RawNote;
|
|
10
11
|
fields: Field[];
|
|
11
12
|
indexes: Index[];
|
|
13
|
+
constraints?: any[];
|
|
12
14
|
token: Token;
|
|
13
15
|
headerColor: string;
|
|
14
16
|
dbState: DbState;
|
|
@@ -20,11 +22,12 @@ declare class TablePartial extends Element {
|
|
|
20
22
|
noteToken: Token;
|
|
21
23
|
fields: Field[];
|
|
22
24
|
indexes: Index[];
|
|
25
|
+
constraints: Constraint[];
|
|
23
26
|
headerColor: string;
|
|
24
27
|
dbState: DbState;
|
|
25
28
|
id: number;
|
|
26
29
|
|
|
27
|
-
constructor({ name, note, fields, indexes, token, headerColor, dbState }: RawTablePartial);
|
|
30
|
+
constructor({ name, note, fields, indexes, constraints, token, headerColor, dbState }: RawTablePartial);
|
|
28
31
|
generateId(): void;
|
|
29
32
|
export(): {
|
|
30
33
|
name: string;
|