@dbml/parse 3.14.1 → 3.15.0-alpha.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/dist/dbml-parse.js +10 -10
- package/dist/dbml-parse.mjs +2257 -2107
- package/dist/src/compiler.d.ts +2 -1
- package/dist/src/lib/analyzer/binder/elementBinder/constraints.d.ts +12 -0
- package/dist/src/lib/analyzer/binder/elementBinder/table.d.ts +3 -0
- package/dist/src/lib/analyzer/types.d.ts +4 -2
- package/dist/src/lib/analyzer/validator/elementValidators/constraints.d.ts +23 -0
- package/dist/src/lib/analyzer/validator/utils.d.ts +2 -1
- package/dist/src/lib/errors.d.ts +10 -2
- package/dist/src/lib/interpreter/elementInterpreter/table.d.ts +1 -0
- package/dist/src/lib/interpreter/elementInterpreter/tablePartial.d.ts +1 -0
- package/dist/src/lib/interpreter/types.d.ts +8 -0
- package/package.json +4 -3
package/dist/src/compiler.d.ts
CHANGED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { default as ElementBinder } from './elementBinder';
|
|
2
|
+
export default class ConstraintsBinder extends ElementBinder {
|
|
3
|
+
protected subfield: {
|
|
4
|
+
arg: {
|
|
5
|
+
argBinderRules: {
|
|
6
|
+
shouldBind: false;
|
|
7
|
+
}[];
|
|
8
|
+
};
|
|
9
|
+
settingList: {};
|
|
10
|
+
};
|
|
11
|
+
protected settingList: {};
|
|
12
|
+
}
|
|
@@ -6,14 +6,15 @@ export declare enum ElementKind {
|
|
|
6
6
|
Project = "project",
|
|
7
7
|
Indexes = "indexes",
|
|
8
8
|
TableGroup = "tablegroup",
|
|
9
|
-
TablePartial = "tablepartial"
|
|
9
|
+
TablePartial = "tablepartial",
|
|
10
|
+
Constraints = "constraints"
|
|
10
11
|
}
|
|
11
12
|
export declare enum SettingName {
|
|
12
13
|
Color = "color",
|
|
13
14
|
HeaderColor = "headercolor",
|
|
14
15
|
Note = "note",
|
|
15
16
|
PK = "pk",
|
|
16
|
-
|
|
17
|
+
PrimaryKey = "primary key",
|
|
17
18
|
Unique = "unique",
|
|
18
19
|
Ref = "ref",
|
|
19
20
|
NotNull = "not null",
|
|
@@ -22,6 +23,7 @@ export declare enum SettingName {
|
|
|
22
23
|
Default = "default",
|
|
23
24
|
Name = "name",
|
|
24
25
|
Type = "type",
|
|
26
|
+
Constraint = "constraint",
|
|
25
27
|
Update = "update",
|
|
26
28
|
Delete = "delete"
|
|
27
29
|
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { default as SymbolFactory } from '../../symbol/factory';
|
|
2
|
+
import { CompileError } from '../../../errors';
|
|
3
|
+
import { ElementDeclarationNode } from '../../../parser/nodes';
|
|
4
|
+
import { SyntaxToken } from '../../../lexer/tokens';
|
|
5
|
+
import { ElementValidator } from '../types';
|
|
6
|
+
import { default as SymbolTable } from '../../../analyzer/symbol/symbolTable';
|
|
7
|
+
export default class ConstraintsValidator implements ElementValidator {
|
|
8
|
+
private declarationNode;
|
|
9
|
+
private publicSymbolTable;
|
|
10
|
+
private symbolFactory;
|
|
11
|
+
constructor(declarationNode: ElementDeclarationNode & {
|
|
12
|
+
type: SyntaxToken;
|
|
13
|
+
}, publicSymbolTable: SymbolTable, symbolFactory: SymbolFactory);
|
|
14
|
+
validate(): CompileError[];
|
|
15
|
+
private validateContext;
|
|
16
|
+
private validateName;
|
|
17
|
+
private validateAlias;
|
|
18
|
+
private validateSettingList;
|
|
19
|
+
private validateBody;
|
|
20
|
+
private validateFields;
|
|
21
|
+
private validateFieldSetting;
|
|
22
|
+
private validateSubElements;
|
|
23
|
+
}
|
|
@@ -13,9 +13,10 @@ import { default as SymbolFactory } from '../symbol/factory';
|
|
|
13
13
|
import { default as Report } from '../../report';
|
|
14
14
|
import { CompileError } from '../../errors';
|
|
15
15
|
import { default as TablePartialValidator } from './elementValidators/tablePartial';
|
|
16
|
+
import { default as ConstraintsValidator } from './elementValidators/constraints';
|
|
16
17
|
export declare function pickValidator(element: ElementDeclarationNode & {
|
|
17
18
|
type: SyntaxToken;
|
|
18
|
-
}): typeof CustomValidator | typeof EnumValidator | typeof TableValidator | typeof TableGroupValidator | typeof ProjectValidator | typeof RefValidator | typeof NoteValidator | typeof IndexesValidator | typeof TablePartialValidator;
|
|
19
|
+
}): typeof CustomValidator | typeof EnumValidator | typeof TableValidator | typeof TableGroupValidator | typeof ProjectValidator | typeof RefValidator | typeof NoteValidator | typeof IndexesValidator | typeof TablePartialValidator | typeof ConstraintsValidator;
|
|
19
20
|
export declare function isValidName(nameNode: SyntaxNode): boolean;
|
|
20
21
|
export declare function isValidAlias(aliasNode: SyntaxNode): aliasNode is PrimaryExpressionNode & {
|
|
21
22
|
expression: VariableNode;
|
package/dist/src/lib/errors.d.ts
CHANGED
|
@@ -24,7 +24,7 @@ export declare enum CompileErrorCode {
|
|
|
24
24
|
UNEXPECTED_SIMPLE_BODY = 3008,
|
|
25
25
|
UNEXPECTED_COMPLEX_BODY = 3009,
|
|
26
26
|
INVALID_TABLE_CONTEXT = 3010,
|
|
27
|
-
|
|
27
|
+
UNKNOWN_TABLE_SETTING = 3011,
|
|
28
28
|
DUPLICATE_TABLE_SETTING = 3012,
|
|
29
29
|
INVALID_TABLEGROUP_CONTEXT = 3013,
|
|
30
30
|
INVALID_TABLEGROUP_ELEMENT_NAME = 3014,
|
|
@@ -75,13 +75,21 @@ export declare enum CompileErrorCode {
|
|
|
75
75
|
INVALID_ELEMENT_IN_SIMPLE_BODY = 3059,
|
|
76
76
|
INVALID_TABLE_PARTIAL_CONTEXT = 3060,
|
|
77
77
|
INVALID_TABLE_PARTIAL_ELEMENT_NAME = 3061,
|
|
78
|
-
|
|
78
|
+
INVALID_TABLE_PARTIAL_SETTING_VALUE = 3062,
|
|
79
79
|
DUPLICATE_TABLE_PARTIAL_ELEMENT_NAME = 3063,
|
|
80
80
|
DUPLICATE_TABLE_PARTIAL_SETTING = 3064,
|
|
81
81
|
INVALID_TABLE_PARTIAL_INJECTION = 3065,
|
|
82
82
|
INVALID_TABLE_PARTIAL_INJECTION_OP = 3066,
|
|
83
83
|
INVALID_TABLE_PARTIAL_INJECTION_NAME = 3067,
|
|
84
84
|
DUPLICATE_TABLE_PARTIAL_INJECTION_NAME = 3068,
|
|
85
|
+
UNKNOWN_TABLE_PARTIAL_SETTING = 3069,
|
|
86
|
+
INVALID_TABLE_SETTING_VALUE = 3070,
|
|
87
|
+
INVALID_CONSTRAINTS_CONTEXT = 3071,
|
|
88
|
+
INVALID_CONSTRAINTS_FIELD = 3072,
|
|
89
|
+
INVALID_CONSTRAINT = 3073,
|
|
90
|
+
UNKNOWN_CONSTRAINT_SETTING = 3074,
|
|
91
|
+
DUPLICATE_CONSTRAINT_SETTING = 3075,
|
|
92
|
+
INVALID_CONSTRAINT_SETTING_VALUE = 3076,
|
|
85
93
|
BINDING_ERROR = 4000,
|
|
86
94
|
UNSUPPORTED = 5000,
|
|
87
95
|
CIRCULAR_REF = 5001,
|
|
@@ -41,6 +41,7 @@ export interface Table {
|
|
|
41
41
|
schemaName: null | string;
|
|
42
42
|
alias: string | null;
|
|
43
43
|
fields: Column[];
|
|
44
|
+
constraints: Constraint[];
|
|
44
45
|
partials: TablePartialInjection[];
|
|
45
46
|
token: TokenPosition;
|
|
46
47
|
indexes: Index[];
|
|
@@ -66,6 +67,7 @@ export interface Column {
|
|
|
66
67
|
type: ColumnType;
|
|
67
68
|
token: TokenPosition;
|
|
68
69
|
inline_refs: InlineRef[];
|
|
70
|
+
constraints: Constraint[];
|
|
69
71
|
pk?: boolean;
|
|
70
72
|
dbdefault?: {
|
|
71
73
|
type: 'number' | 'string' | 'boolean' | 'expression';
|
|
@@ -95,6 +97,11 @@ export interface Index {
|
|
|
95
97
|
};
|
|
96
98
|
type?: string;
|
|
97
99
|
}
|
|
100
|
+
export interface Constraint {
|
|
101
|
+
token: TokenPosition;
|
|
102
|
+
expression: string;
|
|
103
|
+
name?: string;
|
|
104
|
+
}
|
|
98
105
|
export interface InlineRef {
|
|
99
106
|
schemaName: string | null;
|
|
100
107
|
tableName: string;
|
|
@@ -163,6 +170,7 @@ export interface TablePartial {
|
|
|
163
170
|
token: TokenPosition;
|
|
164
171
|
indexes: Index[];
|
|
165
172
|
headerColor?: string;
|
|
173
|
+
constraints: Constraint[];
|
|
166
174
|
note?: {
|
|
167
175
|
value: string;
|
|
168
176
|
token: TokenPosition;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dbml/parse",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.15.0-alpha.0",
|
|
4
4
|
"description": "> TODO: description",
|
|
5
5
|
"author": "Holistics <dev@holistics.io>",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -29,7 +29,8 @@
|
|
|
29
29
|
"test:watch": "vitest tests",
|
|
30
30
|
"coverage": "vitest run --coverage",
|
|
31
31
|
"prepublish": "npm run build",
|
|
32
|
-
"prepare": "npm run build"
|
|
32
|
+
"prepare": "npm run build",
|
|
33
|
+
"lint": "eslint ."
|
|
33
34
|
},
|
|
34
35
|
"devDependencies": {
|
|
35
36
|
"@types/lodash": "^4.14.200",
|
|
@@ -48,5 +49,5 @@
|
|
|
48
49
|
"engines": {
|
|
49
50
|
"node": ">=18"
|
|
50
51
|
},
|
|
51
|
-
"gitHead": "
|
|
52
|
+
"gitHead": "b8718ceac53a179f91856011a03b360c9c40854c"
|
|
52
53
|
}
|