@dbml/parse 10.0.0-optional-ref.0 → 10.1.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 +33 -19
- package/dist/dbml-parse.mjs +6154 -4683
- package/dist/src/compiler/index.d.ts +11 -7
- package/dist/src/compiler/queries/transform/index.d.ts +3 -1
- package/dist/src/compiler/queries/transform/renameTable.d.ts +2 -2
- package/dist/src/compiler/queries/transform/syncDep.d.ts +54 -0
- package/dist/src/compiler/queries/transform/types.d.ts +48 -0
- package/dist/src/compiler/queries/transform/updateElementSetting.d.ts +6 -0
- package/dist/src/compiler/queries/transform/utils/index.d.ts +26 -0
- package/dist/src/compiler/queries/transform/utils/ref.d.ts +15 -0
- package/dist/src/compiler/queries/utils.d.ts +6 -0
- package/dist/src/compiler/types.d.ts +9 -7
- package/dist/src/core/global_modules/dep/bind.d.ts +18 -0
- package/dist/src/core/global_modules/dep/index.d.ts +2 -0
- package/dist/src/core/global_modules/dep/interpret.d.ts +18 -0
- package/dist/src/core/global_modules/metadata/bind.d.ts +11 -0
- package/dist/src/core/global_modules/metadata/index.d.ts +2 -0
- package/dist/src/core/global_modules/metadata/interpret.d.ts +14 -0
- package/dist/src/core/global_modules/metadata/utils.d.ts +29 -0
- package/dist/src/core/global_modules/note/interpret.d.ts +3 -1
- package/dist/src/core/global_modules/program/utils/dep.d.ts +4 -0
- package/dist/src/core/global_modules/program/utils/external.d.ts +3 -0
- package/dist/src/core/global_modules/program/utils/index.d.ts +3 -0
- package/dist/src/core/global_modules/program/utils/records.d.ts +6 -0
- package/dist/src/core/global_modules/records/utils/constraints/fk.d.ts +2 -2
- package/dist/src/core/global_modules/records/utils/constraints/helper.d.ts +1 -2
- package/dist/src/core/global_modules/records/utils/constraints/pk.d.ts +2 -2
- package/dist/src/core/global_modules/records/utils/constraints/unique.d.ts +2 -2
- package/dist/src/core/global_modules/table/bind.d.ts +2 -0
- package/dist/src/core/global_modules/table/interpret.d.ts +12 -1
- package/dist/src/core/global_modules/tableGroup/interpret.d.ts +3 -1
- package/dist/src/core/global_modules/utils.d.ts +5 -1
- package/dist/src/core/local_modules/dep/index.d.ts +2 -0
- package/dist/src/core/local_modules/dep/validate.d.ts +19 -0
- package/dist/src/core/local_modules/metadata/index.d.ts +2 -0
- package/dist/src/core/local_modules/metadata/utils.d.ts +7 -0
- package/dist/src/core/local_modules/metadata/validate.d.ts +14 -0
- package/dist/src/core/types/errors.d.ts +99 -67
- package/dist/src/core/types/keywords.d.ts +4 -1
- package/dist/src/core/types/nodes.d.ts +14 -3
- package/dist/src/core/types/relation.d.ts +6 -2
- package/dist/src/core/types/schemaJson/types.d.ts +45 -1
- package/dist/src/core/types/symbol/metadata.d.ts +30 -11
- package/dist/src/core/types/symbol/symbols.d.ts +10 -1
- package/dist/src/core/utils/diagnostics_reporter/index.d.ts +2 -0
- package/dist/src/core/utils/diagnostics_reporter/records.d.ts +87 -0
- package/dist/src/core/utils/diagnostics_reporter/ref.d.ts +30 -0
- package/dist/src/core/utils/expression.d.ts +2 -1
- package/dist/src/core/utils/interpret.d.ts +12 -2
- package/dist/src/core/utils/note.d.ts +18 -0
- package/dist/src/core/utils/setting.d.ts +13 -14
- package/dist/src/core/utils/span.d.ts +2 -0
- package/dist/src/core/utils/tokens.d.ts +3 -0
- package/dist/src/core/utils/validate.d.ts +16 -2
- package/dist/src/index.d.ts +7 -3
- package/dist/src/services/diagnostics/provider.d.ts +13 -0
- package/dist/src/services/index.d.ts +1 -1
- package/dist/src/services/suggestions/provider.d.ts +19 -0
- package/package.json +4 -3
- package/dist/src/compiler/queries/transform/utils.d.ts +0 -23
- package/dist/src/core/global_modules/program/utils.d.ts +0 -3
|
@@ -57,102 +57,134 @@ export declare enum CompileErrorCode {
|
|
|
57
57
|
INVALID_REF_FIELD = 3039,
|
|
58
58
|
EMPTY_REF = 3040,
|
|
59
59
|
REF_REDEFINED = 3041,
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
60
|
+
INVALID_DEP_CONTEXT = 3042,
|
|
61
|
+
INVALID_DEP_FIELD = 3043,
|
|
62
|
+
INVALID_NOTE_CONTEXT = 3044,
|
|
63
|
+
INVALID_NOTE = 3045,
|
|
64
|
+
NOTE_REDEFINED = 3046,
|
|
65
|
+
NOTE_CONTENT_REDEFINED = 3047,
|
|
66
|
+
EMPTY_NOTE = 3048,
|
|
67
|
+
UNKNOWN_NOTE_SETTING = 3049,
|
|
68
|
+
DUPLICATE_NOTE_SETTING = 3050,
|
|
69
|
+
INVALID_NOTE_SETTING_VALUE = 3051,
|
|
70
|
+
INVALID_INDEXES_CONTEXT = 3052,
|
|
71
|
+
INVALID_INDEXES_FIELD = 3053,
|
|
72
|
+
INVALID_INDEX = 3054,
|
|
73
|
+
UNKNOWN_INDEX_SETTING = 3055,
|
|
74
|
+
DUPLICATE_INDEX_SETTING = 3056,
|
|
75
|
+
UNEXPECTED_INDEX_SETTING_VALUE = 3057,
|
|
76
|
+
INVALID_INDEX_SETTING_VALUE = 3058,
|
|
77
|
+
INVALID_PROJECT_CONTEXT = 3059,
|
|
78
|
+
PROJECT_REDEFINED = 3060,
|
|
79
|
+
INVALID_PROJECT_FIELD = 3061,
|
|
80
|
+
INVALID_CUSTOM_CONTEXT = 3062,
|
|
81
|
+
INVALID_CUSTOM_ELEMENT_VALUE = 3063,
|
|
82
|
+
INVALID_ELEMENT_IN_SIMPLE_BODY = 3064,
|
|
83
|
+
INVALID_TABLE_PARTIAL_CONTEXT = 3065,
|
|
84
|
+
INVALID_TABLE_PARTIAL_ELEMENT_NAME = 3066,
|
|
85
|
+
INVALID_TABLE_PARTIAL_SETTING_VALUE = 3067,
|
|
86
|
+
DUPLICATE_TABLE_PARTIAL_ELEMENT_NAME = 3068,
|
|
87
|
+
DUPLICATE_TABLE_PARTIAL_SETTING = 3069,
|
|
88
|
+
INVALID_TABLE_PARTIAL_INJECTION = 3070,
|
|
89
|
+
INVALID_TABLE_PARTIAL_INJECTION_OP = 3071,
|
|
90
|
+
INVALID_TABLE_PARTIAL_INJECTION_NAME = 3072,
|
|
91
|
+
DUPLICATE_TABLE_PARTIAL_INJECTION_NAME = 3073,
|
|
92
|
+
UNKNOWN_TABLE_PARTIAL_SETTING = 3074,
|
|
93
|
+
INVALID_TABLE_SETTING_VALUE = 3075,
|
|
94
|
+
INVALID_CHECKS_CONTEXT = 3076,
|
|
95
|
+
INVALID_CHECKS_FIELD = 3077,
|
|
96
|
+
INVALID_CHECK = 3078,
|
|
97
|
+
UNKNOWN_CHECK_SETTING = 3079,
|
|
98
|
+
DUPLICATE_CHECK_SETTING = 3080,
|
|
99
|
+
INVALID_CHECK_SETTING_VALUE = 3081,
|
|
100
|
+
INVALID_RECORDS_CONTEXT = 3082,
|
|
101
|
+
INVALID_RECORDS_NAME = 3083,
|
|
102
|
+
INVALID_RECORDS_FIELD = 3084,
|
|
103
|
+
DUPLICATE_COLUMN_REFERENCES_IN_RECORDS = 3085,
|
|
104
|
+
DUPLICATE_RECORDS_FOR_TABLE = 3086,
|
|
105
|
+
INVALID_USE_CONTEXT = 3087,
|
|
106
|
+
INVALID_USE_SPECIFIER_KIND = 3088,
|
|
107
|
+
INVALID_USE_SPECIFIER_NAME = 3089,
|
|
108
|
+
INVALID_DIAGRAMVIEW_CONTEXT = 3090,
|
|
109
|
+
DUPLICATE_DIAGRAMVIEW_NAME = 3091,
|
|
110
|
+
INVALID_DIAGRAMVIEW_FIELD = 3092,
|
|
111
|
+
DUPLICATE_DIAGRAMVIEW_FIELD = 3093,
|
|
110
112
|
BINDING_ERROR = 4000,
|
|
111
113
|
NONEXISTENT_MODULE = 4001,
|
|
112
114
|
UNSUPPORTED = 5000,
|
|
113
115
|
CIRCULAR_REF = 5001,
|
|
114
116
|
SAME_ENDPOINT = 5002,
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
117
|
+
DEP_SELF_LOOP = 5003,
|
|
118
|
+
DEP_MIXED_DOWNSTREAM_TABLES = 5004,
|
|
119
|
+
DEP_DUPLICATE_DOWNSTREAM_TABLE = 5005,
|
|
120
|
+
DEP_MIXED_LEVEL = 5006,
|
|
121
|
+
UNEQUAL_FIELDS_BINARY_REF = 5007,
|
|
122
|
+
CONFLICTING_SETTING = 5008,
|
|
123
|
+
TABLE_REAPPEAR_IN_TABLEGROUP = 5009,
|
|
124
|
+
INVALID_METADATA_TARGET_KIND = 5010,
|
|
125
|
+
INVALID_METADATA_FIELD = 5011,
|
|
126
|
+
DUPLICATE_METADATA_FIELD = 5012
|
|
118
127
|
}
|
|
119
128
|
export interface RelatedLocation {
|
|
120
129
|
nodeOrToken: SyntaxNode | SyntaxToken;
|
|
121
130
|
message: string;
|
|
122
131
|
}
|
|
123
|
-
export
|
|
132
|
+
export interface QuickFix {
|
|
133
|
+
title: string;
|
|
134
|
+
shortTitle?: string;
|
|
135
|
+
filepath: Filepath;
|
|
136
|
+
edits: TextEdit[];
|
|
137
|
+
isPreferred?: boolean;
|
|
138
|
+
}
|
|
139
|
+
export declare enum DiagnosticCategory {
|
|
140
|
+
RefColumnMismatch = "Mismatched optional ref constraints",
|
|
141
|
+
RecordValueTypeMismatch = "Record type errors",
|
|
142
|
+
RecordConstraintViolation = "Record constraint violations",
|
|
143
|
+
Other = "Other"
|
|
144
|
+
}
|
|
145
|
+
export interface CompileDetails {
|
|
146
|
+
category?: DiagnosticCategory;
|
|
147
|
+
explanation?: string;
|
|
148
|
+
quickFixes?: QuickFix[];
|
|
149
|
+
}
|
|
150
|
+
export interface CompileDiagnostic extends Error {
|
|
124
151
|
code: Readonly<CompileErrorCode>;
|
|
125
152
|
diagnostic: Readonly<string>;
|
|
153
|
+
details?: Readonly<CompileDetails>;
|
|
126
154
|
nodeOrToken: Readonly<SyntaxNode | SyntaxToken>;
|
|
127
155
|
start: Readonly<number>;
|
|
128
156
|
end: Readonly<number>;
|
|
129
|
-
|
|
157
|
+
filepath: Filepath;
|
|
158
|
+
}
|
|
159
|
+
export declare class CompileError extends Error implements CompileDiagnostic {
|
|
160
|
+
code: Readonly<CompileErrorCode>;
|
|
161
|
+
diagnostic: Readonly<string>;
|
|
162
|
+
details?: Readonly<CompileDetails>;
|
|
163
|
+
nodeOrToken: Readonly<SyntaxNode | SyntaxToken>;
|
|
164
|
+
start: Readonly<number>;
|
|
165
|
+
end: Readonly<number>;
|
|
166
|
+
constructor(code: number, message: string, nodeOrToken: SyntaxNode | SyntaxToken, details?: CompileDetails);
|
|
130
167
|
toWarning(): CompileWarning;
|
|
131
168
|
get filepath(): Filepath;
|
|
132
169
|
}
|
|
133
|
-
export declare class CompileWarning extends Error {
|
|
170
|
+
export declare class CompileWarning extends Error implements CompileDiagnostic {
|
|
134
171
|
code: Readonly<CompileErrorCode>;
|
|
135
172
|
diagnostic: Readonly<string>;
|
|
173
|
+
details?: Readonly<CompileDetails>;
|
|
136
174
|
nodeOrToken: Readonly<SyntaxNode | SyntaxToken>;
|
|
137
175
|
start: Readonly<number>;
|
|
138
176
|
end: Readonly<number>;
|
|
139
|
-
constructor(code: number, message: string, nodeOrToken: SyntaxNode | SyntaxToken);
|
|
177
|
+
constructor(code: number, message: string, nodeOrToken: SyntaxNode | SyntaxToken, details?: CompileDetails);
|
|
140
178
|
get filepath(): Filepath;
|
|
141
179
|
}
|
|
142
|
-
export
|
|
143
|
-
title: string;
|
|
144
|
-
filepath: Filepath;
|
|
145
|
-
edits: TextEdit[];
|
|
146
|
-
}
|
|
147
|
-
export declare class CompileInfo extends Error {
|
|
180
|
+
export declare class CompileInfo extends Error implements CompileDiagnostic {
|
|
148
181
|
code: Readonly<CompileErrorCode>;
|
|
149
182
|
diagnostic: Readonly<string>;
|
|
183
|
+
details?: Readonly<CompileDetails>;
|
|
150
184
|
nodeOrToken: Readonly<SyntaxNode | SyntaxToken>;
|
|
151
185
|
start: Readonly<number>;
|
|
152
186
|
end: Readonly<number>;
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
quickFixes?: QuickFix[];
|
|
156
|
-
});
|
|
187
|
+
constructor(code: number, message: string, nodeOrToken: SyntaxNode | SyntaxToken, details?: CompileDetails);
|
|
188
|
+
get quickFixes(): QuickFix[] | undefined;
|
|
157
189
|
get filepath(): Filepath;
|
|
158
190
|
}
|
|
@@ -2,6 +2,7 @@ export declare enum ElementKind {
|
|
|
2
2
|
Table = "table",
|
|
3
3
|
Enum = "enum",
|
|
4
4
|
Ref = "ref",
|
|
5
|
+
Dep = "dep",
|
|
5
6
|
Note = "note",
|
|
6
7
|
Project = "project",
|
|
7
8
|
Indexes = "indexes",
|
|
@@ -13,7 +14,8 @@ export declare enum ElementKind {
|
|
|
13
14
|
DiagramViewTables = "tables",
|
|
14
15
|
DiagramViewNotes = "notes",
|
|
15
16
|
DiagramViewTableGroups = "tablegroups",
|
|
16
|
-
DiagramViewSchemas = "schemas"
|
|
17
|
+
DiagramViewSchemas = "schemas",
|
|
18
|
+
Metadata = "metadata"
|
|
17
19
|
}
|
|
18
20
|
export declare enum SettingName {
|
|
19
21
|
Color = "color",
|
|
@@ -23,6 +25,7 @@ export declare enum SettingName {
|
|
|
23
25
|
PrimaryKey = "primary key",
|
|
24
26
|
Unique = "unique",
|
|
25
27
|
Ref = "ref",
|
|
28
|
+
Dep = "dep",
|
|
26
29
|
NotNull = "not null",
|
|
27
30
|
Null = "null",
|
|
28
31
|
Increment = "increment",
|
|
@@ -110,14 +110,16 @@ export declare class UseSpecifierListNode extends SyntaxNode {
|
|
|
110
110
|
}
|
|
111
111
|
export declare class ElementDeclarationNode extends SyntaxNode {
|
|
112
112
|
type?: SyntaxToken;
|
|
113
|
+
targetKind?: SyntaxToken;
|
|
113
114
|
name?: NormalExpressionNode;
|
|
114
115
|
as?: SyntaxToken;
|
|
115
116
|
alias?: NormalExpressionNode;
|
|
116
117
|
attributeList?: ListExpressionNode;
|
|
117
118
|
bodyColon?: SyntaxToken;
|
|
118
119
|
body?: FunctionApplicationNode | BlockExpressionNode;
|
|
119
|
-
constructor({ type, name, as, alias, attributeList, bodyColon, body, }: {
|
|
120
|
+
constructor({ type, targetKind, name, as, alias, attributeList, bodyColon, body, }: {
|
|
120
121
|
type?: SyntaxToken;
|
|
122
|
+
targetKind?: SyntaxToken;
|
|
121
123
|
name?: NormalExpressionNode;
|
|
122
124
|
as?: SyntaxToken;
|
|
123
125
|
alias?: NormalExpressionNode;
|
|
@@ -125,8 +127,17 @@ export declare class ElementDeclarationNode extends SyntaxNode {
|
|
|
125
127
|
bodyColon?: SyntaxToken;
|
|
126
128
|
body?: BlockExpressionNode | FunctionApplicationNode;
|
|
127
129
|
}, id: SyntaxNodeId, filepath: Filepath);
|
|
128
|
-
isKind(...kinds:
|
|
129
|
-
|
|
130
|
+
isKind<T extends ElementKind>(...kinds: T[]): this is ElementDeclarationNode & {
|
|
131
|
+
type: {
|
|
132
|
+
value: T;
|
|
133
|
+
};
|
|
134
|
+
};
|
|
135
|
+
getElementKind<T extends ElementKind>(this: ElementDeclarationNode & {
|
|
136
|
+
type: {
|
|
137
|
+
value: T;
|
|
138
|
+
};
|
|
139
|
+
}): T;
|
|
140
|
+
getElementKind(this: ElementDeclarationNode): ElementKind | undefined;
|
|
130
141
|
}
|
|
131
142
|
export declare class IdentifierStreamNode extends SyntaxNode {
|
|
132
143
|
identifiers: SyntaxToken[];
|
|
@@ -1,17 +1,21 @@
|
|
|
1
1
|
type BaseRelationshipOp = '>' | '<' | '-' | '<>';
|
|
2
2
|
export type RelationshipOp = `${'?' | ''}${BaseRelationshipOp}${'?' | ''}`;
|
|
3
3
|
export type RelationCardinality = `${number}` | '*' | `${number}..${number | '*'}`;
|
|
4
|
-
export declare function normalizeCardinality(c: RelationCardinality): RelationCardinality;
|
|
5
4
|
export declare function parseCardinality(c: RelationCardinality): {
|
|
6
5
|
min: number;
|
|
7
6
|
max: number | '*';
|
|
8
7
|
};
|
|
9
|
-
export declare const RELATIONSHIP_OPS: ReadonlySet<RelationshipOp>;
|
|
10
8
|
export declare const CARDINALITY_ONE: RelationCardinality;
|
|
11
9
|
export declare const CARDINALITY_MAYBE: RelationCardinality;
|
|
12
10
|
export declare const CARDINALITY_SOME: RelationCardinality;
|
|
13
11
|
export declare const CARDINALITY_MANY: RelationCardinality;
|
|
12
|
+
export declare const RELATIONSHIP_OPS: ReadonlyMap<RelationshipOp, [RelationCardinality, RelationCardinality]>;
|
|
14
13
|
export declare function getMultiplicities(op: string): [RelationCardinality, RelationCardinality] | undefined;
|
|
14
|
+
export declare function isEndpointOneSide(relation: RelationCardinality): boolean;
|
|
15
|
+
export declare function isEndpointManySide(relation: RelationCardinality): boolean;
|
|
16
|
+
export declare function isEndpointOptional(relation: RelationCardinality): boolean;
|
|
17
|
+
export declare function isEndpointRequired(relation: RelationCardinality): boolean;
|
|
18
|
+
export declare function makeRelationshipRequired(op: RelationshipOp): BaseRelationshipOp;
|
|
15
19
|
export declare function getRelationshipOp(left: RelationCardinality, right: RelationCardinality): RelationshipOp;
|
|
16
20
|
export declare function makeCardinalityOptional(rel: RelationCardinality): RelationCardinality;
|
|
17
21
|
export declare function makeCardinalityRequired(rel: RelationCardinality): RelationCardinality;
|
|
@@ -2,6 +2,7 @@ import { NONE_COLOR } from '../../../constants';
|
|
|
2
2
|
import { Filepath } from '../filepath';
|
|
3
3
|
import { Position } from '../position';
|
|
4
4
|
import { RelationshipOp, RelationCardinality } from '../relation';
|
|
5
|
+
export type CustomMetadata = Record<string, string>;
|
|
5
6
|
export type Color = `#${string}` | typeof NONE_COLOR;
|
|
6
7
|
export declare enum AliasKind {
|
|
7
8
|
Table = "table"
|
|
@@ -59,6 +60,7 @@ export interface Database {
|
|
|
59
60
|
tables: Table[];
|
|
60
61
|
notes: Note[];
|
|
61
62
|
refs: Ref[];
|
|
63
|
+
deps: Dep[];
|
|
62
64
|
enums: Enum[];
|
|
63
65
|
tableGroups: TableGroup[];
|
|
64
66
|
aliases: Alias[];
|
|
@@ -86,12 +88,14 @@ export interface Table {
|
|
|
86
88
|
value: string;
|
|
87
89
|
token: TokenPosition;
|
|
88
90
|
};
|
|
91
|
+
metadata?: CustomMetadata;
|
|
89
92
|
}
|
|
90
93
|
export interface Note {
|
|
91
94
|
name: string;
|
|
92
95
|
content: string;
|
|
93
96
|
token: TokenPosition;
|
|
94
97
|
color?: Color;
|
|
98
|
+
metadata?: CustomMetadata;
|
|
95
99
|
}
|
|
96
100
|
export interface ColumnType {
|
|
97
101
|
schemaName: string | null;
|
|
@@ -111,6 +115,7 @@ export interface Column {
|
|
|
111
115
|
type: ColumnType;
|
|
112
116
|
token: TokenPosition;
|
|
113
117
|
inline_refs: InlineRef[];
|
|
118
|
+
inline_deps: InlineDep[];
|
|
114
119
|
checks: Check[];
|
|
115
120
|
pk?: boolean;
|
|
116
121
|
dbdefault?: {
|
|
@@ -124,6 +129,7 @@ export interface Column {
|
|
|
124
129
|
value: string;
|
|
125
130
|
token: TokenPosition;
|
|
126
131
|
};
|
|
132
|
+
metadata?: CustomMetadata;
|
|
127
133
|
}
|
|
128
134
|
export interface Index {
|
|
129
135
|
columns: {
|
|
@@ -171,6 +177,39 @@ export interface RefEndpoint {
|
|
|
171
177
|
relation: RelationCardinality;
|
|
172
178
|
token: TokenPosition;
|
|
173
179
|
}
|
|
180
|
+
export interface Dep {
|
|
181
|
+
schemaName: string | null;
|
|
182
|
+
name: string | null;
|
|
183
|
+
edges: DepEdge[];
|
|
184
|
+
color?: Color;
|
|
185
|
+
note?: {
|
|
186
|
+
value: string;
|
|
187
|
+
token: TokenPosition;
|
|
188
|
+
};
|
|
189
|
+
metadata?: Record<string, string | number | boolean | null>;
|
|
190
|
+
token: TokenPosition;
|
|
191
|
+
}
|
|
192
|
+
export interface DepEdge {
|
|
193
|
+
upstream: DepEndpoint;
|
|
194
|
+
downstream: DepEndpoint;
|
|
195
|
+
token: TokenPosition;
|
|
196
|
+
}
|
|
197
|
+
export interface DepEndpoint {
|
|
198
|
+
schemaName: string | null;
|
|
199
|
+
tableName: string;
|
|
200
|
+
fieldNames: string[];
|
|
201
|
+
token: TokenPosition;
|
|
202
|
+
}
|
|
203
|
+
export declare const DEP_DOWNSTREAM: "->";
|
|
204
|
+
export declare const DEP_UPSTREAM: "<-";
|
|
205
|
+
export type DepDirection = typeof DEP_DOWNSTREAM | typeof DEP_UPSTREAM;
|
|
206
|
+
export interface InlineDep {
|
|
207
|
+
schemaName: string | null;
|
|
208
|
+
tableName: string;
|
|
209
|
+
fieldNames: string[];
|
|
210
|
+
direction: DepDirection;
|
|
211
|
+
token: TokenPosition;
|
|
212
|
+
}
|
|
174
213
|
export interface Enum {
|
|
175
214
|
name: string;
|
|
176
215
|
schemaName: string | null;
|
|
@@ -195,6 +234,7 @@ export interface TableGroup {
|
|
|
195
234
|
value: string;
|
|
196
235
|
token: TokenPosition;
|
|
197
236
|
};
|
|
237
|
+
metadata?: CustomMetadata;
|
|
198
238
|
}
|
|
199
239
|
export interface TableGroupField {
|
|
200
240
|
name: string;
|
|
@@ -238,6 +278,10 @@ export interface TableRecord {
|
|
|
238
278
|
values: RecordValue[][];
|
|
239
279
|
token: TokenPosition;
|
|
240
280
|
}
|
|
281
|
+
export type MetadataValues = Record<string, {
|
|
282
|
+
value: string;
|
|
283
|
+
token: TokenPosition;
|
|
284
|
+
}>;
|
|
241
285
|
export type Project = Record<string, never> | {
|
|
242
286
|
name: string | null;
|
|
243
287
|
tables: Table[];
|
|
@@ -252,4 +296,4 @@ export type Project = Record<string, never> | {
|
|
|
252
296
|
token: TokenPosition;
|
|
253
297
|
[index: string & Omit<any, 'name' | 'tables' | 'refs' | 'enums' | 'tableGroups' | 'note' | 'tablePartials' | 'records'>]: string;
|
|
254
298
|
};
|
|
255
|
-
export type SchemaElement = Database | Project | Table | Note | Column | ColumnType | Index | Check | InlineRef | Ref | RefEndpoint | Enum | EnumField | TableGroup | TableGroupField | Alias | TablePartial | TablePartialInjection | TableRecord | RecordValue;
|
|
299
|
+
export type SchemaElement = Database | Project | Table | Note | Column | ColumnType | Index | Check | InlineRef | InlineDep | Ref | RefEndpoint | Dep | DepEdge | DepEndpoint | Enum | EnumField | TableGroup | TableGroupField | Alias | TablePartial | TablePartialInjection | TableRecord | RecordValue | MetadataValues;
|
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
import { default as Compiler } from '../../../compiler';
|
|
2
|
-
import { AttributeNode, ElementDeclarationNode, SyntaxNode } from '../nodes';
|
|
2
|
+
import { AttributeNode, ElementDeclarationNode, InfixExpressionNode, SyntaxNode } from '../nodes';
|
|
3
3
|
import { SyntaxToken } from '../tokens';
|
|
4
|
-
import { ColumnSymbol, NodeSymbol, TablePartialSymbol, TableSymbol } from '../symbol';
|
|
4
|
+
import { ColumnSymbol, NodeSymbol, ProgramSymbol, TablePartialSymbol, TableSymbol } from '../symbol';
|
|
5
5
|
import { Internable } from '../internable';
|
|
6
6
|
import { RelationshipOp, RelationCardinality } from '../relation';
|
|
7
7
|
export declare enum MetadataKind {
|
|
8
8
|
Ref = "ref",
|
|
9
|
+
Dep = "dep",
|
|
9
10
|
PartialRef = "partial ref",
|
|
10
11
|
TableChecks = "table checks",
|
|
11
12
|
Indexes = "indexes",
|
|
12
13
|
Records = "records",
|
|
13
|
-
Project = "project"
|
|
14
|
+
Project = "project",
|
|
15
|
+
MetadataElement = "metadata element"
|
|
14
16
|
}
|
|
15
17
|
declare const __nodeMetadataBrand: unique symbol;
|
|
16
18
|
export type NodeMetadataId = number & {
|
|
@@ -28,6 +30,11 @@ export declare abstract class NodeMetadata implements Internable<InternedNodeMet
|
|
|
28
30
|
constructor(declaration: SyntaxNode);
|
|
29
31
|
intern(): InternedNodeMetadata;
|
|
30
32
|
abstract owners(compiler: Compiler): NodeSymbol[];
|
|
33
|
+
/** Get programs (source files) that can both
|
|
34
|
+
* - reach this metadata's declaration file and
|
|
35
|
+
* - see all the given target symbols in their nested schema.
|
|
36
|
+
*/
|
|
37
|
+
resolveOwnerPrograms(compiler: Compiler, targets: NodeSymbol[]): ProgramSymbol[];
|
|
31
38
|
}
|
|
32
39
|
export declare class RefMetadata extends NodeMetadata {
|
|
33
40
|
declaration: ElementDeclarationNode | AttributeNode;
|
|
@@ -54,6 +61,19 @@ export declare class RefMetadata extends NodeMetadata {
|
|
|
54
61
|
rightToken(): SyntaxNode;
|
|
55
62
|
owners(compiler: Compiler): NodeSymbol[];
|
|
56
63
|
}
|
|
64
|
+
export declare class DepMetadata extends NodeMetadata {
|
|
65
|
+
declaration: ElementDeclarationNode | AttributeNode;
|
|
66
|
+
readonly kind = MetadataKind.Dep;
|
|
67
|
+
constructor(declaration: ElementDeclarationNode | AttributeNode);
|
|
68
|
+
container(compiler: Compiler): TableSymbol | undefined;
|
|
69
|
+
edgeExpressions(): InfixExpressionNode[];
|
|
70
|
+
upstreamColumns(compiler: Compiler): ColumnSymbol[][];
|
|
71
|
+
downstreamColumns(compiler: Compiler): ColumnSymbol[][];
|
|
72
|
+
upstreamTables(compiler: Compiler): (TableSymbol | undefined)[];
|
|
73
|
+
downstreamTables(compiler: Compiler): (TableSymbol | undefined)[];
|
|
74
|
+
private hostColumn;
|
|
75
|
+
owners(compiler: Compiler): NodeSymbol[];
|
|
76
|
+
}
|
|
57
77
|
export declare class PartialRefMetadata extends NodeMetadata {
|
|
58
78
|
readonly kind = MetadataKind.PartialRef;
|
|
59
79
|
constructor(declaration: SyntaxNode);
|
|
@@ -65,14 +85,6 @@ export declare class PartialRefMetadata extends NodeMetadata {
|
|
|
65
85
|
op(_compiler: Compiler): RelationshipOp | undefined;
|
|
66
86
|
opToken(): SyntaxToken | undefined;
|
|
67
87
|
cardinalities(compiler: Compiler): [RelationCardinality, RelationCardinality] | undefined;
|
|
68
|
-
leftCardinality(compiler: Compiler): {
|
|
69
|
-
min: number;
|
|
70
|
-
max: number | '*';
|
|
71
|
-
} | undefined;
|
|
72
|
-
rightCardinality(compiler: Compiler): {
|
|
73
|
-
min: number;
|
|
74
|
-
max: number | '*';
|
|
75
|
-
} | undefined;
|
|
76
88
|
leftToken(): SyntaxNode;
|
|
77
89
|
rightToken(): SyntaxNode;
|
|
78
90
|
owners(compiler: Compiler): NodeSymbol[];
|
|
@@ -95,6 +107,13 @@ export declare class RecordsMetadata extends NodeMetadata {
|
|
|
95
107
|
table(compiler: Compiler): TableSymbol | undefined;
|
|
96
108
|
owners(compiler: Compiler): NodeSymbol[];
|
|
97
109
|
}
|
|
110
|
+
export declare class MetadataElementMetadata extends NodeMetadata {
|
|
111
|
+
declaration: ElementDeclarationNode;
|
|
112
|
+
readonly kind = MetadataKind.MetadataElement;
|
|
113
|
+
constructor(declaration: ElementDeclarationNode);
|
|
114
|
+
target(compiler: Compiler): NodeSymbol | undefined;
|
|
115
|
+
owners(compiler: Compiler): NodeSymbol[];
|
|
116
|
+
}
|
|
98
117
|
export declare class ProjectMetadata extends NodeMetadata {
|
|
99
118
|
readonly kind = MetadataKind.Project;
|
|
100
119
|
constructor(declaration: SyntaxNode);
|
|
@@ -24,6 +24,7 @@ export declare enum SymbolKind {
|
|
|
24
24
|
DiagramViewTableGroup = "DiagramView tablegroup",
|
|
25
25
|
DiagramViewNote = "DiagramView note",
|
|
26
26
|
DiagramViewSchema = "DiagramView schema",
|
|
27
|
+
Metadata = "Metadata",
|
|
27
28
|
Program = "Program"
|
|
28
29
|
}
|
|
29
30
|
export declare const ImportKind: {
|
|
@@ -35,6 +36,13 @@ export declare const ImportKind: {
|
|
|
35
36
|
Schema: SymbolKind;
|
|
36
37
|
};
|
|
37
38
|
export type ImportKind = (typeof ImportKind)[keyof typeof ImportKind];
|
|
39
|
+
/** Allowed target element types for a Metadata element header */
|
|
40
|
+
export declare enum MetadataTargetKind {
|
|
41
|
+
Table = "Table",
|
|
42
|
+
Column = "Column",
|
|
43
|
+
TableGroup = "TableGroup",
|
|
44
|
+
Note = "Note"
|
|
45
|
+
}
|
|
38
46
|
declare const __nodeSymbolBrand: unique symbol;
|
|
39
47
|
export type NodeSymbolId = number & {
|
|
40
48
|
readonly [__nodeSymbolBrand]: true;
|
|
@@ -147,11 +155,12 @@ export declare class ColumnSymbol extends NodeSymbol {
|
|
|
147
155
|
}, id: NodeSymbolId, filepath: Filepath);
|
|
148
156
|
get canBeImported(): boolean;
|
|
149
157
|
get originalSymbol(): NodeSymbol;
|
|
150
|
-
qualifiedName(compiler: Compiler): string;
|
|
158
|
+
qualifiedName(compiler: Compiler): string[];
|
|
151
159
|
pk(compiler: Compiler): boolean;
|
|
152
160
|
isUniqueSet(compiler: Compiler): boolean;
|
|
153
161
|
unique(compiler: Compiler): boolean;
|
|
154
162
|
nullable(compiler: Compiler): boolean;
|
|
163
|
+
private isInPkIndex;
|
|
155
164
|
isNotNullSet(compiler: Compiler): boolean | undefined;
|
|
156
165
|
isIncrementSet(compiler: Compiler): boolean;
|
|
157
166
|
increment(compiler: Compiler): boolean;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export { refNullableMismatch, refNotNullMismatch, refUniqueMismatch, refNonUniqueMismatch, } from './ref';
|
|
2
|
+
export { recordsNullNotAllowed, recordsInvalidEnum, recordsInvalidNumeric, recordsInvalidInteger, recordsExceedsPrecision, recordsExceedsScale, recordsInvalidBoolean, recordsInvalidDatetime, recordsInvalidString, recordsStringTooLong, recordsPkNull, recordsPkDuplicate, recordsPkMissing, recordsFkNull, recordsFkNotFound, recordsUniqueDuplicate, } from './records';
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { default as Compiler } from '../../../compiler';
|
|
2
|
+
import { CompileInfo } from '../../types/errors';
|
|
3
|
+
import { SyntaxNode } from '../../types/nodes';
|
|
4
|
+
import { SyntaxToken } from '../../types/tokens';
|
|
5
|
+
import { ColumnSymbol } from '../../types/symbol';
|
|
6
|
+
import { Filepath } from '../../types/filepath';
|
|
7
|
+
import { TableSymbol } from '../../types/symbol/symbols';
|
|
8
|
+
export declare function recordsNullNotAllowed(node: SyntaxNode | SyntaxToken, options: {
|
|
9
|
+
colName: string;
|
|
10
|
+
}): CompileInfo;
|
|
11
|
+
export declare function recordsInvalidEnum(node: SyntaxNode | SyntaxToken, options: {
|
|
12
|
+
colName: string;
|
|
13
|
+
}): CompileInfo;
|
|
14
|
+
export declare function recordsInvalidNumeric(node: SyntaxNode | SyntaxToken, options: {
|
|
15
|
+
colName: string;
|
|
16
|
+
typeName: string;
|
|
17
|
+
}): CompileInfo;
|
|
18
|
+
export declare function recordsInvalidInteger(node: SyntaxNode | SyntaxToken, options: {
|
|
19
|
+
colName: string;
|
|
20
|
+
value: number;
|
|
21
|
+
}): CompileInfo;
|
|
22
|
+
export declare function recordsExceedsPrecision(node: SyntaxNode | SyntaxToken, options: {
|
|
23
|
+
colName: string;
|
|
24
|
+
typeName: string;
|
|
25
|
+
value: number;
|
|
26
|
+
precision: number;
|
|
27
|
+
scale: number;
|
|
28
|
+
totalDigits: number;
|
|
29
|
+
}): CompileInfo;
|
|
30
|
+
export declare function recordsExceedsScale(node: SyntaxNode | SyntaxToken, options: {
|
|
31
|
+
colName: string;
|
|
32
|
+
typeName: string;
|
|
33
|
+
value: number;
|
|
34
|
+
precision: number;
|
|
35
|
+
scale: number;
|
|
36
|
+
decimalDigits: number;
|
|
37
|
+
}): CompileInfo;
|
|
38
|
+
export declare function recordsInvalidBoolean(node: SyntaxNode | SyntaxToken, options: {
|
|
39
|
+
colName: string;
|
|
40
|
+
}): CompileInfo;
|
|
41
|
+
export declare function recordsInvalidDatetime(node: SyntaxNode | SyntaxToken, options: {
|
|
42
|
+
colName: string;
|
|
43
|
+
}): CompileInfo;
|
|
44
|
+
export declare function recordsInvalidString(node: SyntaxNode | SyntaxToken, options: {
|
|
45
|
+
colName: string;
|
|
46
|
+
}): CompileInfo;
|
|
47
|
+
export declare function recordsStringTooLong(node: SyntaxNode | SyntaxToken, options: {
|
|
48
|
+
colName: string;
|
|
49
|
+
typeName: string;
|
|
50
|
+
typeArg: string;
|
|
51
|
+
maxLength: number;
|
|
52
|
+
actualLength: number;
|
|
53
|
+
}): CompileInfo;
|
|
54
|
+
export declare function recordsPkNull(compiler: Compiler, node: SyntaxNode | SyntaxToken, options: {
|
|
55
|
+
table: TableSymbol;
|
|
56
|
+
columns: ColumnSymbol[];
|
|
57
|
+
}): CompileInfo;
|
|
58
|
+
export declare function recordsPkDuplicate(compiler: Compiler, node: SyntaxNode | SyntaxToken, options: {
|
|
59
|
+
table: TableSymbol;
|
|
60
|
+
columns: ColumnSymbol[];
|
|
61
|
+
valueStr: string;
|
|
62
|
+
}): CompileInfo;
|
|
63
|
+
export declare function recordsPkMissing(compiler: Compiler, node: SyntaxNode | SyntaxToken, options: {
|
|
64
|
+
table: TableSymbol;
|
|
65
|
+
columns: ColumnSymbol[];
|
|
66
|
+
}): CompileInfo;
|
|
67
|
+
export declare function recordsFkNull(compiler: Compiler, node: SyntaxNode | SyntaxToken, options: {
|
|
68
|
+
leftTable: TableSymbol;
|
|
69
|
+
leftColumns: ColumnSymbol[];
|
|
70
|
+
rightTable: TableSymbol;
|
|
71
|
+
rightColumns: ColumnSymbol[];
|
|
72
|
+
filepath: Filepath;
|
|
73
|
+
valueStr: string;
|
|
74
|
+
}): CompileInfo;
|
|
75
|
+
export declare function recordsFkNotFound(compiler: Compiler, node: SyntaxNode | SyntaxToken, options: {
|
|
76
|
+
leftTable: TableSymbol;
|
|
77
|
+
leftColumns: ColumnSymbol[];
|
|
78
|
+
rightTable: TableSymbol;
|
|
79
|
+
rightColumns: ColumnSymbol[];
|
|
80
|
+
filepath: Filepath;
|
|
81
|
+
valueStr: string;
|
|
82
|
+
}): CompileInfo;
|
|
83
|
+
export declare function recordsUniqueDuplicate(compiler: Compiler, node: SyntaxNode | SyntaxToken, options: {
|
|
84
|
+
table: TableSymbol;
|
|
85
|
+
columns: ColumnSymbol[];
|
|
86
|
+
valueStr: string;
|
|
87
|
+
}): CompileInfo;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { default as Compiler } from '../../../compiler';
|
|
2
|
+
import { CompileInfo, QuickFix } from '../../types/errors';
|
|
3
|
+
import { SyntaxNode } from '../../types/nodes';
|
|
4
|
+
import { SyntaxToken } from '../../types/tokens';
|
|
5
|
+
import { ColumnSymbol } from '../../types/symbol';
|
|
6
|
+
import { RelationshipOp } from '../../types/relation';
|
|
7
|
+
export declare function refNullableMismatch(compiler: Compiler, node: SyntaxNode | SyntaxToken, options: {
|
|
8
|
+
relOp: RelationshipOp;
|
|
9
|
+
columns: ColumnSymbol[];
|
|
10
|
+
refNode: SyntaxNode;
|
|
11
|
+
quickFixes?: QuickFix[];
|
|
12
|
+
}): CompileInfo;
|
|
13
|
+
export declare function refNotNullMismatch(compiler: Compiler, node: SyntaxNode | SyntaxToken, options: {
|
|
14
|
+
relOp: RelationshipOp;
|
|
15
|
+
columns: ColumnSymbol[];
|
|
16
|
+
refNode: SyntaxNode;
|
|
17
|
+
quickFixes?: QuickFix[];
|
|
18
|
+
}): CompileInfo;
|
|
19
|
+
export declare function refUniqueMismatch(compiler: Compiler, node: SyntaxNode | SyntaxToken, options: {
|
|
20
|
+
relOp: RelationshipOp;
|
|
21
|
+
columns: ColumnSymbol[];
|
|
22
|
+
refNode: SyntaxNode;
|
|
23
|
+
quickFixes?: QuickFix[];
|
|
24
|
+
}): CompileInfo;
|
|
25
|
+
export declare function refNonUniqueMismatch(compiler: Compiler, node: SyntaxNode | SyntaxToken, options: {
|
|
26
|
+
relOp: RelationshipOp;
|
|
27
|
+
columns: ColumnSymbol[];
|
|
28
|
+
refNode: SyntaxNode;
|
|
29
|
+
quickFixes?: QuickFix[];
|
|
30
|
+
}): CompileInfo;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ElementDeclarationNode, FunctionApplicationNode, FunctionExpressionNode, IdentifierStreamNode, PrimaryExpressionNode, SyntaxNode, TupleExpressionNode, VariableNode } from '../types/nodes';
|
|
1
|
+
import { AttributeNode, ElementDeclarationNode, FunctionApplicationNode, FunctionExpressionNode, IdentifierStreamNode, PrimaryExpressionNode, SyntaxNode, TupleExpressionNode, VariableNode } from '../types/nodes';
|
|
2
2
|
import { SyntaxToken } from '../types/tokens';
|
|
3
3
|
export declare function extractVariableNode(value?: unknown): SyntaxToken | undefined;
|
|
4
4
|
export declare function extractStringFromIdentifierStream(stream?: IdentifierStreamNode): string | undefined;
|
|
@@ -35,3 +35,4 @@ export declare function extractVariableFromExpression(node?: SyntaxNode): string
|
|
|
35
35
|
export declare function extractVarNameFromPrimaryVariable(node?: PrimaryExpressionNode & {
|
|
36
36
|
expression: VariableNode;
|
|
37
37
|
}): string | undefined;
|
|
38
|
+
export declare function extractSettingName(attr: AttributeNode): string | undefined;
|