@dbml/parse 10.0.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 +24 -20
- package/dist/dbml-parse.mjs +2849 -2599
- 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/types/errors.d.ts +37 -14
- 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/span.d.ts +2 -0
- package/dist/src/services/diagnostics/provider.d.ts +13 -0
- package/dist/src/services/index.d.ts +1 -1
- package/package.json +2 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { default as Compiler } from '../../../../../compiler/index';
|
|
2
|
-
import {
|
|
2
|
+
import { CompileInfo } from '../../../../types/errors';
|
|
3
3
|
import { Filepath } from '../../../../types/filepath';
|
|
4
4
|
import { SyntaxNode } from '../../../../types/nodes';
|
|
5
5
|
import { Ref, TableRecord } from '../../../../types/schemaJson';
|
|
@@ -10,4 +10,4 @@ export type TableInfo = {
|
|
|
10
10
|
record: TableRecord | undefined;
|
|
11
11
|
recordBlock: SyntaxNode | undefined;
|
|
12
12
|
};
|
|
13
|
-
export declare function validateForeignKeys(compiler: Compiler, allRefs: Ref[], allRecords: Map<InternedNodeSymbol, TableInfo>, filepath: Filepath):
|
|
13
|
+
export declare function validateForeignKeys(compiler: Compiler, allRefs: Ref[], allRecords: Map<InternedNodeSymbol, TableInfo>, filepath: Filepath): CompileInfo[];
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { default as Compiler } from '../../../../../compiler/index';
|
|
2
|
-
import { CompileWarning } from '../../../../types/errors';
|
|
3
2
|
import { RecordValue, TableRecord } from '../../../../types/schemaJson';
|
|
4
3
|
import { ColumnSymbol } from '../../../../types/symbol';
|
|
5
4
|
export declare function toKeyedRows(record: TableRecord): Record<string, RecordValue>[];
|
|
@@ -10,4 +9,4 @@ export declare function formatFullColumnName(schemaName: string | null, tableNam
|
|
|
10
9
|
export declare function formatFullColumnNames(schemaName: string | null, tableName: string, columnNames: string[]): string;
|
|
11
10
|
export declare function formatValues(compiler: Compiler, row: Record<string, RecordValue>, columns: ColumnSymbol[]): string;
|
|
12
11
|
export declare function getDiagnosticAnchorValues(row: Record<string, RecordValue>, columnNames: string[]): RecordValue[];
|
|
13
|
-
export declare function
|
|
12
|
+
export declare function resolveRecordValueNode(compiler: Compiler, recordValue: RecordValue): import('../../../../..').SyntaxNode | import('../../../../..').SyntaxToken | Readonly<import('../../../../..').ProgramNode>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { default as Compiler } from '../../../../../compiler/index';
|
|
2
|
-
import {
|
|
2
|
+
import { CompileInfo } from '../../../../types/errors';
|
|
3
3
|
import { SyntaxNode } from '../../../../types/nodes';
|
|
4
4
|
import { TableRecord } from '../../../../types/schemaJson';
|
|
5
5
|
import { TableSymbol } from '../../../../types/symbol';
|
|
6
|
-
export declare function validatePrimaryKey(compiler: Compiler, tableSymbol: TableSymbol, recordBlock: SyntaxNode, record: TableRecord):
|
|
6
|
+
export declare function validatePrimaryKey(compiler: Compiler, tableSymbol: TableSymbol, recordBlock: SyntaxNode, record: TableRecord): CompileInfo[];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { default as Compiler } from '../../../../../compiler/index';
|
|
2
|
-
import {
|
|
2
|
+
import { CompileInfo } from '../../../../types/errors';
|
|
3
3
|
import { TableRecord } from '../../../../types/schemaJson';
|
|
4
4
|
import { TableSymbol } from '../../../../types/symbol';
|
|
5
|
-
export declare function validateUnique(compiler: Compiler, tableSymbol: TableSymbol, record: TableRecord):
|
|
5
|
+
export declare function validateUnique(compiler: Compiler, tableSymbol: TableSymbol, record: TableRecord): CompileInfo[];
|
|
@@ -129,39 +129,62 @@ export interface RelatedLocation {
|
|
|
129
129
|
nodeOrToken: SyntaxNode | SyntaxToken;
|
|
130
130
|
message: string;
|
|
131
131
|
}
|
|
132
|
-
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 {
|
|
133
151
|
code: Readonly<CompileErrorCode>;
|
|
134
152
|
diagnostic: Readonly<string>;
|
|
153
|
+
details?: Readonly<CompileDetails>;
|
|
135
154
|
nodeOrToken: Readonly<SyntaxNode | SyntaxToken>;
|
|
136
155
|
start: Readonly<number>;
|
|
137
156
|
end: Readonly<number>;
|
|
138
|
-
|
|
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);
|
|
139
167
|
toWarning(): CompileWarning;
|
|
140
168
|
get filepath(): Filepath;
|
|
141
169
|
}
|
|
142
|
-
export declare class CompileWarning extends Error {
|
|
170
|
+
export declare class CompileWarning extends Error implements CompileDiagnostic {
|
|
143
171
|
code: Readonly<CompileErrorCode>;
|
|
144
172
|
diagnostic: Readonly<string>;
|
|
173
|
+
details?: Readonly<CompileDetails>;
|
|
145
174
|
nodeOrToken: Readonly<SyntaxNode | SyntaxToken>;
|
|
146
175
|
start: Readonly<number>;
|
|
147
176
|
end: Readonly<number>;
|
|
148
|
-
constructor(code: number, message: string, nodeOrToken: SyntaxNode | SyntaxToken);
|
|
177
|
+
constructor(code: number, message: string, nodeOrToken: SyntaxNode | SyntaxToken, details?: CompileDetails);
|
|
149
178
|
get filepath(): Filepath;
|
|
150
179
|
}
|
|
151
|
-
export
|
|
152
|
-
title: string;
|
|
153
|
-
filepath: Filepath;
|
|
154
|
-
edits: TextEdit[];
|
|
155
|
-
}
|
|
156
|
-
export declare class CompileInfo extends Error {
|
|
180
|
+
export declare class CompileInfo extends Error implements CompileDiagnostic {
|
|
157
181
|
code: Readonly<CompileErrorCode>;
|
|
158
182
|
diagnostic: Readonly<string>;
|
|
183
|
+
details?: Readonly<CompileDetails>;
|
|
159
184
|
nodeOrToken: Readonly<SyntaxNode | SyntaxToken>;
|
|
160
185
|
start: Readonly<number>;
|
|
161
186
|
end: Readonly<number>;
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
quickFixes?: QuickFix[];
|
|
165
|
-
});
|
|
187
|
+
constructor(code: number, message: string, nodeOrToken: SyntaxNode | SyntaxToken, details?: CompileDetails);
|
|
188
|
+
get quickFixes(): QuickFix[] | undefined;
|
|
166
189
|
get filepath(): Filepath;
|
|
167
190
|
}
|
|
@@ -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,6 @@
|
|
|
1
|
+
import { default as Compiler } from '../../compiler';
|
|
1
2
|
import { ElementDeclarationNode, SyntaxNode } from '../types/nodes';
|
|
2
3
|
import { SyntaxToken } from '../types/tokens';
|
|
3
4
|
export declare function isOffsetWithinSpan(offset: number, nodeOrToken: SyntaxNode | SyntaxToken): boolean;
|
|
4
5
|
export declare function isOffsetWithinElementHeader(offset: number, element: ElementDeclarationNode): boolean;
|
|
6
|
+
export declare function getSourceSnippet(compiler: Compiler, node: SyntaxNode | SyntaxToken): string | undefined;
|
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
import { default as Compiler } from '../../compiler';
|
|
2
2
|
import { Filepath } from '../../core/types/filepath';
|
|
3
3
|
import { MarkerData } from '../types';
|
|
4
|
+
export interface DiagnosticQuickFix {
|
|
5
|
+
title: string;
|
|
6
|
+
shortTitle?: string;
|
|
7
|
+
edits: {
|
|
8
|
+
start: number;
|
|
9
|
+
end: number;
|
|
10
|
+
newText: string;
|
|
11
|
+
}[];
|
|
12
|
+
isPreferred?: boolean;
|
|
13
|
+
}
|
|
4
14
|
export interface Diagnostic {
|
|
5
15
|
type: 'error' | 'warning' | 'info';
|
|
6
16
|
text: string;
|
|
@@ -9,7 +19,10 @@ export interface Diagnostic {
|
|
|
9
19
|
endRow: number;
|
|
10
20
|
endColumn: number;
|
|
11
21
|
code?: string | number;
|
|
22
|
+
category?: string;
|
|
23
|
+
explanation?: string;
|
|
12
24
|
filepath: Filepath;
|
|
25
|
+
quickFixes?: DiagnosticQuickFix[];
|
|
13
26
|
}
|
|
14
27
|
export default class DBMLDiagnosticsProvider {
|
|
15
28
|
private compiler;
|
|
@@ -3,7 +3,7 @@ import { default as DBMLDefinitionProvider } from './definition/provider';
|
|
|
3
3
|
import { default as DBMLDiagnosticsProvider } from './diagnostics/provider';
|
|
4
4
|
import { default as DBMLReferencesProvider } from './references/provider';
|
|
5
5
|
import { default as DBMLCompletionItemProvider } from './suggestions/provider';
|
|
6
|
-
export type { Diagnostic } from './diagnostics/provider';
|
|
6
|
+
export type { Diagnostic, DiagnosticQuickFix } from './diagnostics/provider';
|
|
7
7
|
export * from './types';
|
|
8
8
|
export { DBMLCodeActionProvider, DBMLCompletionItemProvider, DBMLDefinitionProvider, DBMLReferencesProvider, DBMLDiagnosticsProvider, };
|
|
9
9
|
export { dbmlMonarchTokensProvider } from './monarch';
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package",
|
|
3
3
|
"name": "@dbml/parse",
|
|
4
|
-
"version": "10.0.0",
|
|
4
|
+
"version": "10.1.0-alpha.0",
|
|
5
5
|
"description": "DBML parser v2",
|
|
6
6
|
"author": "Holistics <dev@holistics.io>",
|
|
7
7
|
"license": "Apache-2.0",
|
|
@@ -51,5 +51,5 @@
|
|
|
51
51
|
"engines": {
|
|
52
52
|
"node": ">=18"
|
|
53
53
|
},
|
|
54
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "b9c9c643d79c2ab0677852a1742fb3cc57561f73"
|
|
55
55
|
}
|