@dbml/parse 10.4.0-alpha.1 → 10.4.0-alpha.3
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 -24
- package/dist/dbml-parse.mjs +2968 -2870
- package/dist/src/compiler/index.d.ts +2 -1
- package/dist/src/compiler/projectLayout/layout.d.ts +7 -0
- package/dist/src/core/global_modules/metadata/utils.d.ts +3 -3
- package/dist/src/core/types/filepath.d.ts +3 -1
- package/dist/src/core/types/schemaJson/types.d.ts +3 -2
- package/dist/src/core/utils/expression.d.ts +1 -0
- package/dist/src/core/utils/interpret.d.ts +2 -2
- package/dist/src/core/utils/validate.d.ts +0 -1
- package/dist/src/index.d.ts +3 -2
- package/dist/src/services/definition/provider.d.ts +1 -0
- package/dist/src/services/suggestions/provider.d.ts +2 -0
- package/dist/src/services/suggestions/use.d.ts +4 -1
- package/package.json +3 -3
|
@@ -109,7 +109,7 @@ export default class Compiler {
|
|
|
109
109
|
source: (filepath: Filepath) => string;
|
|
110
110
|
ast: (filepath?: Filepath) => Readonly<import('../core/types/nodes').ProgramNode>;
|
|
111
111
|
errors: (filepath?: Filepath) => readonly Readonly<import('..').CompileError>[];
|
|
112
|
-
warnings: (filepath?: Filepath) => readonly Readonly<import('
|
|
112
|
+
warnings: (filepath?: Filepath) => readonly Readonly<import('..').CompileWarning>[];
|
|
113
113
|
tokens: (filepath?: Filepath) => readonly Readonly<import('..').SyntaxToken>[];
|
|
114
114
|
rawDb: (filepath?: Filepath) => Readonly<import('..').Database> | undefined;
|
|
115
115
|
publicSymbolTable: (filepath?: Filepath) => readonly Readonly<import('../core/types/symbol').NodeSymbol>[] | undefined;
|
|
@@ -130,6 +130,7 @@ export default class Compiler {
|
|
|
130
130
|
initMonacoServices(options?: {
|
|
131
131
|
autocompletion?: {
|
|
132
132
|
triggerCharacters?: string[];
|
|
133
|
+
fileListDepth?: number;
|
|
133
134
|
};
|
|
134
135
|
}): {
|
|
135
136
|
definitionProvider: DBMLDefinitionProvider;
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import { Filepath } from '../../core/types/filepath';
|
|
2
|
+
export interface FileSpecifierInfo {
|
|
3
|
+
specifier: string;
|
|
4
|
+
label?: string;
|
|
5
|
+
detail?: string;
|
|
6
|
+
}
|
|
2
7
|
export interface DbmlProjectLayout {
|
|
3
8
|
resolveFileSpecifier(currentFilepath: Filepath, specifier: string): Filepath | undefined;
|
|
9
|
+
getFileSpecifierInfo(currentFilepath: Filepath, targetFilepath: Filepath): FileSpecifierInfo | undefined;
|
|
4
10
|
getSource(filePath: Filepath): string | undefined;
|
|
5
11
|
exists(filePath: Filepath): boolean;
|
|
6
12
|
isFile(filePath: Filepath): boolean;
|
|
@@ -12,6 +18,7 @@ export declare class MemoryProjectLayout implements DbmlProjectLayout {
|
|
|
12
18
|
private readonly files;
|
|
13
19
|
constructor(files?: Map<string, string> | Record<string, string>);
|
|
14
20
|
resolveFileSpecifier(currentFilepath: Filepath, relativePath: string): Filepath | undefined;
|
|
21
|
+
getFileSpecifierInfo(currentFilepath: Filepath, targetFilepath: Filepath): FileSpecifierInfo | undefined;
|
|
15
22
|
setSource(filePath: Filepath, content: string): void;
|
|
16
23
|
getSource(filePath: Filepath): string | undefined;
|
|
17
24
|
deleteSource(filePath: Filepath): void;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { default as Compiler } from '../../../compiler/index';
|
|
2
2
|
import { Filepath, SettingName } from '../../types';
|
|
3
|
-
import { Column, Note, Ref, Table, TableGroup, TokenPosition } from '../../types/schemaJson';
|
|
3
|
+
import { Column, CustomMetadataValue, Note, Ref, Table, TableGroup, TokenPosition } from '../../types/schemaJson';
|
|
4
4
|
import { SyntaxNode } from '../../types/nodes';
|
|
5
5
|
import { NodeSymbol, SymbolKind, MetadataTargetKind } from '../../types/symbol';
|
|
6
6
|
export type MetadataTarget = Table | TableGroup | Note | Column | Ref;
|
|
@@ -14,9 +14,9 @@ interface MetadataField<T extends MetadataTarget> {
|
|
|
14
14
|
isValidBuiltinFieldValue(node?: SyntaxNode): boolean;
|
|
15
15
|
message: string;
|
|
16
16
|
/** Write the metadata value to the element builtin props (e.g. write to `table.note`) */
|
|
17
|
-
assignBuiltinField(element: Partial<T>, value:
|
|
17
|
+
assignBuiltinField(element: Partial<T>, value: CustomMetadataValue, token: TokenPosition): void;
|
|
18
18
|
}
|
|
19
|
-
export type MetadataFieldRegistry<T extends MetadataTarget, K extends SettingName
|
|
19
|
+
export type MetadataFieldRegistry<T extends MetadataTarget, K extends SettingName> = Record<K, MetadataField<T>>;
|
|
20
20
|
export type NameWithSymbolKind = {
|
|
21
21
|
name: string;
|
|
22
22
|
symbolKind: SymbolKind;
|
|
@@ -5,10 +5,12 @@ export type FilepathId = string & {
|
|
|
5
5
|
};
|
|
6
6
|
export declare class Filepath implements Internable<FilepathId> {
|
|
7
7
|
private readonly protocol?;
|
|
8
|
-
private readonly
|
|
8
|
+
private readonly root;
|
|
9
|
+
private readonly segments;
|
|
9
10
|
constructor(absolutePath: string, options?: {
|
|
10
11
|
protocol?: string;
|
|
11
12
|
});
|
|
13
|
+
private get path();
|
|
12
14
|
intern(): FilepathId;
|
|
13
15
|
static from(absolutePath: string): Filepath;
|
|
14
16
|
static resolve(fromDir: string, relativePath: string): Filepath;
|
|
@@ -2,7 +2,8 @@ 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
|
|
5
|
+
export type CustomMetadataValue = string | Color | number | boolean;
|
|
6
|
+
export type CustomMetadata = Record<string, CustomMetadataValue>;
|
|
6
7
|
export type Color = `#${string}` | typeof NONE_COLOR;
|
|
7
8
|
export declare enum AliasKind {
|
|
8
9
|
Table = "table"
|
|
@@ -285,7 +286,7 @@ export interface TableRecord {
|
|
|
285
286
|
token: TokenPosition;
|
|
286
287
|
}
|
|
287
288
|
export type MetadataValues = Record<string, {
|
|
288
|
-
value:
|
|
289
|
+
value: CustomMetadataValue;
|
|
289
290
|
token: TokenPosition;
|
|
290
291
|
}>;
|
|
291
292
|
export type Project = Record<string, never> | {
|
|
@@ -23,6 +23,7 @@ export declare function destructureIndexNode(node?: SyntaxNode): {
|
|
|
23
23
|
} | undefined;
|
|
24
24
|
export declare function extractQuotedStringToken(value?: SyntaxNode): string | undefined;
|
|
25
25
|
export declare function extractNumericLiteral(node?: SyntaxNode): number | null;
|
|
26
|
+
export declare function extractBooleanLiteral(node?: SyntaxNode): boolean | null;
|
|
26
27
|
export declare function destructureCallExpression(node?: SyntaxNode): {
|
|
27
28
|
variables: (PrimaryExpressionNode & {
|
|
28
29
|
expression: VariableNode;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { default as Compiler } from '../../compiler';
|
|
2
|
-
import { Color, ColumnType, CustomMetadata, TokenPosition } from '../types/schemaJson';
|
|
2
|
+
import { Color, ColumnType, CustomMetadata, CustomMetadataValue, TokenPosition } from '../types/schemaJson';
|
|
3
3
|
import { SyntaxNode } from '../types/nodes';
|
|
4
4
|
import { default as Report } from '../types/report';
|
|
5
5
|
import { Settings } from './validate';
|
|
@@ -23,4 +23,4 @@ export declare function processColumnType(compiler: Compiler, typeNode: SyntaxNo
|
|
|
23
23
|
* NOTE: This is used during interpret phase, so no need to validate values, just extract them
|
|
24
24
|
*/
|
|
25
25
|
export declare function extractCustomInlineMetadata(settingMap: Settings, builtinSettings: readonly SettingName[]): CustomMetadata;
|
|
26
|
-
export declare function extractMetadataValue(node?: SyntaxNode):
|
|
26
|
+
export declare function extractMetadataValue(node?: SyntaxNode): CustomMetadataValue | undefined;
|
|
@@ -54,7 +54,6 @@ export declare function isTupleOfVariables(value?: SyntaxNode): value is TupleEx
|
|
|
54
54
|
};
|
|
55
55
|
export declare function isValidColumnType(type: SyntaxNode): boolean;
|
|
56
56
|
export type Settings = Record<SettingName | string, AttributeNode[]>;
|
|
57
|
-
export declare function isValidMetadataValue(value?: SyntaxNode): boolean;
|
|
58
57
|
export declare function aggregateSettingList(settingList?: ListExpressionNode): Report<Settings>;
|
|
59
58
|
export declare function isExpressionAQuotedString(value?: unknown): value is PrimaryExpressionNode & ({
|
|
60
59
|
expression: VariableNode & {
|
package/dist/src/index.d.ts
CHANGED
|
@@ -8,10 +8,11 @@ export { MetadataKind } from './core/types/symbol/metadata';
|
|
|
8
8
|
export * from './core/global_modules/records/utils';
|
|
9
9
|
export * from './core/types/nodes';
|
|
10
10
|
export { SyntaxToken, SyntaxTokenKind, isTriviaToken, isOp, isOpToken, } from './core/types/tokens';
|
|
11
|
-
export { CompileError, CompileErrorCode, } from './core/types/errors';
|
|
11
|
+
export { CompileError, CompileErrorCode, CompileWarning, CompileInfo, } from './core/types/errors';
|
|
12
|
+
export type { Diagnostic, DiagnosticQuickFix } from './services/diagnostics/provider';
|
|
12
13
|
export type { Position, } from './core/types';
|
|
13
14
|
export { ScopeKind, splitQualifiedIdentifier, unescapeString, escapeString, formatRecordValue, isValidIdentifier, addDoubleQuoteIfNeeded, normalizeQualifiedName, } from './compiler/index';
|
|
14
|
-
export { type Database, type MasterDatabase, type Table, type Note, type Column, type ColumnType, type Index, type Check, type InlineRef, type Ref, type RefEndpointPair, type RefEndpoint, type Enum, type EnumField, type TableGroup, type TableGroupField, type Alias, type AliasKind, type TablePartial, type TablePartialInjection, type RecordValue, type RecordValueType, type TableRecord, type Project, type SchemaElement, type TokenPosition, type ElementRef, type FilterConfig, type DiagramView, type CustomMetadata, } from './core/types/schemaJson';
|
|
15
|
+
export { type Database, type MasterDatabase, type Table, type Note, type Column, type ColumnType, type Index, type Check, type InlineRef, type Ref, type RefEndpointPair, type RefEndpoint, type Enum, type EnumField, type TableGroup, type TableGroupField, type Alias, type AliasKind, type TablePartial, type TablePartialInjection, type RecordValue, type RecordValueType, type TableRecord, type Project, type SchemaElement, type TokenPosition, type ElementRef, type FilterConfig, type DiagramView, type CustomMetadata, type CustomMetadataValue, } from './core/types/schemaJson';
|
|
15
16
|
export { type RelationCardinality, type RelationshipOp, getRelationshipOp, getMultiplicities, parseCardinality, makeCardinalityRequired, makeCardinalityOptional, makeRelationshipRequired, isEndpointOneSide, isEndpointManySide, isEndpointOptional, isEndpointRequired, CARDINALITY_ONE, CARDINALITY_MAYBE, CARDINALITY_SOME, CARDINALITY_MANY, } from './core/types/relation';
|
|
16
17
|
export type { DiagramViewSyncOperation, DiagramViewBlock, TextEdit, } from './compiler/queries/transform';
|
|
17
18
|
export { findDiagramViewBlocks } from './compiler/queries/transform';
|
|
@@ -20,10 +20,12 @@ export declare const TABLE_BODY_SUGGESTION_LABELS: ("indexes" | "checks" | "Note
|
|
|
20
20
|
export declare const PROJECT_FIELD_SUGGESTION_LABELS: ("Table" | "Enum" | "TableGroup" | "TablePartial" | "Note" | "Ref" | "Dep")[];
|
|
21
21
|
export interface DBMLCompletionItemProviderOptions {
|
|
22
22
|
triggerCharacters?: string[];
|
|
23
|
+
fileListDepth?: number;
|
|
23
24
|
}
|
|
24
25
|
export default class DBMLCompletionItemProvider implements CompletionItemProvider {
|
|
25
26
|
private compiler;
|
|
26
27
|
triggerCharacters: string[];
|
|
28
|
+
fileListDepth: number;
|
|
27
29
|
constructor(compiler: Compiler, options?: DBMLCompletionItemProviderOptions);
|
|
28
30
|
provideCompletionItems(model: TextModel, position: Position): CompletionList;
|
|
29
31
|
}
|
|
@@ -2,4 +2,7 @@ import { default as Compiler } from '../../compiler';
|
|
|
2
2
|
import { Filepath } from '../../core/types/filepath';
|
|
3
3
|
import { SyntaxToken } from '../../core/types/tokens';
|
|
4
4
|
import { CompletionList, TextModel } from '../types';
|
|
5
|
-
export
|
|
5
|
+
export interface SuggestUseCompletionOptions {
|
|
6
|
+
fileListDepth?: number;
|
|
7
|
+
}
|
|
8
|
+
export declare function suggestUseCompletion(compiler: Compiler, filepath: Filepath, offset: number, bOcToken: SyntaxToken | undefined, model: TextModel, options?: SuggestUseCompletionOptions): CompletionList | null;
|
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.4.0-alpha.
|
|
4
|
+
"version": "10.4.0-alpha.3",
|
|
5
5
|
"description": "DBML parser v2",
|
|
6
6
|
"author": "Holistics <dev@holistics.io>",
|
|
7
7
|
"license": "Apache-2.0",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"dist"
|
|
26
26
|
],
|
|
27
27
|
"scripts": {
|
|
28
|
-
"build": "
|
|
28
|
+
"build": "rimraf ./dist && tsc --noEmit && vite build",
|
|
29
29
|
"dev": "vite build --watch",
|
|
30
30
|
"test": "vitest run",
|
|
31
31
|
"test:watch": "vitest watch",
|
|
@@ -51,5 +51,5 @@
|
|
|
51
51
|
"engines": {
|
|
52
52
|
"node": ">=18"
|
|
53
53
|
},
|
|
54
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "3c5f2624711c16e2b5011f118c62899f41abca7d"
|
|
55
55
|
}
|