@dbml/parse 10.3.0 → 10.4.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 +25 -25
- package/dist/dbml-parse.mjs +2569 -2473
- package/dist/src/compiler/index.d.ts +19 -0
- package/dist/src/compiler/queries/metadata/isSymbolVisible.d.ts +10 -0
- package/dist/src/compiler/queries/metadata/metadataTargets.d.ts +7 -0
- package/dist/src/compiler/queries/symbol/visibleSymbols.d.ts +7 -0
- package/dist/src/core/global_modules/metadata/utils.d.ts +9 -7
- package/dist/src/core/global_modules/ref/index.d.ts +4 -0
- package/dist/src/core/global_modules/ref/interpret.d.ts +3 -1
- package/dist/src/core/types/schemaJson/types.d.ts +1 -0
- package/dist/src/core/types/symbol/symbols.d.ts +11 -1
- package/dist/src/services/suggestions/provider.d.ts +1 -1
- package/package.json +2 -2
|
@@ -50,7 +50,26 @@ 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[];
|
|
53
68
|
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
|
+
*/
|
|
54
73
|
reachableFiles: (entry?: Filepath | undefined) => Filepath[];
|
|
55
74
|
usableMembers: (symbolOrFilepath: Filepath | import('../core/types/symbol').SchemaSymbol | import('../core/types/symbol').ProgramSymbol) => import('../core/types/report').default<{
|
|
56
75
|
nonSchemaMembers: import('../core/types/symbol').NodeSymbol[];
|
|
@@ -0,0 +1,10 @@
|
|
|
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;
|
|
@@ -0,0 +1,7 @@
|
|
|
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[];
|
|
@@ -0,0 +1,7 @@
|
|
|
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[];
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { default as Compiler } from '../../../compiler/index';
|
|
2
2
|
import { Filepath, SettingName } from '../../types';
|
|
3
|
-
import { Column, Note, Table, TableGroup, TokenPosition } from '../../types/schemaJson';
|
|
4
|
-
import {
|
|
3
|
+
import { Column, Note, Ref, Table, TableGroup, TokenPosition } from '../../types/schemaJson';
|
|
4
|
+
import { 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 | Ref;
|
|
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,13 +17,15 @@ 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
|
-
type NameWithSymbolKind = {
|
|
20
|
+
export 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: MetadataTargetKind): NameWithSymbolKind[];
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
export declare function mapNamePartToSymbolKind(nameParts: string[], targetKind: Exclude<MetadataTargetKind, MetadataTargetKind.Ref>): NameWithSymbolKind[];
|
|
26
|
+
/**
|
|
27
|
+
* Merge every custom-metadata block applying to the target in the current program (in precedence order) to its `metadata` and other builtin (note/headercolor/...) fields
|
|
28
|
+
* NOTE: Only run during interpret phase
|
|
29
|
+
*/
|
|
28
30
|
export declare function attachCustomMetadata<T extends MetadataTarget>(compiler: Compiler, targetElement: Partial<T>, targetSymbol: NodeSymbol, fieldsRegistry: MetadataFieldRegistry<T, any>, filepath: Filepath): void;
|
|
29
31
|
export {};
|
|
@@ -2,6 +2,10 @@ 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';
|
|
5
6
|
import { GlobalModule } from '../types';
|
|
7
|
+
export declare const refUtils: {
|
|
8
|
+
getDuplicateError(name: string, schemaLabel: string, errorNode: SyntaxNode): CompileError;
|
|
9
|
+
};
|
|
6
10
|
export declare const refModule: GlobalModule;
|
|
7
11
|
export declare function nodeRefereeOfRefEndpoint(compiler: Compiler, globalSymbol: NodeSymbol, node: SyntaxNode): Report<NodeSymbol | undefined>;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { Ref } from '../../types/schemaJson';
|
|
2
|
-
import { RefMetadata, Filepath } from '../../types';
|
|
2
|
+
import { RefMetadata, SettingName, 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>;
|
|
5
7
|
export declare class RefInterpreter {
|
|
6
8
|
private compiler;
|
|
7
9
|
private metadata;
|
|
@@ -16,6 +16,7 @@ export declare enum SymbolKind {
|
|
|
16
16
|
Enum = "Enum",
|
|
17
17
|
EnumField = "Enum field",
|
|
18
18
|
StickyNote = "Note",
|
|
19
|
+
Ref = "Ref",
|
|
19
20
|
TablePartial = "TablePartial",
|
|
20
21
|
PartialInjection = "PartialInjection",
|
|
21
22
|
DiagramView = "DiagramView",
|
|
@@ -41,7 +42,8 @@ export declare enum MetadataTargetKind {
|
|
|
41
42
|
Table = "Table",
|
|
42
43
|
Column = "Column",
|
|
43
44
|
TableGroup = "TableGroup",
|
|
44
|
-
Note = "Note"
|
|
45
|
+
Note = "Note",
|
|
46
|
+
Ref = "Ref"
|
|
45
47
|
}
|
|
46
48
|
declare const __nodeSymbolBrand: unique symbol;
|
|
47
49
|
export type NodeSymbolId = number & {
|
|
@@ -211,6 +213,14 @@ export declare class NoteSymbol extends NodeSymbol {
|
|
|
211
213
|
get canBeImported(): boolean;
|
|
212
214
|
get originalSymbol(): NodeSymbol;
|
|
213
215
|
}
|
|
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
|
+
}
|
|
214
224
|
export declare class TablePartialSymbol extends NodeSymbol {
|
|
215
225
|
constructor({ declaration, name, }: {
|
|
216
226
|
declaration?: SyntaxNode;
|
|
@@ -27,4 +27,4 @@ export default class DBMLCompletionItemProvider implements CompletionItemProvide
|
|
|
27
27
|
constructor(compiler: Compiler, options?: DBMLCompletionItemProviderOptions);
|
|
28
28
|
provideCompletionItems(model: TextModel, position: Position): CompletionList;
|
|
29
29
|
}
|
|
30
|
-
export declare const TOP_LEVEL_SUGGESTION_LABELS: ("Table" | "Enum" | "TableGroup" | "TablePartial" | "Note" | "
|
|
30
|
+
export declare const TOP_LEVEL_SUGGESTION_LABELS: ("Table" | "Enum" | "TableGroup" | "TablePartial" | "Note" | "Ref" | "DiagramView" | "Metadata" | "Dep" | "Project" | "Records")[];
|
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
|
+
"version": "10.4.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": "ed4c390c2ce94cb9e73e3e84610917e1f15527ff"
|
|
55
55
|
}
|