@dbml/parse 6.2.0-alpha.0 → 6.2.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/__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 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { default as SymbolTable } from '../../../core/analyzer/symbol/symbolTable';
|
|
2
|
-
import { TableSymbol } from '../../../core/analyzer/symbol/symbols';
|
|
3
|
-
export type TableNameInput = string | {
|
|
4
|
-
schema?: string;
|
|
5
|
-
table: string;
|
|
6
|
-
};
|
|
7
|
-
/**
|
|
8
|
-
* Normalizes a table name input to { schema, table } format.
|
|
9
|
-
* Properly handles quoted identifiers with dots inside.
|
|
10
|
-
*/
|
|
11
|
-
export declare function normalizeTableName(input: TableNameInput): {
|
|
12
|
-
schema: string;
|
|
13
|
-
table: string;
|
|
14
|
-
};
|
|
15
|
-
/**
|
|
16
|
-
* Looks up a table symbol from the symbol table.
|
|
17
|
-
*/
|
|
18
|
-
export declare function lookupTableSymbol(symbolTable: Readonly<SymbolTable>, schema: string, table: string): TableSymbol | null;
|
|
19
|
-
/**
|
|
20
|
-
* Removes surrounding double quotes from a string if present.
|
|
21
|
-
*/
|
|
22
|
-
export declare function stripQuotes(str: string): string;
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Checks if an identifier is valid (can be used without quotes in DBML).
|
|
3
|
-
* Valid identifiers must:
|
|
4
|
-
* - Contain only alphanumeric characters and underscores
|
|
5
|
-
* - Not start with a digit
|
|
6
|
-
*
|
|
7
|
-
* @param name - The identifier to check
|
|
8
|
-
* @returns True if the identifier is valid and doesn't need quotes
|
|
9
|
-
*
|
|
10
|
-
* @example
|
|
11
|
-
* isValidIdentifier('users') => true
|
|
12
|
-
* isValidIdentifier('user_name') => true
|
|
13
|
-
* isValidIdentifier('user name') => false (contains space)
|
|
14
|
-
* isValidIdentifier('123users') => false (starts with digit)
|
|
15
|
-
*/
|
|
16
|
-
export declare function isValidIdentifier(name: string): boolean;
|
|
17
|
-
/**
|
|
18
|
-
* Adds double quotes around an identifier if needed.
|
|
19
|
-
* Identifiers need quotes if they:
|
|
20
|
-
* - Contain non-alphanumeric characters (except underscore)
|
|
21
|
-
* - Start with a digit
|
|
22
|
-
* - Are empty strings
|
|
23
|
-
*
|
|
24
|
-
* @param identifier - The identifier to potentially quote
|
|
25
|
-
* @returns The identifier with double quotes if needed, otherwise unchanged
|
|
26
|
-
*
|
|
27
|
-
* @example
|
|
28
|
-
* addDoubleQuoteIfNeeded('users') => 'users'
|
|
29
|
-
* addDoubleQuoteIfNeeded('user name') => '"user name"'
|
|
30
|
-
* addDoubleQuoteIfNeeded('123users') => '"123users"'
|
|
31
|
-
* addDoubleQuoteIfNeeded('user-name') => '"user-name"'
|
|
32
|
-
*/
|
|
33
|
-
export declare function addDoubleQuoteIfNeeded(identifier: string): string;
|
|
34
|
-
/**
|
|
35
|
-
* Unescapes a string by processing escape sequences.
|
|
36
|
-
* Handles escaped quotes (\"), common escape sequences, unicode (\uHHHH), and arbitrary escapes.
|
|
37
|
-
*
|
|
38
|
-
* @param str - The string to unescape
|
|
39
|
-
* @returns The unescaped string
|
|
40
|
-
*
|
|
41
|
-
* @example
|
|
42
|
-
* unescapeString('table\\"name') => 'table"name'
|
|
43
|
-
* unescapeString('line1\\nline2') => 'line1\nline2'
|
|
44
|
-
* unescapeString('\\u0041BC') => 'ABC'
|
|
45
|
-
* unescapeString('\\x') => 'x'
|
|
46
|
-
*/
|
|
47
|
-
export declare function unescapeString(str: string): string;
|
|
48
|
-
/**
|
|
49
|
-
* Escapes a string by adding backslashes before special characters.
|
|
50
|
-
* Handles quotes and other characters that need escaping.
|
|
51
|
-
*
|
|
52
|
-
* @param str - The string to escape
|
|
53
|
-
* @returns The escaped string
|
|
54
|
-
*
|
|
55
|
-
* @example
|
|
56
|
-
* escapeString('table"name') => 'table\\"name'
|
|
57
|
-
* escapeString('line1\nline2') => 'line1\\nline2'
|
|
58
|
-
*/
|
|
59
|
-
export declare function escapeString(str: string): string;
|
|
60
|
-
/**
|
|
61
|
-
* Formats a record value for DBML output.
|
|
62
|
-
* Handles different data types and converts them to appropriate DBML syntax.
|
|
63
|
-
*
|
|
64
|
-
* @param recordValue - The record value with type information, or a primitive value
|
|
65
|
-
* @returns The formatted string representation for DBML
|
|
66
|
-
*
|
|
67
|
-
* @example
|
|
68
|
-
* formatRecordValue({ value: 1, type: 'integer' }) => '1'
|
|
69
|
-
* formatRecordValue({ value: 'Alice', type: 'string' }) => "'Alice'"
|
|
70
|
-
* formatRecordValue({ value: true, type: 'bool' }) => 'true'
|
|
71
|
-
* formatRecordValue({ value: null, type: 'string' }) => 'null'
|
|
72
|
-
* formatRecordValue(undefined) => 'null'
|
|
73
|
-
* formatRecordValue(null) => 'null'
|
|
74
|
-
* formatRecordValue('Alice') => "'Alice'"
|
|
75
|
-
* formatRecordValue(42) => '42'
|
|
76
|
-
* formatRecordValue(true) => 'true'
|
|
77
|
-
*/
|
|
78
|
-
export declare function formatRecordValue(recordValue: {
|
|
79
|
-
value: any;
|
|
80
|
-
type: string;
|
|
81
|
-
} | string | number | boolean | null | undefined): string;
|
|
82
|
-
/**
|
|
83
|
-
* Splits a qualified identifier string into its components, handling quoted segments.
|
|
84
|
-
*
|
|
85
|
-
* Examples:
|
|
86
|
-
* - "schema.table" => ["schema", "table"]
|
|
87
|
-
* - '"schema name".table' => ["schema name", "table"]
|
|
88
|
-
* - '"schema.with.dots"."table.with.dots".column' => ["schema.with.dots", "table.with.dots", "column"]
|
|
89
|
-
* - 'schema."table name"."column name"' => ["schema", "table name", "column name"]
|
|
90
|
-
* - 'schema . table' => ["schema", "table"]
|
|
91
|
-
*
|
|
92
|
-
* @param identifier - The qualified identifier string to split
|
|
93
|
-
* @returns Array of unquoted identifier components
|
|
94
|
-
*/
|
|
95
|
-
export declare function splitQualifiedIdentifier(identifier: string): string[];
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { SyntaxToken } from '../../../lexer/tokens';
|
|
2
|
-
import { ElementBinder } from '../types';
|
|
3
|
-
import { ElementDeclarationNode, ProgramNode } from '../../../parser/nodes';
|
|
4
|
-
import { CompileError } from '../../../errors';
|
|
5
|
-
import { default as SymbolFactory } from '../../symbol/factory';
|
|
6
|
-
export default class RecordsBinder implements ElementBinder {
|
|
7
|
-
private symbolFactory;
|
|
8
|
-
private declarationNode;
|
|
9
|
-
private ast;
|
|
10
|
-
private boundColumns;
|
|
11
|
-
constructor(declarationNode: ElementDeclarationNode & {
|
|
12
|
-
type: SyntaxToken;
|
|
13
|
-
}, ast: ProgramNode, symbolFactory: SymbolFactory);
|
|
14
|
-
bind(): CompileError[];
|
|
15
|
-
private bindRecordsName;
|
|
16
|
-
private bindTopLevelName;
|
|
17
|
-
private bindInsideTableName;
|
|
18
|
-
private bindBody;
|
|
19
|
-
private bindDataRows;
|
|
20
|
-
private bindDataRow;
|
|
21
|
-
private bindSubElements;
|
|
22
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { default as SymbolFactory } from '../../symbol/factory';
|
|
2
|
-
import { CompileError } from '../../../errors';
|
|
3
|
-
import { BlockExpressionNode, ElementDeclarationNode, FunctionApplicationNode } from '../../../parser/nodes';
|
|
4
|
-
import { SyntaxToken } from '../../../lexer/tokens';
|
|
5
|
-
import { ElementValidator } from '../types';
|
|
6
|
-
import { default as SymbolTable } from '../../symbol/symbolTable';
|
|
7
|
-
export default class RecordsValidator 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 validateTopLevelName;
|
|
18
|
-
private validateInsideTableName;
|
|
19
|
-
private validateAlias;
|
|
20
|
-
private validateSettingList;
|
|
21
|
-
validateBody(body?: FunctionApplicationNode | BlockExpressionNode): CompileError[];
|
|
22
|
-
private validateDataRows;
|
|
23
|
-
private validateDataRow;
|
|
24
|
-
private isValidRecordValue;
|
|
25
|
-
private validateSubElements;
|
|
26
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { ElementDeclarationNode } from '../../parser/nodes';
|
|
2
|
-
import { default as Report } from '../../report';
|
|
3
|
-
import { InterpreterDatabase } from '../types';
|
|
4
|
-
export declare class RecordsInterpreter {
|
|
5
|
-
private env;
|
|
6
|
-
private tableToRecordMap;
|
|
7
|
-
constructor(env: InterpreterDatabase);
|
|
8
|
-
interpret(elements: ElementDeclarationNode[]): Report<void>;
|
|
9
|
-
private validateConstraints;
|
|
10
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { RecordValue, Column, TableRecordRow } from '../../../types';
|
|
2
|
-
import { CompileError } from '../../../../errors';
|
|
3
|
-
export declare function extractKeyValueWithDefault(row: Record<string, RecordValue>, columnNames: string[], columns?: (Column | undefined)[]): string;
|
|
4
|
-
export declare function hasNullWithoutDefaultInKey(row: Record<string, RecordValue>, columnNames: string[], columns?: (Column | undefined)[]): boolean;
|
|
5
|
-
export declare function isAutoIncrementColumn(column: Column): boolean;
|
|
6
|
-
export declare function hasNotNullWithDefault(column: Column): boolean;
|
|
7
|
-
export declare function formatFullColumnName(schemaName: string | null, tableName: string, columnName: string): string;
|
|
8
|
-
export declare function formatFullColumnNames(schemaName: string | null, tableName: string, columnNames: string[]): string;
|
|
9
|
-
export declare function formatValues(row: Record<string, RecordValue>, columnNames: string[]): string;
|
|
10
|
-
export declare function createConstraintErrors(row: TableRecordRow, columnNames: string[], message: string): CompileError[];
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { ColumnSymbol } from '../../../../analyzer/symbol/symbols';
|
|
2
|
-
export type SqlDialect = 'mysql' | 'postgres' | 'mssql' | 'oracle' | 'snowflake';
|
|
3
|
-
export declare function normalizeTypeName(type: string): string;
|
|
4
|
-
export declare function isIntegerType(type: string, dialect?: SqlDialect): boolean;
|
|
5
|
-
export declare function isFloatType(type: string, dialect?: SqlDialect): boolean;
|
|
6
|
-
export declare function isNumericType(type: string, dialect?: SqlDialect): boolean;
|
|
7
|
-
export declare function isBooleanType(type: string, dialect?: SqlDialect): boolean;
|
|
8
|
-
export declare function isStringType(type: string, dialect?: SqlDialect): boolean;
|
|
9
|
-
export declare function isBinaryType(type: string, dialect?: SqlDialect): boolean;
|
|
10
|
-
export declare function isDateTimeType(type: string, dialect?: SqlDialect): boolean;
|
|
11
|
-
export declare function isSerialType(type: string, dialect?: SqlDialect): boolean;
|
|
12
|
-
export declare function getNumericTypeParams(columnSymbol: ColumnSymbol): {
|
|
13
|
-
precision?: number;
|
|
14
|
-
scale?: number;
|
|
15
|
-
};
|
|
16
|
-
export declare function getLengthTypeParam(columnSymbol: ColumnSymbol): {
|
|
17
|
-
length?: number;
|
|
18
|
-
};
|
|
19
|
-
export declare function getRecordValueType(sqlType: string, isEnum: boolean): string;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { FunctionExpressionNode, SyntaxNode } from '../../../../parser/nodes';
|
|
2
|
-
export { extractNumericLiteral } from '../../../../analyzer/utils';
|
|
3
|
-
export declare function isNullish(value: SyntaxNode): boolean;
|
|
4
|
-
export declare function isEmptyStringLiteral(value: SyntaxNode): boolean;
|
|
5
|
-
export declare function isFunctionExpression(value: SyntaxNode): value is FunctionExpressionNode;
|
|
6
|
-
export declare function extractSignedNumber(node: SyntaxNode): number | null;
|
|
7
|
-
export declare function tryExtractNumeric(value: SyntaxNode | number | string | boolean | undefined | null): number | null;
|
|
8
|
-
export declare function tryExtractInteger(value: SyntaxNode | number | string | boolean | undefined | null): number | null;
|
|
9
|
-
export declare const TRUTHY_VALUES: string[];
|
|
10
|
-
export declare const FALSY_VALUES: string[];
|
|
11
|
-
export declare function tryExtractBoolean(value: SyntaxNode | number | string | boolean | undefined | null): boolean | null;
|
|
12
|
-
export declare function tryExtractEnum(value: SyntaxNode | string | undefined | null): string | null;
|
|
13
|
-
export declare function tryExtractString(value: SyntaxNode | string | boolean | number | undefined | null): string | null;
|
|
14
|
-
export declare function tryExtractDateTime(value: SyntaxNode | string | undefined | null): string | null;
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { default as Compiler } from '../../compiler';
|
|
2
|
-
import { MarkerData } from '../types';
|
|
3
|
-
interface Diagnostic {
|
|
4
|
-
type: 'error' | 'warning';
|
|
5
|
-
text: string;
|
|
6
|
-
startRow: number;
|
|
7
|
-
startColumn: number;
|
|
8
|
-
endRow: number;
|
|
9
|
-
endColumn: number;
|
|
10
|
-
code?: string | number;
|
|
11
|
-
}
|
|
12
|
-
export default class DBMLDiagnosticsProvider {
|
|
13
|
-
private compiler;
|
|
14
|
-
constructor(compiler: Compiler);
|
|
15
|
-
/**
|
|
16
|
-
* Get all diagnostics (errors and warnings) from the current compilation
|
|
17
|
-
*/
|
|
18
|
-
provideDiagnostics(): Diagnostic[];
|
|
19
|
-
/**
|
|
20
|
-
* Get only errors from the current compilation
|
|
21
|
-
*/
|
|
22
|
-
provideErrors(): Diagnostic[];
|
|
23
|
-
/**
|
|
24
|
-
* Get only warnings from the current compilation
|
|
25
|
-
*/
|
|
26
|
-
provideWarnings(): Diagnostic[];
|
|
27
|
-
/**
|
|
28
|
-
* Convert Monaco markers format (for editor integration)
|
|
29
|
-
*/
|
|
30
|
-
provideMarkers(): MarkerData[];
|
|
31
|
-
private createDiagnostic;
|
|
32
|
-
private getSeverityValue;
|
|
33
|
-
}
|
|
34
|
-
export {};
|
|
File without changes
|
|
File without changes
|
|
File without changes
|