@dbml/parse 10.4.0-alpha.1 → 10.4.0-alpha.2
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 +27 -27
- package/dist/dbml-parse.mjs +4389 -4455
- package/dist/src/compiler/index.d.ts +2 -20
- package/dist/src/compiler/projectLayout/layout.d.ts +7 -0
- package/dist/src/core/global_modules/metadata/utils.d.ts +7 -9
- package/dist/src/core/global_modules/ref/index.d.ts +0 -4
- package/dist/src/core/global_modules/ref/interpret.d.ts +1 -3
- package/dist/src/core/types/filepath.d.ts +3 -1
- package/dist/src/core/types/schemaJson/types.d.ts +0 -5
- package/dist/src/core/types/symbol/symbols.d.ts +1 -11
- package/dist/src/index.d.ts +2 -1
- package/dist/src/services/definition/provider.d.ts +1 -0
- package/dist/src/services/suggestions/provider.d.ts +3 -1
- package/dist/src/services/suggestions/use.d.ts +4 -1
- package/package.json +3 -3
- package/dist/src/compiler/queries/metadata/isSymbolVisible.d.ts +0 -10
- package/dist/src/compiler/queries/metadata/metadataTargets.d.ts +0 -7
- package/dist/src/compiler/queries/symbol/visibleSymbols.d.ts +0 -7
|
@@ -50,26 +50,7 @@ export default class Compiler {
|
|
|
50
50
|
symbolMetadata: (symbol: import('../core/types/symbol').NodeSymbol) => import('../core/types/symbol').NodeMetadata[];
|
|
51
51
|
symbolAliases: (symbol: import('../core/types/symbol').NodeSymbol) => import('../core/types/report').default<import('../core/types/symbol').AliasSymbol[]>;
|
|
52
52
|
symbolUses: (symbol: import('../core/types/symbol').NodeSymbol) => import('../core/types/report').default<import('../core/types/symbol').UseSymbol[]>;
|
|
53
|
-
/**
|
|
54
|
-
* A global query
|
|
55
|
-
* Return the named refs visible from a program (refs are not imported via `use`).
|
|
56
|
-
*/
|
|
57
|
-
visibleSymbols: (program: import('../core/types/symbol').ProgramSymbol, kind: import('../core/types/symbol').SymbolKind) => import('../core/types/symbol').RefSymbol[];
|
|
58
|
-
/**
|
|
59
|
-
* A global query
|
|
60
|
-
* Whether a symbol is visible from a program
|
|
61
|
-
*/
|
|
62
|
-
isSymbolVisible: (program: import('../core/types/symbol').ProgramSymbol, symbol: import('../core/types/symbol').NodeSymbol) => boolean;
|
|
63
|
-
/**
|
|
64
|
-
* A global query
|
|
65
|
-
* Resolve all candidates that a metadata block can target
|
|
66
|
-
*/
|
|
67
|
-
metadataTargets: (block: import('../core/types/symbol').MetadataElementMetadata) => import('../core/types/symbol').NodeSymbol[];
|
|
68
53
|
fileDependencies: (filepath: Filepath) => Filepath[];
|
|
69
|
-
/**
|
|
70
|
-
* A global query
|
|
71
|
-
* BFS-traverse imports from an entry filepath and return all reachable files. Related: fileDependencies.
|
|
72
|
-
*/
|
|
73
54
|
reachableFiles: (entry?: Filepath | undefined) => Filepath[];
|
|
74
55
|
usableMembers: (symbolOrFilepath: Filepath | import('../core/types/symbol').SchemaSymbol | import('../core/types/symbol').ProgramSymbol) => import('../core/types/report').default<{
|
|
75
56
|
nonSchemaMembers: import('../core/types/symbol').NodeSymbol[];
|
|
@@ -109,7 +90,7 @@ export default class Compiler {
|
|
|
109
90
|
source: (filepath: Filepath) => string;
|
|
110
91
|
ast: (filepath?: Filepath) => Readonly<import('../core/types/nodes').ProgramNode>;
|
|
111
92
|
errors: (filepath?: Filepath) => readonly Readonly<import('..').CompileError>[];
|
|
112
|
-
warnings: (filepath?: Filepath) => readonly Readonly<import('
|
|
93
|
+
warnings: (filepath?: Filepath) => readonly Readonly<import('..').CompileWarning>[];
|
|
113
94
|
tokens: (filepath?: Filepath) => readonly Readonly<import('..').SyntaxToken>[];
|
|
114
95
|
rawDb: (filepath?: Filepath) => Readonly<import('..').Database> | undefined;
|
|
115
96
|
publicSymbolTable: (filepath?: Filepath) => readonly Readonly<import('../core/types/symbol').NodeSymbol>[] | undefined;
|
|
@@ -130,6 +111,7 @@ export default class Compiler {
|
|
|
130
111
|
initMonacoServices(options?: {
|
|
131
112
|
autocompletion?: {
|
|
132
113
|
triggerCharacters?: string[];
|
|
114
|
+
fileListDepth?: number;
|
|
133
115
|
};
|
|
134
116
|
}): {
|
|
135
117
|
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,9 +1,9 @@
|
|
|
1
1
|
import { default as Compiler } from '../../../compiler/index';
|
|
2
2
|
import { Filepath, SettingName } from '../../types';
|
|
3
|
-
import { Column, Note,
|
|
4
|
-
import { SyntaxNode } from '../../types/nodes';
|
|
3
|
+
import { Column, Note, Table, TableGroup, TokenPosition } from '../../types/schemaJson';
|
|
4
|
+
import { ElementDeclarationNode, SyntaxNode } from '../../types/nodes';
|
|
5
5
|
import { NodeSymbol, SymbolKind, MetadataTargetKind } from '../../types/symbol';
|
|
6
|
-
export type MetadataTarget = Table | TableGroup | Note | Column
|
|
6
|
+
export type MetadataTarget = Table | TableGroup | Note | Column;
|
|
7
7
|
/**
|
|
8
8
|
* Specs for builtin metadata (table's note, tablegroup's color, .etc) for different element types. Does 2 things:
|
|
9
9
|
* - `validate`: Validating if the metadata value is syntactically correct
|
|
@@ -17,15 +17,13 @@ interface MetadataField<T extends MetadataTarget> {
|
|
|
17
17
|
assignBuiltinField(element: Partial<T>, value: string, token: TokenPosition): void;
|
|
18
18
|
}
|
|
19
19
|
export type MetadataFieldRegistry<T extends MetadataTarget, K extends SettingName = SettingName> = Record<K, MetadataField<T>>;
|
|
20
|
-
|
|
20
|
+
type NameWithSymbolKind = {
|
|
21
21
|
name: string;
|
|
22
22
|
symbolKind: SymbolKind;
|
|
23
23
|
};
|
|
24
24
|
/** @internal Exported for testing only. */
|
|
25
|
-
export declare function mapNamePartToSymbolKind(nameParts: string[], targetKind:
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
* NOTE: Only run during interpret phase
|
|
29
|
-
*/
|
|
25
|
+
export declare function mapNamePartToSymbolKind(nameParts: string[], targetKind: MetadataTargetKind): NameWithSymbolKind[];
|
|
26
|
+
export declare function resolveMetadataTarget(compiler: Compiler, metadataNode: ElementDeclarationNode): NodeSymbol | undefined;
|
|
27
|
+
/** Merge every custom-metadata block, reachable from the current program, targeting element to it's `metadata` and other builtin (note/headercolor/...) fields */
|
|
30
28
|
export declare function attachCustomMetadata<T extends MetadataTarget>(compiler: Compiler, targetElement: Partial<T>, targetSymbol: NodeSymbol, fieldsRegistry: MetadataFieldRegistry<T, any>, filepath: Filepath): void;
|
|
31
29
|
export {};
|
|
@@ -2,10 +2,6 @@ import { default as Compiler } from '../../../compiler/index';
|
|
|
2
2
|
import { SyntaxNode } from '../../types/nodes';
|
|
3
3
|
import { default as Report } from '../../types/report';
|
|
4
4
|
import { NodeSymbol } from '../../types/symbol';
|
|
5
|
-
import { CompileError } from '../../types';
|
|
6
5
|
import { GlobalModule } from '../types';
|
|
7
|
-
export declare const refUtils: {
|
|
8
|
-
getDuplicateError(name: string, schemaLabel: string, errorNode: SyntaxNode): CompileError;
|
|
9
|
-
};
|
|
10
6
|
export declare const refModule: GlobalModule;
|
|
11
7
|
export declare function nodeRefereeOfRefEndpoint(compiler: Compiler, globalSymbol: NodeSymbol, node: SyntaxNode): Report<NodeSymbol | undefined>;
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { Ref } from '../../types/schemaJson';
|
|
2
|
-
import { RefMetadata,
|
|
2
|
+
import { RefMetadata, Filepath } from '../../types';
|
|
3
3
|
import { default as Compiler } from '../../../compiler';
|
|
4
4
|
import { default as Report } from '../../types/report';
|
|
5
|
-
import { MetadataFieldRegistry } from '../metadata/utils';
|
|
6
|
-
export declare const REF_METADATA_FIELDS: MetadataFieldRegistry<Ref, SettingName.Color | SettingName.Note>;
|
|
7
5
|
export declare class RefInterpreter {
|
|
8
6
|
private compiler;
|
|
9
7
|
private metadata;
|
|
@@ -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;
|
|
@@ -164,14 +164,9 @@ export interface Ref {
|
|
|
164
164
|
name: string | null;
|
|
165
165
|
endpoints: RefEndpointPair;
|
|
166
166
|
color?: Color;
|
|
167
|
-
note?: {
|
|
168
|
-
value: string;
|
|
169
|
-
token: TokenPosition;
|
|
170
|
-
};
|
|
171
167
|
onDelete?: string;
|
|
172
168
|
onUpdate?: string;
|
|
173
169
|
inactive?: boolean;
|
|
174
|
-
metadata?: CustomMetadata;
|
|
175
170
|
token: TokenPosition;
|
|
176
171
|
}
|
|
177
172
|
export type RefEndpointPair = [RefEndpoint, RefEndpoint];
|
|
@@ -16,7 +16,6 @@ export declare enum SymbolKind {
|
|
|
16
16
|
Enum = "Enum",
|
|
17
17
|
EnumField = "Enum field",
|
|
18
18
|
StickyNote = "Note",
|
|
19
|
-
Ref = "Ref",
|
|
20
19
|
TablePartial = "TablePartial",
|
|
21
20
|
PartialInjection = "PartialInjection",
|
|
22
21
|
DiagramView = "DiagramView",
|
|
@@ -42,8 +41,7 @@ export declare enum MetadataTargetKind {
|
|
|
42
41
|
Table = "Table",
|
|
43
42
|
Column = "Column",
|
|
44
43
|
TableGroup = "TableGroup",
|
|
45
|
-
Note = "Note"
|
|
46
|
-
Ref = "Ref"
|
|
44
|
+
Note = "Note"
|
|
47
45
|
}
|
|
48
46
|
declare const __nodeSymbolBrand: unique symbol;
|
|
49
47
|
export type NodeSymbolId = number & {
|
|
@@ -213,14 +211,6 @@ export declare class NoteSymbol extends NodeSymbol {
|
|
|
213
211
|
get canBeImported(): boolean;
|
|
214
212
|
get originalSymbol(): NodeSymbol;
|
|
215
213
|
}
|
|
216
|
-
export declare class RefSymbol extends NodeSymbol {
|
|
217
|
-
constructor({ declaration, name, }: {
|
|
218
|
-
declaration?: SyntaxNode;
|
|
219
|
-
name?: string;
|
|
220
|
-
}, id: NodeSymbolId, filepath: Filepath);
|
|
221
|
-
get canBeImported(): boolean;
|
|
222
|
-
get originalSymbol(): NodeSymbol;
|
|
223
|
-
}
|
|
224
214
|
export declare class TablePartialSymbol extends NodeSymbol {
|
|
225
215
|
constructor({ declaration, name, }: {
|
|
226
216
|
declaration?: SyntaxNode;
|
package/dist/src/index.d.ts
CHANGED
|
@@ -8,7 +8,8 @@ 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
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, } from './core/types/schemaJson';
|
|
@@ -20,11 +20,13 @@ 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
|
}
|
|
30
|
-
export declare const TOP_LEVEL_SUGGESTION_LABELS: ("Table" | "Enum" | "TableGroup" | "TablePartial" | "Note" | "
|
|
32
|
+
export declare const TOP_LEVEL_SUGGESTION_LABELS: ("Table" | "Enum" | "TableGroup" | "TablePartial" | "Note" | "DiagramView" | "Metadata" | "Ref" | "Dep" | "Project" | "Records")[];
|
|
@@ -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.2",
|
|
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": "cdf36a18c335cfea80135fabab1b8f80c7466cfd"
|
|
55
55
|
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { NodeSymbol, ProgramSymbol } from '../../../core/types/symbol';
|
|
2
|
-
import { default as Compiler } from '../../index';
|
|
3
|
-
/**
|
|
4
|
-
* Whether `symbol` is visible from `program`.
|
|
5
|
-
* - Column: visible when its table is (a column is not a direct schema member)
|
|
6
|
-
* - Ref: refs are not imported via `use`, a ref is visible when it shows up in the program's output,
|
|
7
|
-
* i.e. the program reaches the ref's file and sees both endpoint tables (RefMetadata.owners)
|
|
8
|
-
* - otherwise: the symbol sits in the program's schemas, directly or through `use`
|
|
9
|
-
*/
|
|
10
|
-
export declare function isSymbolVisible(this: Compiler, program: ProgramSymbol, symbol: NodeSymbol): boolean;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { NodeSymbol } from '../../../core/types/symbol';
|
|
2
|
-
import { MetadataElementMetadata } from '../../../core/types/symbol/metadata';
|
|
3
|
-
import { default as Compiler } from '../../index';
|
|
4
|
-
/**
|
|
5
|
-
* Resolve the candidates a Metadata block targets, from its `<target-kind> <name>` header.
|
|
6
|
-
*/
|
|
7
|
-
export declare function metadataTargets(this: Compiler, block: MetadataElementMetadata): NodeSymbol[];
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { ProgramSymbol, RefSymbol, SymbolKind } from '../../../core/types/symbol';
|
|
2
|
-
import { default as Compiler } from '../../index';
|
|
3
|
-
/**
|
|
4
|
-
* Named refs usable from `program`: refs are not imported via `use`, a named ref is visible
|
|
5
|
-
* wherever it shows up in the output (see isSymbolVisible).
|
|
6
|
-
*/
|
|
7
|
-
export declare function visibleSymbols(this: Compiler, program: ProgramSymbol, kind: SymbolKind): RefSymbol[];
|