@dbml/parse 6.2.0-alpha.0 → 6.2.1
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/__tests__/utils/compiler.d.ts +5 -5
- package/dist/__tests__/utils/mocks.d.ts +0 -1
- package/dist/__tests__/utils/testHelpers.d.ts +2 -2
- package/dist/dbml-parse.js +12 -33
- package/dist/dbml-parse.mjs +5297 -17115
- package/dist/src/compiler/index.d.ts +4 -8
- package/dist/src/compiler/queries/parse.d.ts +1 -2
- package/dist/src/compiler/queries/transform/index.d.ts +1 -2
- package/dist/src/compiler/queries/transform/renameTable.d.ts +4 -1
- package/dist/src/compiler/types.d.ts +1 -2
- package/dist/src/core/analyzer/analyzer.d.ts +3 -2
- package/dist/src/core/analyzer/binder/binder.d.ts +2 -1
- package/dist/src/core/analyzer/binder/utils.d.ts +1 -2
- package/dist/src/core/analyzer/types.d.ts +1 -2
- package/dist/src/core/analyzer/utils.d.ts +1 -11
- package/dist/src/core/analyzer/validator/utils.d.ts +3 -3
- package/dist/src/core/analyzer/validator/validator.d.ts +2 -1
- package/dist/src/core/errors.d.ts +1 -15
- package/dist/src/core/interpreter/interpreter.d.ts +2 -1
- package/dist/src/core/interpreter/types.d.ts +2 -39
- package/dist/src/core/interpreter/utils.d.ts +3 -4
- package/dist/src/core/lexer/lexer.d.ts +2 -1
- package/dist/src/core/parser/nodes.d.ts +6 -17
- package/dist/src/core/parser/parser.d.ts +4 -6
- package/dist/src/core/parser/utils.d.ts +3 -3
- package/dist/src/core/report.d.ts +5 -8
- package/dist/src/core/serialization/serialize.d.ts +4 -0
- package/dist/src/core/utils.d.ts +1 -0
- package/dist/src/index.d.ts +4 -3
- package/dist/src/services/index.d.ts +1 -2
- package/dist/src/services/suggestions/utils.d.ts +1 -27
- package/dist/src/services/types.d.ts +2 -13
- package/package.json +6 -18
- package/dist/__tests__/examples/compiler/stringUtils.test.d.ts +0 -1
- package/dist/__tests__/examples/interpreter/record/data.test.d.ts +0 -1
- package/dist/__tests__/examples/interpreter/record/fk.test.d.ts +0 -1
- package/dist/__tests__/examples/interpreter/record/increment.test.d.ts +0 -1
- package/dist/__tests__/examples/interpreter/record/multi_records.test.d.ts +0 -1
- package/dist/__tests__/examples/interpreter/record/pk.test.d.ts +0 -1
- package/dist/__tests__/examples/interpreter/record/table_partial.test.d.ts +0 -1
- package/dist/__tests__/examples/interpreter/record/type_compatibility.test.d.ts +0 -1
- package/dist/__tests__/examples/interpreter/record/unique.test.d.ts +0 -1
- package/dist/__tests__/examples/lexer/scientific-notation.test.d.ts +0 -1
- package/dist/__tests__/examples/services/definition/general.test.d.ts +0 -1
- package/dist/__tests__/examples/services/definition/records.test.d.ts +0 -1
- package/dist/__tests__/examples/services/references/general.test.d.ts +0 -1
- package/dist/__tests__/examples/services/references/records.test.d.ts +0 -1
- package/dist/__tests__/examples/services/suggestions/general.test.d.ts +0 -1
- package/dist/__tests__/examples/services/suggestions/suggestions_records.test.d.ts +0 -1
- package/dist/__tests__/examples/validator/records.test.d.ts +0 -1
- package/dist/src/compiler/queries/transform/utils.d.ts +0 -22
- package/dist/src/compiler/queries/utils.d.ts +0 -95
- package/dist/src/core/analyzer/binder/elementBinder/records.d.ts +0 -22
- package/dist/src/core/analyzer/validator/elementValidators/records.d.ts +0 -26
- package/dist/src/core/interpreter/records/index.d.ts +0 -10
- package/dist/src/core/interpreter/records/utils/constraints/fk.d.ts +0 -3
- package/dist/src/core/interpreter/records/utils/constraints/helper.d.ts +0 -10
- package/dist/src/core/interpreter/records/utils/constraints/index.d.ts +0 -3
- package/dist/src/core/interpreter/records/utils/constraints/pk.d.ts +0 -3
- package/dist/src/core/interpreter/records/utils/constraints/unique.d.ts +0 -3
- package/dist/src/core/interpreter/records/utils/data/index.d.ts +0 -2
- package/dist/src/core/interpreter/records/utils/data/sqlTypes.d.ts +0 -19
- package/dist/src/core/interpreter/records/utils/data/values.d.ts +0 -14
- package/dist/src/core/interpreter/records/utils/index.d.ts +0 -2
- package/dist/src/services/diagnostics/provider.d.ts +0 -34
- package/dist/src/services/suggestions/recordRowSnippet.d.ts +0 -3
- /package/dist/__tests__/examples/{binder/records.test.d.ts → services/definition.test.d.ts} +0 -0
- /package/dist/__tests__/examples/{compiler/identifierUtils.test.d.ts → services/references.test.d.ts} +0 -0
- /package/dist/__tests__/examples/{compiler/splitQualifiedIdentifier.test.d.ts → services/suggestions.test.d.ts} +0 -0
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import { ProgramNode } from '../core/parser/nodes';
|
|
2
2
|
import { SyntaxToken } from '../core/lexer/tokens';
|
|
3
|
+
import { CompileError } from '../core/errors';
|
|
3
4
|
import { Database } from '../core/interpreter/types';
|
|
4
5
|
import { default as Report } from '../core/report';
|
|
5
|
-
import { DBMLCompletionItemProvider, DBMLDefinitionProvider, DBMLReferencesProvider
|
|
6
|
+
import { DBMLCompletionItemProvider, DBMLDefinitionProvider, DBMLReferencesProvider } from '../services/index';
|
|
6
7
|
import { TextEdit, TableNameInput } from './queries/transform';
|
|
7
|
-
import { splitQualifiedIdentifier, unescapeString, escapeString, formatRecordValue, isValidIdentifier, addDoubleQuoteIfNeeded } from './queries/utils';
|
|
8
8
|
export { ScopeKind } from './types';
|
|
9
|
-
export type { TextEdit, TableNameInput };
|
|
10
|
-
export { splitQualifiedIdentifier, unescapeString, escapeString, formatRecordValue, isValidIdentifier, addDoubleQuoteIfNeeded };
|
|
11
9
|
export default class Compiler {
|
|
12
10
|
private source;
|
|
13
11
|
private cache;
|
|
@@ -28,10 +26,9 @@ export default class Compiler {
|
|
|
28
26
|
ast: ProgramNode;
|
|
29
27
|
tokens: SyntaxToken[];
|
|
30
28
|
rawDb?: Database;
|
|
31
|
-
}>;
|
|
29
|
+
}, CompileError>;
|
|
32
30
|
ast: () => Readonly<ProgramNode>;
|
|
33
|
-
errors: () => readonly Readonly<
|
|
34
|
-
warnings: () => readonly Readonly<import('../core/errors').CompileWarning>[];
|
|
31
|
+
errors: () => readonly Readonly<CompileError>[];
|
|
35
32
|
tokens: () => Readonly<SyntaxToken>[];
|
|
36
33
|
rawDb: () => Readonly<Database> | undefined;
|
|
37
34
|
publicSymbolTable: () => Readonly<import('../core/analyzer/symbol/symbolTable').default>;
|
|
@@ -65,6 +62,5 @@ export default class Compiler {
|
|
|
65
62
|
definitionProvider: DBMLDefinitionProvider;
|
|
66
63
|
referenceProvider: DBMLReferencesProvider;
|
|
67
64
|
autocompletionProvider: DBMLCompletionItemProvider;
|
|
68
|
-
diagnosticsProvider: DBMLDiagnosticsProvider;
|
|
69
65
|
};
|
|
70
66
|
}
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { default as Compiler } from '../index';
|
|
2
2
|
import { ProgramNode } from '../../core/parser/nodes';
|
|
3
3
|
import { SyntaxToken } from '../../core/lexer/tokens';
|
|
4
|
-
import { CompileError
|
|
4
|
+
import { CompileError } from '../../core/errors';
|
|
5
5
|
import { Database } from '../../core/interpreter/types';
|
|
6
6
|
import { default as SymbolTable } from '../../core/analyzer/symbol/symbolTable';
|
|
7
7
|
export declare function ast(this: Compiler): Readonly<ProgramNode>;
|
|
8
8
|
export declare function errors(this: Compiler): readonly Readonly<CompileError>[];
|
|
9
|
-
export declare function warnings(this: Compiler): readonly Readonly<CompileWarning>[];
|
|
10
9
|
export declare function tokens(this: Compiler): Readonly<SyntaxToken>[];
|
|
11
10
|
export declare function rawDb(this: Compiler): Readonly<Database> | undefined;
|
|
12
11
|
export declare function publicSymbolTable(this: Compiler): Readonly<SymbolTable>;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { ProgramNode } from '../parser/nodes';
|
|
2
2
|
import { default as Report } from '../report';
|
|
3
|
+
import { CompileError } from '../errors';
|
|
3
4
|
import { NodeSymbolIdGenerator } from './symbol/symbols';
|
|
4
5
|
export default class Analyzer {
|
|
5
6
|
private ast;
|
|
6
7
|
private symbolFactory;
|
|
7
8
|
constructor(ast: ProgramNode, symbolIdGenerator: NodeSymbolIdGenerator);
|
|
8
|
-
analyze(): Report<ProgramNode>;
|
|
9
|
-
validate(): Report<ProgramNode>;
|
|
9
|
+
analyze(): Report<ProgramNode, CompileError>;
|
|
10
|
+
validate(): Report<ProgramNode, CompileError>;
|
|
10
11
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { CompileError } from '../../errors';
|
|
1
2
|
import { ProgramNode } from '../../parser/nodes';
|
|
2
3
|
import { default as Report } from '../../report';
|
|
3
4
|
import { default as SymbolFactory } from '../symbol/factory';
|
|
@@ -6,5 +7,5 @@ export default class Binder {
|
|
|
6
7
|
private symbolFactory;
|
|
7
8
|
constructor(ast: ProgramNode, symbolFactory: SymbolFactory);
|
|
8
9
|
private resolvePartialInjections;
|
|
9
|
-
resolve(): Report<ProgramNode>;
|
|
10
|
+
resolve(): Report<ProgramNode, CompileError>;
|
|
10
11
|
}
|
|
@@ -12,10 +12,9 @@ import { default as TableGroupBinder } from './elementBinder/tableGroup';
|
|
|
12
12
|
import { default as TablePartialBinder } from './elementBinder/tablePartial';
|
|
13
13
|
import { SymbolKind } from '../symbol/symbolIndex';
|
|
14
14
|
import { CompileError } from '../../errors';
|
|
15
|
-
import { default as RecordsBinder } from './elementBinder/records';
|
|
16
15
|
export declare function pickBinder(element: ElementDeclarationNode & {
|
|
17
16
|
type: SyntaxToken;
|
|
18
|
-
}): typeof ChecksBinder | typeof CustomBinder | typeof EnumBinder | typeof TableBinder | typeof TableGroupBinder | typeof ProjectBinder | typeof RefBinder | typeof NoteBinder | typeof IndexesBinder | typeof TablePartialBinder
|
|
17
|
+
}): typeof ChecksBinder | typeof CustomBinder | typeof EnumBinder | typeof TableBinder | typeof TableGroupBinder | typeof ProjectBinder | typeof RefBinder | typeof NoteBinder | typeof IndexesBinder | typeof TablePartialBinder;
|
|
19
18
|
export declare function scanNonListNodeForBinding(node?: SyntaxNode): {
|
|
20
19
|
variables: (PrimaryExpressionNode & {
|
|
21
20
|
expression: VariableNode;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Option } from '../option';
|
|
2
2
|
import { ElementDeclarationNode, FunctionExpressionNode, InfixExpressionNode, PrimaryExpressionNode, SyntaxNode, VariableNode } from '../parser/nodes';
|
|
3
|
-
import { SyntaxToken } from '../lexer/tokens';
|
|
4
3
|
import { NodeSymbolIndex } from './symbol/symbolIndex';
|
|
5
4
|
import { NodeSymbol } from './symbol/symbols';
|
|
5
|
+
import { SyntaxToken } from '../lexer/tokens';
|
|
6
6
|
import { ElementKind } from './types';
|
|
7
7
|
export declare function getElementKind(node?: ElementDeclarationNode): Option<ElementKind>;
|
|
8
8
|
export declare function destructureMemberAccessExpression(node?: SyntaxNode): Option<SyntaxNode[]>;
|
|
@@ -26,8 +26,6 @@ export declare function extractVarNameFromPrimaryVariable(node?: PrimaryExpressi
|
|
|
26
26
|
expression: VariableNode;
|
|
27
27
|
}): Option<string>;
|
|
28
28
|
export declare function extractQuotedStringToken(value?: SyntaxNode): Option<string>;
|
|
29
|
-
export declare function extractNumericLiteral(node?: SyntaxNode): number | null;
|
|
30
|
-
export declare function extractReferee(node?: SyntaxNode): NodeSymbol | undefined;
|
|
31
29
|
export declare function isBinaryRelationship(value?: SyntaxNode): value is InfixExpressionNode;
|
|
32
30
|
export declare function isEqualTupleOperands(value: InfixExpressionNode): value is InfixExpressionNode;
|
|
33
31
|
export declare function isValidIndexName(value?: SyntaxNode): value is (PrimaryExpressionNode & {
|
|
@@ -40,12 +38,4 @@ export declare function extractIndexName(value: (PrimaryExpressionNode & {
|
|
|
40
38
|
}) | (FunctionExpressionNode & {
|
|
41
39
|
value: SyntaxToken;
|
|
42
40
|
})): string;
|
|
43
|
-
export declare function destructureCallExpression(node?: SyntaxNode): Option<{
|
|
44
|
-
variables: (PrimaryExpressionNode & {
|
|
45
|
-
expression: VariableNode;
|
|
46
|
-
})[];
|
|
47
|
-
args: (PrimaryExpressionNode & {
|
|
48
|
-
expression: VariableNode;
|
|
49
|
-
})[];
|
|
50
|
-
}>;
|
|
51
41
|
export declare function findSymbol(id: NodeSymbolIndex, startElement: ElementDeclarationNode): NodeSymbol | undefined;
|
|
@@ -11,12 +11,12 @@ import { default as TableGroupValidator } from './elementValidators/tableGroup';
|
|
|
11
11
|
import { default as SymbolTable } from '../symbol/symbolTable';
|
|
12
12
|
import { default as SymbolFactory } from '../symbol/factory';
|
|
13
13
|
import { default as Report } from '../../report';
|
|
14
|
+
import { CompileError } from '../../errors';
|
|
14
15
|
import { default as TablePartialValidator } from './elementValidators/tablePartial';
|
|
15
16
|
import { default as ChecksValidator } from './elementValidators/checks';
|
|
16
|
-
import { default as RecordsValidator } from './elementValidators/records';
|
|
17
17
|
export declare function pickValidator(element: ElementDeclarationNode & {
|
|
18
18
|
type: SyntaxToken;
|
|
19
|
-
}): typeof CustomValidator | typeof EnumValidator | typeof TableValidator | typeof TableGroupValidator | typeof ProjectValidator | typeof RefValidator | typeof NoteValidator | typeof IndexesValidator | typeof TablePartialValidator | typeof ChecksValidator
|
|
19
|
+
}): typeof CustomValidator | typeof EnumValidator | typeof TableValidator | typeof TableGroupValidator | typeof ProjectValidator | typeof RefValidator | typeof NoteValidator | typeof IndexesValidator | typeof TablePartialValidator | typeof ChecksValidator;
|
|
20
20
|
export declare function isValidName(nameNode: SyntaxNode): boolean;
|
|
21
21
|
export declare function isValidAlias(aliasNode: SyntaxNode): aliasNode is PrimaryExpressionNode & {
|
|
22
22
|
expression: VariableNode;
|
|
@@ -62,4 +62,4 @@ export declare function isTupleOfVariables(value?: SyntaxNode): value is TupleEx
|
|
|
62
62
|
export declare function isValidColumnType(type: SyntaxNode): boolean;
|
|
63
63
|
export declare function aggregateSettingList(settingList?: ListExpressionNode): Report<{
|
|
64
64
|
[index: string]: AttributeNode[];
|
|
65
|
-
}>;
|
|
65
|
+
}, CompileError>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { default as Report } from '../../report';
|
|
2
|
+
import { CompileError } from '../../errors';
|
|
2
3
|
import { ProgramNode } from '../../parser/nodes';
|
|
3
4
|
import { default as SymbolFactory } from '../symbol/factory';
|
|
4
5
|
export default class Validator {
|
|
@@ -6,5 +7,5 @@ export default class Validator {
|
|
|
6
7
|
private publicSchemaSymbol;
|
|
7
8
|
private symbolFactory;
|
|
8
9
|
constructor(ast: ProgramNode, symbolFactory: SymbolFactory);
|
|
9
|
-
validate(): Report<ProgramNode>;
|
|
10
|
+
validate(): Report<ProgramNode, CompileError>;
|
|
10
11
|
}
|
|
@@ -90,11 +90,6 @@ export declare enum CompileErrorCode {
|
|
|
90
90
|
UNKNOWN_CHECK_SETTING = 3074,
|
|
91
91
|
DUPLICATE_CHECK_SETTING = 3075,
|
|
92
92
|
INVALID_CHECK_SETTING_VALUE = 3076,
|
|
93
|
-
INVALID_RECORDS_CONTEXT = 3077,
|
|
94
|
-
INVALID_RECORDS_NAME = 3078,
|
|
95
|
-
INVALID_RECORDS_FIELD = 3079,
|
|
96
|
-
DUPLICATE_COLUMN_REFERENCES_IN_RECORDS = 3080,
|
|
97
|
-
DUPLICATE_RECORDS_FOR_TABLE = 3081,
|
|
98
93
|
BINDING_ERROR = 4000,
|
|
99
94
|
UNSUPPORTED = 5000,
|
|
100
95
|
CIRCULAR_REF = 5001,
|
|
@@ -106,16 +101,7 @@ export declare enum CompileErrorCode {
|
|
|
106
101
|
export declare class CompileError extends Error {
|
|
107
102
|
code: Readonly<CompileErrorCode>;
|
|
108
103
|
diagnostic: Readonly<string>;
|
|
109
|
-
nodeOrToken: Readonly<SyntaxNode | SyntaxToken>;
|
|
110
|
-
start: Readonly<number>;
|
|
111
|
-
end: Readonly<number>;
|
|
112
|
-
constructor(code: number, message: string, nodeOrToken: SyntaxNode | SyntaxToken);
|
|
113
|
-
toWarning(): CompileWarning;
|
|
114
|
-
}
|
|
115
|
-
export declare class CompileWarning extends Error {
|
|
116
|
-
code: Readonly<CompileErrorCode>;
|
|
117
|
-
diagnostic: Readonly<string>;
|
|
118
|
-
nodeOrToken: Readonly<SyntaxNode | SyntaxToken>;
|
|
104
|
+
nodeOrToken: Readonly<SyntaxNode | SyntaxToken | readonly (SyntaxNode | SyntaxToken)[]>;
|
|
119
105
|
start: Readonly<number>;
|
|
120
106
|
end: Readonly<number>;
|
|
121
107
|
constructor(code: number, message: string, nodeOrToken: SyntaxNode | SyntaxToken);
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { ProgramNode } from '../parser/nodes';
|
|
2
|
+
import { CompileError } from '../errors';
|
|
2
3
|
import { Database, InterpreterDatabase } from './types';
|
|
3
4
|
import { default as Report } from '../report';
|
|
4
5
|
export default class Interpreter {
|
|
5
6
|
ast: ProgramNode;
|
|
6
7
|
env: InterpreterDatabase;
|
|
7
8
|
constructor(ast: ProgramNode);
|
|
8
|
-
interpret(): Report<Database>;
|
|
9
|
+
interpret(): Report<Database, CompileError>;
|
|
9
10
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ElementDeclarationNode
|
|
1
|
+
import { ElementDeclarationNode } from '../parser/nodes';
|
|
2
2
|
import { Position } from '../types';
|
|
3
3
|
import { CompileError } from '../errors';
|
|
4
4
|
export interface TokenPosition {
|
|
@@ -24,34 +24,6 @@ export interface InterpreterDatabase {
|
|
|
24
24
|
tablePartials: Map<ElementDeclarationNode, TablePartial>;
|
|
25
25
|
aliases: Alias[];
|
|
26
26
|
project: Map<ElementDeclarationNode, Project>;
|
|
27
|
-
records: Map<Table, TableRecordRow[]>;
|
|
28
|
-
recordsElements: ElementDeclarationNode[];
|
|
29
|
-
cachedMergedTables: Map<Table, Table>;
|
|
30
|
-
source: string;
|
|
31
|
-
}
|
|
32
|
-
export type RecordValueType = 'string' | 'bool' | 'integer' | 'real' | 'date' | 'time' | 'datetime' | string;
|
|
33
|
-
export interface RecordValue {
|
|
34
|
-
value: any;
|
|
35
|
-
type: RecordValueType;
|
|
36
|
-
}
|
|
37
|
-
export interface TableRecordRow {
|
|
38
|
-
values: Record<string, {
|
|
39
|
-
value: any;
|
|
40
|
-
type: RecordValueType;
|
|
41
|
-
node?: SyntaxNode;
|
|
42
|
-
}>;
|
|
43
|
-
node: FunctionApplicationNode;
|
|
44
|
-
columnNodes: Record<string, SyntaxNode>;
|
|
45
|
-
}
|
|
46
|
-
export interface TableRecordsData {
|
|
47
|
-
table: Table;
|
|
48
|
-
rows: TableRecordRow[];
|
|
49
|
-
}
|
|
50
|
-
export interface TableRecord {
|
|
51
|
-
schemaName: string | undefined;
|
|
52
|
-
tableName: string;
|
|
53
|
-
columns: string[];
|
|
54
|
-
values: RecordValue[][];
|
|
55
27
|
}
|
|
56
28
|
export interface Database {
|
|
57
29
|
schemas: [];
|
|
@@ -63,7 +35,6 @@ export interface Database {
|
|
|
63
35
|
aliases: Alias[];
|
|
64
36
|
project: Project;
|
|
65
37
|
tablePartials: TablePartial[];
|
|
66
|
-
records: TableRecord[];
|
|
67
38
|
}
|
|
68
39
|
export interface Table {
|
|
69
40
|
name: string;
|
|
@@ -90,14 +61,6 @@ export interface ColumnType {
|
|
|
90
61
|
schemaName: string | null;
|
|
91
62
|
type_name: string;
|
|
92
63
|
args: string | null;
|
|
93
|
-
numericParams?: {
|
|
94
|
-
precision: number;
|
|
95
|
-
scale: number;
|
|
96
|
-
};
|
|
97
|
-
lengthParam?: {
|
|
98
|
-
length: number;
|
|
99
|
-
};
|
|
100
|
-
isEnum?: boolean;
|
|
101
64
|
}
|
|
102
65
|
export interface Column {
|
|
103
66
|
name: string;
|
|
@@ -230,5 +193,5 @@ export type Project = Record<string, never> | {
|
|
|
230
193
|
token: TokenPosition;
|
|
231
194
|
};
|
|
232
195
|
token: TokenPosition;
|
|
233
|
-
[index: string & Omit<any, 'name' | 'tables' | 'refs' | 'enums' | 'tableGroups' | 'note' | 'tablePartials'
|
|
196
|
+
[index: string & Omit<any, 'name' | 'tables' | 'refs' | 'enums' | 'tableGroups' | 'note' | 'tablePartials'>]: string;
|
|
234
197
|
};
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { ColumnSymbol } from '../analyzer/symbol/symbols';
|
|
2
2
|
import { LiteralNode, PrimaryExpressionNode, SyntaxNode } from '../parser/nodes';
|
|
3
|
-
import { ColumnType, RelationCardinality, Table, TokenPosition
|
|
3
|
+
import { ColumnType, RelationCardinality, Table, TokenPosition } from './types';
|
|
4
4
|
import { SyntaxTokenKind } from '../lexer/tokens';
|
|
5
5
|
import { default as Report } from '../report';
|
|
6
|
+
import { CompileError } from '../errors';
|
|
6
7
|
export declare function extractNamesFromRefOperand(operand: SyntaxNode, owner?: Table): {
|
|
7
8
|
schemaName: string | null;
|
|
8
9
|
tableName: string;
|
|
@@ -31,6 +32,4 @@ export declare function processDefaultValue(valueNode?: SyntaxNode): {
|
|
|
31
32
|
type: 'string' | 'number' | 'boolean' | 'expression';
|
|
32
33
|
value: string | number;
|
|
33
34
|
} | undefined;
|
|
34
|
-
export declare function processColumnType(typeNode: SyntaxNode
|
|
35
|
-
export declare function mergeTableAndPartials(table: Table, env: InterpreterDatabase): Table;
|
|
36
|
-
export declare function extractInlineRefsFromTablePartials(table: Table, env: InterpreterDatabase): Ref[];
|
|
35
|
+
export declare function processColumnType(typeNode: SyntaxNode): Report<ColumnType, CompileError>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { CompileError } from '../errors';
|
|
1
2
|
import { default as Report } from '../report';
|
|
2
3
|
import { SyntaxToken, SyntaxTokenKind } from './tokens';
|
|
3
4
|
export default class Lexer {
|
|
@@ -14,7 +15,7 @@ export default class Lexer {
|
|
|
14
15
|
match(sequence: string): boolean;
|
|
15
16
|
private addToken;
|
|
16
17
|
private createToken;
|
|
17
|
-
lex(): Report<SyntaxToken[]>;
|
|
18
|
+
lex(): Report<SyntaxToken[], CompileError>;
|
|
18
19
|
scanTokens(): void;
|
|
19
20
|
gatherTrivia(): void;
|
|
20
21
|
gatherInvalid(): void;
|
|
@@ -38,18 +38,15 @@ export declare enum SyntaxNodeKind {
|
|
|
38
38
|
CALL_EXPRESSION = "<call-expression>",
|
|
39
39
|
PRIMARY_EXPRESSION = "<primary-expression>",
|
|
40
40
|
GROUP_EXPRESSION = "<group-expression>",
|
|
41
|
-
|
|
42
|
-
EMPTY = "<dummy>",
|
|
41
|
+
DUMMY = "<dummy>",
|
|
43
42
|
ARRAY = "<array>"
|
|
44
43
|
}
|
|
45
44
|
export declare class ProgramNode extends SyntaxNode {
|
|
46
45
|
body: ElementDeclarationNode[];
|
|
47
46
|
eof?: SyntaxToken;
|
|
48
|
-
|
|
49
|
-
constructor({ body, eof, source }: {
|
|
47
|
+
constructor({ body, eof }: {
|
|
50
48
|
body?: ElementDeclarationNode[];
|
|
51
49
|
eof?: SyntaxToken;
|
|
52
|
-
source: string;
|
|
53
50
|
}, id: SyntaxNodeId);
|
|
54
51
|
}
|
|
55
52
|
export declare class ElementDeclarationNode extends SyntaxNode {
|
|
@@ -87,7 +84,7 @@ export declare class AttributeNode extends SyntaxNode {
|
|
|
87
84
|
value?: NormalExpressionNode | IdentiferStreamNode;
|
|
88
85
|
}, id: SyntaxNodeId);
|
|
89
86
|
}
|
|
90
|
-
export type NormalExpressionNode = PrefixExpressionNode | InfixExpressionNode | PostfixExpressionNode | BlockExpressionNode | ListExpressionNode | TupleExpressionNode |
|
|
87
|
+
export type NormalExpressionNode = PrefixExpressionNode | InfixExpressionNode | PostfixExpressionNode | BlockExpressionNode | ListExpressionNode | TupleExpressionNode | CallExpressionNode | PrimaryExpressionNode | FunctionExpressionNode | DummyNode | ArrayNode;
|
|
91
88
|
export type ExpressionNode = ElementDeclarationNode | NormalExpressionNode | FunctionApplicationNode;
|
|
92
89
|
export declare class PrefixExpressionNode extends SyntaxNode {
|
|
93
90
|
op?: SyntaxToken;
|
|
@@ -163,14 +160,6 @@ export declare class TupleExpressionNode extends SyntaxNode {
|
|
|
163
160
|
tupleCloseParen?: SyntaxToken;
|
|
164
161
|
}, id: SyntaxNodeId);
|
|
165
162
|
}
|
|
166
|
-
export declare class CommaExpressionNode extends SyntaxNode {
|
|
167
|
-
elementList: NormalExpressionNode[];
|
|
168
|
-
commaList: SyntaxToken[];
|
|
169
|
-
constructor({ elementList, commaList, }: {
|
|
170
|
-
elementList?: NormalExpressionNode[];
|
|
171
|
-
commaList?: SyntaxToken[];
|
|
172
|
-
}, id: SyntaxNodeId);
|
|
173
|
-
}
|
|
174
163
|
export declare class GroupExpressionNode extends TupleExpressionNode {
|
|
175
164
|
constructor({ groupOpenParen, expression, groupCloseParen, }: {
|
|
176
165
|
groupOpenParen?: SyntaxToken;
|
|
@@ -204,9 +193,9 @@ export declare class PrimaryExpressionNode extends SyntaxNode {
|
|
|
204
193
|
expression?: LiteralNode | VariableNode;
|
|
205
194
|
}, id: SyntaxNodeId);
|
|
206
195
|
}
|
|
207
|
-
export declare class
|
|
208
|
-
constructor({
|
|
209
|
-
|
|
196
|
+
export declare class DummyNode extends SyntaxNode {
|
|
197
|
+
constructor({ pre }: {
|
|
198
|
+
pre: Readonly<SyntaxNode> | Readonly<SyntaxToken>;
|
|
210
199
|
}, id: SyntaxNodeId);
|
|
211
200
|
}
|
|
212
201
|
export declare class ArrayNode extends SyntaxNode {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { CompileError } from '../errors';
|
|
1
2
|
import { SyntaxToken } from '../lexer/tokens';
|
|
2
3
|
import { default as Report } from '../report';
|
|
3
4
|
import { ProgramNode, SyntaxNodeIdGenerator } from './nodes';
|
|
@@ -7,8 +8,7 @@ export default class Parser {
|
|
|
7
8
|
private errors;
|
|
8
9
|
private contextStack;
|
|
9
10
|
private nodeFactory;
|
|
10
|
-
|
|
11
|
-
constructor(source: string, tokens: SyntaxToken[], nodeIdGenerator: SyntaxNodeIdGenerator);
|
|
11
|
+
constructor(tokens: SyntaxToken[], nodeIdGenerator: SyntaxNodeIdGenerator);
|
|
12
12
|
private isAtEnd;
|
|
13
13
|
private advance;
|
|
14
14
|
private peek;
|
|
@@ -22,7 +22,7 @@ export default class Parser {
|
|
|
22
22
|
parse(): Report<{
|
|
23
23
|
ast: ProgramNode;
|
|
24
24
|
tokens: SyntaxToken[];
|
|
25
|
-
}>;
|
|
25
|
+
}, CompileError>;
|
|
26
26
|
private program;
|
|
27
27
|
private synchronizeProgram;
|
|
28
28
|
private elementDeclaration;
|
|
@@ -30,9 +30,7 @@ export default class Parser {
|
|
|
30
30
|
private synchronizeElementDeclarationAlias;
|
|
31
31
|
private fieldDeclaration;
|
|
32
32
|
private expression;
|
|
33
|
-
private
|
|
34
|
-
private commaExpression;
|
|
35
|
-
private shouldStopCommaExpression;
|
|
33
|
+
private shouldStopExpression;
|
|
36
34
|
private normalExpression;
|
|
37
35
|
private expression_bp;
|
|
38
36
|
private leftExpression_bp;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { SyntaxToken, SyntaxTokenKind } from '../lexer/tokens';
|
|
2
2
|
import { Option } from '../option';
|
|
3
3
|
import { default as NodeFactory } from './factory';
|
|
4
|
-
import {
|
|
5
|
-
export declare function convertFuncAppToElem(
|
|
4
|
+
import { ElementDeclarationNode, ExpressionNode, IdentiferStreamNode, InfixExpressionNode, LiteralNode, NormalExpressionNode, PrimaryExpressionNode, SyntaxNode, VariableNode } from './nodes';
|
|
5
|
+
export declare function convertFuncAppToElem(callee: ExpressionNode | undefined, args: NormalExpressionNode[], factory: NodeFactory): Option<ElementDeclarationNode>;
|
|
6
6
|
export declare function isAsKeyword(token?: SyntaxToken): token is SyntaxToken & {
|
|
7
7
|
kind: SyntaxTokenKind.IDENTIFIER;
|
|
8
8
|
value: 'as';
|
|
@@ -49,5 +49,5 @@ type DotDelimitedIdentifier = PrimaryExpressionNode | (AccessExpression & {
|
|
|
49
49
|
export declare function isAccessExpression(node?: SyntaxNode): node is AccessExpression;
|
|
50
50
|
export declare function isDotDelimitedIdentifier(node?: SyntaxNode): node is DotDelimitedIdentifier;
|
|
51
51
|
export declare function extractStringFromIdentifierStream(stream?: IdentiferStreamNode): Option<string>;
|
|
52
|
-
export declare function
|
|
52
|
+
export declare function getElementName(element: ElementDeclarationNode): Option<string>;
|
|
53
53
|
export {};
|
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
export default class Report<T> {
|
|
1
|
+
export default class Report<T, E> {
|
|
3
2
|
private value;
|
|
4
3
|
private errors;
|
|
5
|
-
|
|
6
|
-
constructor(value: T, errors?: CompileError[], warnings?: CompileWarning[]);
|
|
4
|
+
constructor(value: T, errors?: E[]);
|
|
7
5
|
getValue(): T;
|
|
8
|
-
getErrors():
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
map<U>(fn: (_: T) => U): Report<U>;
|
|
6
|
+
getErrors(): E[];
|
|
7
|
+
chain<U>(fn: (_: T) => Report<U, E>): Report<U, E>;
|
|
8
|
+
map<U>(fn: (_: T) => U): Report<U, E>;
|
|
12
9
|
}
|
package/dist/src/core/utils.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export declare function isAlphaOrUnderscore(char: string): boolean;
|
|
|
4
4
|
export declare function isDigit(char: string): boolean;
|
|
5
5
|
export declare function isHexChar(char: string): boolean;
|
|
6
6
|
export declare function isAlphaNumeric(char: string): boolean;
|
|
7
|
+
export declare function addQuoteIfNeeded(s: string): string;
|
|
7
8
|
export declare function alternateLists<T, S>(firstList: T[], secondList: S[]): (T | S)[];
|
|
8
9
|
export declare function isOffsetWithinFullSpan(offset: number, nodeOrToken: SyntaxNode | SyntaxToken): boolean;
|
|
9
10
|
export declare function isOffsetWithinSpan(offset: number, nodeOrToken: SyntaxNode | SyntaxToken): boolean;
|
package/dist/src/index.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
+
import { serialize } from './core/serialization/serialize';
|
|
1
2
|
import { default as Compiler } from './compiler/index';
|
|
2
3
|
import * as services from '@/services/index';
|
|
3
4
|
export { ElementKind, } from './core/analyzer/types';
|
|
4
|
-
export * from './core/interpreter/records/utils';
|
|
5
5
|
export { SyntaxNode, ElementDeclarationNode, ProgramNode, SyntaxNodeKind, type SyntaxNodeId, } from './core/parser/nodes';
|
|
6
6
|
export { SyntaxToken, SyntaxTokenKind, } from './core/lexer/tokens';
|
|
7
7
|
export { CompileError, CompileErrorCode, } from './core/errors';
|
|
8
8
|
export { type Position, } from './core/types';
|
|
9
|
-
export {
|
|
9
|
+
export { addQuoteIfNeeded, } from './core/utils';
|
|
10
|
+
export { ScopeKind, } from './compiler/index';
|
|
10
11
|
export { type Database, type Table, type Column, type Enum, type Ref, type Project, type TableGroup, type TablePartial, } from './core/interpreter/types';
|
|
11
|
-
export { Compiler, services };
|
|
12
|
+
export { serialize, Compiler, services };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { default as DBMLCompletionItemProvider } from './suggestions/provider';
|
|
2
2
|
import { default as DBMLDefinitionProvider } from './definition/provider';
|
|
3
3
|
import { default as DBMLReferencesProvider } from './references/provider';
|
|
4
|
-
import { default as DBMLDiagnosticsProvider } from './diagnostics/provider';
|
|
5
4
|
export * from './types';
|
|
6
|
-
export { DBMLCompletionItemProvider, DBMLDefinitionProvider, DBMLReferencesProvider,
|
|
5
|
+
export { DBMLCompletionItemProvider, DBMLDefinitionProvider, DBMLReferencesProvider, };
|
|
@@ -1,34 +1,8 @@
|
|
|
1
1
|
import { SymbolKind } from '../../core/analyzer/symbol/symbolIndex';
|
|
2
2
|
import { CompletionItemKind, CompletionList } from '../types';
|
|
3
3
|
import { SyntaxToken } from '../../core/lexer/tokens';
|
|
4
|
-
import { SyntaxNode, TupleExpressionNode } from '../../core/parser/nodes';
|
|
5
|
-
import { default as Compiler } from '../../compiler';
|
|
6
|
-
import { ColumnSymbol, TablePartialInjectedColumnSymbol, TablePartialSymbol, TableSymbol } from '../../core/analyzer/symbol/symbols';
|
|
7
4
|
export declare function pickCompletionItemKind(symbolKind: SymbolKind): CompletionItemKind;
|
|
8
5
|
export declare function shouldPrependSpace(token: SyntaxToken | undefined, offset: number): boolean;
|
|
9
6
|
export declare function noSuggestions(): CompletionList;
|
|
10
7
|
export declare function prependSpace(completionList: CompletionList): CompletionList;
|
|
11
|
-
export declare function
|
|
12
|
-
export declare function addSuggestAllSuggestion(completionList: CompletionList, separator?: string): CompletionList;
|
|
13
|
-
export declare function getNodeOrTokenSource(compiler: Compiler, tokenOrNode: SyntaxToken | SyntaxNode): string;
|
|
14
|
-
/**
|
|
15
|
-
* Checks if the offset is within the element's header
|
|
16
|
-
* (within the element, but outside the body)
|
|
17
|
-
*/
|
|
18
|
-
export declare function isOffsetWithinElementHeader(offset: number, element: SyntaxNode & {
|
|
19
|
-
body?: SyntaxNode;
|
|
20
|
-
}): boolean;
|
|
21
|
-
export declare function isTupleEmpty(tuple: TupleExpressionNode): boolean;
|
|
22
|
-
/**
|
|
23
|
-
* Get columns from a table symbol
|
|
24
|
-
* @param tableSymbol The table symbol to extract columns from
|
|
25
|
-
* @returns Array of column objects with name and type information
|
|
26
|
-
*/
|
|
27
|
-
export declare function getColumnsFromTableSymbol(tableSymbol: TableSymbol | TablePartialSymbol): Array<{
|
|
28
|
-
name: string;
|
|
29
|
-
type: string;
|
|
30
|
-
}> | null;
|
|
31
|
-
export declare function extractNameAndTypeOfColumnSymbol(columnSymbol: ColumnSymbol | TablePartialInjectedColumnSymbol, columnName: string): {
|
|
32
|
-
name: string;
|
|
33
|
-
type: string;
|
|
34
|
-
} | null;
|
|
8
|
+
export declare function addQuoteIfNeeded(completionList: CompletionList): CompletionList;
|
|
@@ -12,12 +12,8 @@ export interface CompletionItemProvider {
|
|
|
12
12
|
provideCompletionItems(model: TextModel, position: Position, context: CompletionContext, token: CancellationToken): ProviderResult<CompletionList>;
|
|
13
13
|
resolveCompletionItem?(item: CompletionItem, token: CancellationToken): ProviderResult<CompletionItem>;
|
|
14
14
|
}
|
|
15
|
-
export type CompletionItem = languages.CompletionItem
|
|
16
|
-
|
|
17
|
-
};
|
|
18
|
-
export interface CompletionList extends languages.CompletionList {
|
|
19
|
-
suggestions: CompletionItem[];
|
|
20
|
-
}
|
|
15
|
+
export type CompletionItem = languages.CompletionItem;
|
|
16
|
+
export type CompletionList = languages.CompletionList;
|
|
21
17
|
export declare enum CompletionItemKind {
|
|
22
18
|
Function = 1,
|
|
23
19
|
Constructor = 2,
|
|
@@ -61,10 +57,3 @@ export type Definition = languages.Definition;
|
|
|
61
57
|
export type CodeActionList = languages.CodeActionList;
|
|
62
58
|
export type SignatureHelpResult = languages.SignatureHelpResult;
|
|
63
59
|
export type ReferenceProvider = languages.ReferenceProvider;
|
|
64
|
-
export declare enum MarkerSeverity {
|
|
65
|
-
Hint = 1,
|
|
66
|
-
Info = 2,
|
|
67
|
-
Warning = 4,
|
|
68
|
-
Error = 8
|
|
69
|
-
}
|
|
70
|
-
export type MarkerData = editor.IMarkerData;
|
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": "6.2.
|
|
4
|
+
"version": "6.2.1",
|
|
5
5
|
"description": "DBML parser v2",
|
|
6
6
|
"author": "Holistics <dev@holistics.io>",
|
|
7
7
|
"license": "Apache-2.0",
|
|
@@ -25,10 +25,10 @@
|
|
|
25
25
|
"dist"
|
|
26
26
|
],
|
|
27
27
|
"scripts": {
|
|
28
|
-
"build": "tsc --noEmit && vite build",
|
|
28
|
+
"build": "rm -rf ./dist && tsc --noEmit && vite build",
|
|
29
29
|
"dev": "vite build --watch",
|
|
30
30
|
"test": "vitest run",
|
|
31
|
-
"test:watch": "vitest
|
|
31
|
+
"test:watch": "vitest watch",
|
|
32
32
|
"coverage": "vitest run --coverage",
|
|
33
33
|
"prepublish": "npm run build",
|
|
34
34
|
"prepare": "npm run build",
|
|
@@ -36,25 +36,13 @@
|
|
|
36
36
|
"lint:fix": "eslint --fix ."
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"
|
|
40
|
-
"@types/lodash-es": "^4.17.12",
|
|
41
|
-
"@types/luxon": "^3.7.1",
|
|
42
|
-
"@types/node": "^20.8.8",
|
|
43
|
-
"@typescript-eslint/eslint-plugin": "^8.46.3",
|
|
44
|
-
"@typescript-eslint/parser": "^8.46.3",
|
|
45
|
-
"eslint": "^9.39.1",
|
|
46
|
-
"monaco-editor-core": "^0.44.0",
|
|
47
|
-
"typescript": "^5.9.3",
|
|
48
|
-
"typescript-eslint": "^8.46.3",
|
|
49
|
-
"vite": "^7.2.2",
|
|
50
|
-
"vite-plugin-dts": "^4.5.4"
|
|
39
|
+
"monaco-editor-core": "^0.44.0"
|
|
51
40
|
},
|
|
52
41
|
"dependencies": {
|
|
53
|
-
"lodash-es": "^4.17.21"
|
|
54
|
-
"luxon": "^3.7.2"
|
|
42
|
+
"lodash-es": "^4.17.21"
|
|
55
43
|
},
|
|
56
44
|
"engines": {
|
|
57
45
|
"node": ">=18"
|
|
58
46
|
},
|
|
59
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "403ffd5a0d15bbf0f2b22db2c507659ce3f8fe35"
|
|
60
48
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|