@dbml/parse 8.3.0 → 8.3.1-custom-metadata.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/dbml-parse.js +16 -16
- package/dist/dbml-parse.mjs +3042 -2529
- package/dist/src/compiler/index.d.ts +1 -1
- package/dist/src/compiler/queries/container/element.d.ts +2 -2
- package/dist/src/compiler/types.d.ts +2 -1
- package/dist/src/core/global_modules/metadata/bind.d.ts +11 -0
- package/dist/src/core/global_modules/metadata/index.d.ts +2 -0
- package/dist/src/core/global_modules/metadata/interpret.d.ts +23 -0
- package/dist/src/core/global_modules/metadata/overlap.d.ts +14 -0
- package/dist/src/core/global_modules/metadata/resolve.d.ts +4 -0
- package/dist/src/core/global_modules/program/interpret.d.ts +4 -0
- package/dist/src/core/global_modules/utils.d.ts +3 -1
- package/dist/src/core/local_modules/metadata/index.d.ts +2 -0
- package/dist/src/core/local_modules/metadata/validate.d.ts +14 -0
- package/dist/src/core/parser/parser.d.ts +1 -0
- package/dist/src/core/types/errors.d.ts +6 -1
- package/dist/src/core/types/keywords.d.ts +2 -1
- package/dist/src/core/types/nodes.d.ts +34 -6
- package/dist/src/core/types/schemaJson.d.ts +15 -1
- package/dist/src/core/types/symbol/metadata.d.ts +11 -2
- package/dist/src/core/types/symbol/symbols.d.ts +10 -0
- package/dist/src/core/utils/interpret.d.ts +1 -1
- package/dist/src/core/utils/span.d.ts +2 -2
- package/dist/src/core/utils/tokens.d.ts +3 -0
- package/dist/src/core/utils/validate.d.ts +19 -2
- package/package.json +2 -2
|
@@ -100,7 +100,7 @@ export default class Compiler {
|
|
|
100
100
|
token: undefined;
|
|
101
101
|
index: undefined;
|
|
102
102
|
};
|
|
103
|
-
element: (filepath: Filepath, offset: number) => Readonly<import('../core/types/nodes').ElementDeclarationNode | import('../core/types/nodes').ProgramNode>;
|
|
103
|
+
element: (filepath: Filepath, offset: number) => Readonly<import('../core/types/nodes').ElementDeclarationNode | import('../core/types/nodes').ProgramNode | import('../core/types/nodes').MetadataDeclarationNode>;
|
|
104
104
|
scope: (filepath: Filepath, offset: number) => import('../core/types/symbol').NodeSymbol[] | undefined;
|
|
105
105
|
scopeKind: (filepath: Filepath, offset: number) => import('./types').ScopeKind;
|
|
106
106
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { Filepath } from '../../../core/types/filepath';
|
|
2
|
-
import { ElementDeclarationNode, ProgramNode } from '../../../core/types/nodes';
|
|
2
|
+
import { ElementDeclarationNode, MetadataDeclarationNode, ProgramNode } from '../../../core/types/nodes';
|
|
3
3
|
import { default as Compiler } from '../../index';
|
|
4
|
-
export declare function containerElement(this: Compiler, filepath: Filepath, offset: number): Readonly<ElementDeclarationNode | ProgramNode>;
|
|
4
|
+
export declare function containerElement(this: Compiler, filepath: Filepath, offset: number): Readonly<ElementDeclarationNode | MetadataDeclarationNode | ProgramNode>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { default as Compiler } from '../../../compiler';
|
|
2
|
+
import { CompileError } from '../../types';
|
|
3
|
+
import { MetadataDeclarationNode } from '../../types/nodes';
|
|
4
|
+
export default class MetadataBinder {
|
|
5
|
+
private compiler;
|
|
6
|
+
private declarationNode;
|
|
7
|
+
constructor(compiler: Compiler, declarationNode: MetadataDeclarationNode);
|
|
8
|
+
bind(): CompileError[];
|
|
9
|
+
private bindTargetElement;
|
|
10
|
+
private bindBody;
|
|
11
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { default as Compiler } from '../../../compiler';
|
|
2
|
+
import { Filepath } from '../../types';
|
|
3
|
+
import { MetadataElementMetadata } from '../../types/symbol/metadata';
|
|
4
|
+
import { SyntaxNode } from '../../types/nodes';
|
|
5
|
+
import { default as Report } from '../../types/report';
|
|
6
|
+
import { Color, CustomMetadata, MetadataElement } from '../../types/schemaJson';
|
|
7
|
+
import { Settings } from '../../utils/validate';
|
|
8
|
+
export declare function extractValue(node?: SyntaxNode): string | number | boolean | Color | undefined;
|
|
9
|
+
export declare const TABLE_BUILTIN_SETTINGS: readonly ["headercolor", "note"];
|
|
10
|
+
export declare const TABLEGROUP_BUILTIN_SETTINGS: readonly ["color", "note"];
|
|
11
|
+
export declare const NOTE_BUILTIN_SETTINGS: readonly ["color"];
|
|
12
|
+
export declare const COLUMN_BUILTIN_SETTINGS: readonly ["pk", "primary key", "unique", "note", "ref", "default", "check", "increment", "not null", "null"];
|
|
13
|
+
export declare function extractInlineMetadata(settingMap: Settings, builtinSettingNames: readonly string[]): CustomMetadata;
|
|
14
|
+
export default class MetadataInterpreter {
|
|
15
|
+
private declarationNode;
|
|
16
|
+
private compiler;
|
|
17
|
+
private filepath;
|
|
18
|
+
private metadata;
|
|
19
|
+
constructor(compiler: Compiler, metadata: MetadataElementMetadata, filepath: Filepath);
|
|
20
|
+
interpret(): Report<MetadataElement>;
|
|
21
|
+
private interpretTarget;
|
|
22
|
+
private interpretValues;
|
|
23
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { MetadataTargetKind } from '../../types/symbol';
|
|
2
|
+
export declare enum OverlapValueKind {
|
|
3
|
+
Note = "note",
|
|
4
|
+
Color = "color",
|
|
5
|
+
HeaderColor = "headercolor"
|
|
6
|
+
}
|
|
7
|
+
export type OverlapInlineField = 'note' | 'color' | 'headerColor';
|
|
8
|
+
export interface OverlapKey {
|
|
9
|
+
metaKey: string;
|
|
10
|
+
field: OverlapInlineField;
|
|
11
|
+
reshape: OverlapValueKind;
|
|
12
|
+
}
|
|
13
|
+
export declare const OVERLAP_KEYS: Partial<Record<MetadataTargetKind, OverlapKey[]>>;
|
|
14
|
+
export declare function findOverlapKey(kind: MetadataTargetKind | undefined, key: string): OverlapKey | undefined;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { default as Compiler } from '../../../compiler/index';
|
|
2
|
+
import { MetadataDeclarationNode } from '../../types/nodes';
|
|
3
|
+
import { NodeSymbol } from '../../types/symbol';
|
|
4
|
+
export declare function resolveMetadataTarget(compiler: Compiler, metadataNode: MetadataDeclarationNode): NodeSymbol | undefined;
|
|
@@ -11,13 +11,17 @@ export default class ProgramInterpreter {
|
|
|
11
11
|
private errors;
|
|
12
12
|
private warnings;
|
|
13
13
|
private db;
|
|
14
|
+
private emittedBySymbol;
|
|
14
15
|
constructor(compiler: Compiler, symbol: ProgramSymbol, filepath: Filepath);
|
|
15
16
|
interpret(): Report<SchemaElement | SchemaElement[] | undefined>;
|
|
16
17
|
private interpretAllSymbols;
|
|
17
18
|
private interpretUseSymbol;
|
|
18
19
|
private interpretAllMetadata;
|
|
20
|
+
private promoteOverlapKeys;
|
|
21
|
+
private attachMetadata;
|
|
19
22
|
private interpretAllAliases;
|
|
20
23
|
private validateRecords;
|
|
21
24
|
private collectPartialRefs;
|
|
22
25
|
private pushElement;
|
|
26
|
+
private recordEmitted;
|
|
23
27
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { default as Compiler } from '../../compiler';
|
|
2
|
-
import { RelationCardinality } from '../types';
|
|
2
|
+
import { Filepath, RelationCardinality } from '../types';
|
|
3
3
|
import { PrimaryExpressionNode, SyntaxNode, VariableNode } from '../types/nodes';
|
|
4
4
|
import { default as Report } from '../types/report';
|
|
5
5
|
import { NodeSymbol } from '../types/symbol';
|
|
@@ -15,3 +15,5 @@ export declare function scanNonListNodeForBinding(node?: SyntaxNode): {
|
|
|
15
15
|
}[];
|
|
16
16
|
export declare function nodeRefereeOfLeftExpression(compiler: Compiler, node: SyntaxNode): NodeSymbol | undefined;
|
|
17
17
|
export declare function getMultiplicities(op: string): [RelationCardinality, RelationCardinality] | undefined;
|
|
18
|
+
export declare function getDefaultSchemaSymbol(compiler: Compiler, globalSymbol: NodeSymbol): NodeSymbol | undefined;
|
|
19
|
+
export declare function getGlobalSymbol(compiler: Compiler, filepath: Filepath): NodeSymbol | undefined;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { default as Compiler } from '../../../compiler';
|
|
2
|
+
import { CompileError } from '../../types/errors';
|
|
3
|
+
import { MetadataDeclarationNode } from '../../types/nodes';
|
|
4
|
+
export default class MetadataValidator {
|
|
5
|
+
private compiler;
|
|
6
|
+
private declarationNode;
|
|
7
|
+
constructor(compiler: Compiler, declarationNode: MetadataDeclarationNode);
|
|
8
|
+
validate(): CompileError[];
|
|
9
|
+
private validateTargetKind;
|
|
10
|
+
private validateTargetName;
|
|
11
|
+
private validateBody;
|
|
12
|
+
private validateFields;
|
|
13
|
+
private validateSubElements;
|
|
14
|
+
}
|
|
@@ -32,6 +32,7 @@ export default class Parser {
|
|
|
32
32
|
private synchronizeUseSpecifierList;
|
|
33
33
|
private useSpecifier;
|
|
34
34
|
private synchronizeProgram;
|
|
35
|
+
private metadataDeclaration;
|
|
35
36
|
private elementDeclaration;
|
|
36
37
|
private synchronizeElementDeclarationName;
|
|
37
38
|
private synchronizeElementDeclarationAlias;
|
|
@@ -113,7 +113,12 @@ export declare enum CompileErrorCode {
|
|
|
113
113
|
SAME_ENDPOINT = 5002,
|
|
114
114
|
UNEQUAL_FIELDS_BINARY_REF = 5003,
|
|
115
115
|
CONFLICTING_SETTING = 5004,
|
|
116
|
-
TABLE_REAPPEAR_IN_TABLEGROUP = 5005
|
|
116
|
+
TABLE_REAPPEAR_IN_TABLEGROUP = 5005,
|
|
117
|
+
INVALID_METADATA_CONTEXT = 5006,
|
|
118
|
+
INVALID_METADATA_TARGET_KIND = 5007,
|
|
119
|
+
INVALID_METADATA_FIELD = 5008,
|
|
120
|
+
DUPLICATE_METADATA_FIELD = 5009,
|
|
121
|
+
METADATA_TARGET_NOT_FOUND = 5010
|
|
117
122
|
}
|
|
118
123
|
export declare class CompileError extends Error {
|
|
119
124
|
code: Readonly<CompileErrorCode>;
|
|
@@ -13,7 +13,8 @@ export declare enum ElementKind {
|
|
|
13
13
|
DiagramViewTables = "tables",
|
|
14
14
|
DiagramViewNotes = "notes",
|
|
15
15
|
DiagramViewTableGroups = "tablegroups",
|
|
16
|
-
DiagramViewSchemas = "schemas"
|
|
16
|
+
DiagramViewSchemas = "schemas",
|
|
17
|
+
Metadata = "metadata"
|
|
17
18
|
}
|
|
18
19
|
export declare enum SettingName {
|
|
19
20
|
Color = "color",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Filepath } from './filepath';
|
|
2
2
|
import { Internable } from './internable';
|
|
3
3
|
import { ElementKind } from './keywords';
|
|
4
|
-
import { ImportKind, SymbolKind } from './symbol';
|
|
4
|
+
import { ImportKind, MetadataTargetKind, SymbolKind } from './symbol';
|
|
5
5
|
import { Position } from './position';
|
|
6
6
|
import { SyntaxToken } from './tokens';
|
|
7
7
|
export type SyntaxNodeId = number;
|
|
@@ -36,6 +36,7 @@ export declare class SyntaxNode implements Internable<InternedSyntaxNode> {
|
|
|
36
36
|
export declare enum SyntaxNodeKind {
|
|
37
37
|
PROGRAM = "<program>",
|
|
38
38
|
ELEMENT_DECLARATION = "<element-declaration>",
|
|
39
|
+
METADATA_DECLARATION = "<metadata-declaration>",
|
|
39
40
|
USE_DECLARATION = "<use-declaration>",
|
|
40
41
|
USE_SPECIFIER = "<use-specifier>",
|
|
41
42
|
USE_SPECIFIER_LIST = "<use-specifier-list>",
|
|
@@ -60,16 +61,17 @@ export declare enum SyntaxNodeKind {
|
|
|
60
61
|
WILDCARD = "<wildcard>"
|
|
61
62
|
}
|
|
62
63
|
export declare class ProgramNode extends SyntaxNode {
|
|
63
|
-
body: (UseDeclarationNode | ElementDeclarationNode)[];
|
|
64
|
+
body: (UseDeclarationNode | ElementDeclarationNode | MetadataDeclarationNode)[];
|
|
64
65
|
eof?: SyntaxToken;
|
|
65
66
|
source: string;
|
|
66
67
|
constructor({ body, eof, source, }: {
|
|
67
|
-
body?: (UseDeclarationNode | ElementDeclarationNode)[];
|
|
68
|
+
body?: (UseDeclarationNode | ElementDeclarationNode | MetadataDeclarationNode)[];
|
|
68
69
|
eof?: SyntaxToken;
|
|
69
70
|
source: string;
|
|
70
71
|
}, id: SyntaxNodeId, filepath: Filepath);
|
|
71
72
|
get declarations(): ElementDeclarationNode[];
|
|
72
73
|
get uses(): UseDeclarationNode[];
|
|
74
|
+
get metadata(): MetadataDeclarationNode[];
|
|
73
75
|
}
|
|
74
76
|
export declare class UseDeclarationNode extends SyntaxNode {
|
|
75
77
|
useKeyword?: SyntaxToken;
|
|
@@ -86,11 +88,13 @@ export declare class UseDeclarationNode extends SyntaxNode {
|
|
|
86
88
|
}
|
|
87
89
|
export declare class UseSpecifierNode extends SyntaxNode {
|
|
88
90
|
importKind?: SyntaxToken;
|
|
91
|
+
subKind?: SyntaxToken;
|
|
89
92
|
name?: NormalExpressionNode;
|
|
90
93
|
asKeyword?: SyntaxToken;
|
|
91
94
|
alias?: NormalExpressionNode;
|
|
92
|
-
constructor({ importKind, name, asKeyword, alias, }: {
|
|
95
|
+
constructor({ importKind, subKind, name, asKeyword, alias, }: {
|
|
93
96
|
importKind?: SyntaxToken;
|
|
97
|
+
subKind?: SyntaxToken;
|
|
94
98
|
name?: NormalExpressionNode;
|
|
95
99
|
asKeyword?: SyntaxToken;
|
|
96
100
|
alias?: NormalExpressionNode;
|
|
@@ -108,6 +112,21 @@ export declare class UseSpecifierListNode extends SyntaxNode {
|
|
|
108
112
|
closeBrace?: SyntaxToken;
|
|
109
113
|
}, id: SyntaxNodeId, filepath: Filepath);
|
|
110
114
|
}
|
|
115
|
+
export declare class MetadataDeclarationNode extends SyntaxNode {
|
|
116
|
+
metadataKeyword?: SyntaxToken;
|
|
117
|
+
targetKind?: SyntaxToken;
|
|
118
|
+
targetName?: NormalExpressionNode;
|
|
119
|
+
bodyColon?: SyntaxToken;
|
|
120
|
+
body?: FunctionApplicationNode | BlockExpressionNode;
|
|
121
|
+
constructor({ metadataKeyword, targetKind, targetName, bodyColon, body, }: {
|
|
122
|
+
metadataKeyword?: SyntaxToken;
|
|
123
|
+
targetKind?: SyntaxToken;
|
|
124
|
+
targetName?: NormalExpressionNode;
|
|
125
|
+
bodyColon?: SyntaxToken;
|
|
126
|
+
body?: BlockExpressionNode | FunctionApplicationNode;
|
|
127
|
+
}, id: SyntaxNodeId, filepath: Filepath);
|
|
128
|
+
getTargetKind(): MetadataTargetKind | undefined;
|
|
129
|
+
}
|
|
111
130
|
export declare class ElementDeclarationNode extends SyntaxNode {
|
|
112
131
|
type?: SyntaxToken;
|
|
113
132
|
name?: NormalExpressionNode;
|
|
@@ -125,8 +144,17 @@ export declare class ElementDeclarationNode extends SyntaxNode {
|
|
|
125
144
|
bodyColon?: SyntaxToken;
|
|
126
145
|
body?: BlockExpressionNode | FunctionApplicationNode;
|
|
127
146
|
}, id: SyntaxNodeId, filepath: Filepath);
|
|
128
|
-
isKind(...kinds:
|
|
129
|
-
|
|
147
|
+
isKind<T extends ElementKind>(...kinds: T[]): this is ElementDeclarationNode & {
|
|
148
|
+
type: {
|
|
149
|
+
value: T;
|
|
150
|
+
};
|
|
151
|
+
};
|
|
152
|
+
getElementKind<T extends ElementKind>(this: ElementDeclarationNode & {
|
|
153
|
+
type: {
|
|
154
|
+
value: T;
|
|
155
|
+
};
|
|
156
|
+
}): T;
|
|
157
|
+
getElementKind(this: ElementDeclarationNode): ElementKind | undefined;
|
|
130
158
|
}
|
|
131
159
|
export declare class IdentifierStreamNode extends SyntaxNode {
|
|
132
160
|
identifiers: SyntaxToken[];
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { NONE_COLOR } from '../../constants';
|
|
2
2
|
import { Filepath } from './filepath';
|
|
3
3
|
import { Position } from './position';
|
|
4
|
+
export type CustomMetadata = Record<string, unknown>;
|
|
4
5
|
export type Color = `#${string}` | typeof NONE_COLOR;
|
|
5
6
|
export declare enum AliasKind {
|
|
6
7
|
Table = "table"
|
|
@@ -85,12 +86,14 @@ export interface Table {
|
|
|
85
86
|
value: string;
|
|
86
87
|
token: TokenPosition;
|
|
87
88
|
};
|
|
89
|
+
metadata?: CustomMetadata;
|
|
88
90
|
}
|
|
89
91
|
export interface Note {
|
|
90
92
|
name: string;
|
|
91
93
|
content: string;
|
|
92
94
|
token: TokenPosition;
|
|
93
95
|
color?: Color;
|
|
96
|
+
metadata?: CustomMetadata;
|
|
94
97
|
}
|
|
95
98
|
export interface ColumnType {
|
|
96
99
|
schemaName: string | null;
|
|
@@ -123,6 +126,7 @@ export interface Column {
|
|
|
123
126
|
value: string;
|
|
124
127
|
token: TokenPosition;
|
|
125
128
|
};
|
|
129
|
+
metadata?: CustomMetadata;
|
|
126
130
|
}
|
|
127
131
|
export interface Index {
|
|
128
132
|
columns: {
|
|
@@ -195,6 +199,7 @@ export interface TableGroup {
|
|
|
195
199
|
value: string;
|
|
196
200
|
token: TokenPosition;
|
|
197
201
|
};
|
|
202
|
+
metadata?: CustomMetadata;
|
|
198
203
|
}
|
|
199
204
|
export interface TableGroupField {
|
|
200
205
|
name: string;
|
|
@@ -238,6 +243,15 @@ export interface TableRecord {
|
|
|
238
243
|
values: RecordValue[][];
|
|
239
244
|
token: TokenPosition;
|
|
240
245
|
}
|
|
246
|
+
export interface MetadataElement {
|
|
247
|
+
target: {
|
|
248
|
+
kind: string;
|
|
249
|
+
name: string[];
|
|
250
|
+
};
|
|
251
|
+
values: CustomMetadata;
|
|
252
|
+
valueTokens: Record<string, TokenPosition>;
|
|
253
|
+
token: TokenPosition;
|
|
254
|
+
}
|
|
241
255
|
export type Project = Record<string, never> | {
|
|
242
256
|
name: string | null;
|
|
243
257
|
tables: Table[];
|
|
@@ -252,4 +266,4 @@ export type Project = Record<string, never> | {
|
|
|
252
266
|
token: TokenPosition;
|
|
253
267
|
[index: string & Omit<any, 'name' | 'tables' | 'refs' | 'enums' | 'tableGroups' | 'note' | 'tablePartials' | 'records'>]: string;
|
|
254
268
|
};
|
|
255
|
-
export type SchemaElement = Database | Project | Table | Note | Column | ColumnType | Index | Check | InlineRef | Ref | RefEndpoint | Enum | EnumField | TableGroup | TableGroupField | Alias | TablePartial | TablePartialInjection | TableRecord | RecordValue;
|
|
269
|
+
export type SchemaElement = Database | Project | Table | Note | Column | ColumnType | Index | Check | InlineRef | Ref | RefEndpoint | Enum | EnumField | TableGroup | TableGroupField | Alias | TablePartial | TablePartialInjection | TableRecord | RecordValue | MetadataElement;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { default as Compiler } from '../../../compiler';
|
|
2
|
-
import { AttributeNode, ElementDeclarationNode, SyntaxNode } from '../nodes';
|
|
2
|
+
import { AttributeNode, ElementDeclarationNode, MetadataDeclarationNode, SyntaxNode } from '../nodes';
|
|
3
3
|
import { ColumnSymbol, NodeSymbol, TablePartialSymbol, TableSymbol } from '../symbol';
|
|
4
4
|
import { Internable } from '../internable';
|
|
5
5
|
export declare enum MetadataKind {
|
|
@@ -8,7 +8,8 @@ export declare enum MetadataKind {
|
|
|
8
8
|
TableChecks = "table checks",
|
|
9
9
|
Indexes = "indexes",
|
|
10
10
|
Records = "records",
|
|
11
|
-
Project = "project"
|
|
11
|
+
Project = "project",
|
|
12
|
+
MetadataElement = "metadata element"
|
|
12
13
|
}
|
|
13
14
|
declare const __nodeMetadataBrand: unique symbol;
|
|
14
15
|
export type NodeMetadataId = number & {
|
|
@@ -26,6 +27,7 @@ export declare abstract class NodeMetadata implements Internable<InternedNodeMet
|
|
|
26
27
|
constructor(declaration: SyntaxNode);
|
|
27
28
|
intern(): InternedNodeMetadata;
|
|
28
29
|
abstract owners(compiler: Compiler): NodeSymbol[];
|
|
30
|
+
reachableOwners(compiler: Compiler, targets: NodeSymbol[]): NodeSymbol[];
|
|
29
31
|
}
|
|
30
32
|
export declare class RefMetadata extends NodeMetadata {
|
|
31
33
|
declaration: ElementDeclarationNode | AttributeNode;
|
|
@@ -73,6 +75,13 @@ export declare class RecordsMetadata extends NodeMetadata {
|
|
|
73
75
|
table(compiler: Compiler): TableSymbol | undefined;
|
|
74
76
|
owners(compiler: Compiler): NodeSymbol[];
|
|
75
77
|
}
|
|
78
|
+
export declare class MetadataElementMetadata extends NodeMetadata {
|
|
79
|
+
declaration: MetadataDeclarationNode;
|
|
80
|
+
readonly kind = MetadataKind.MetadataElement;
|
|
81
|
+
constructor(declaration: MetadataDeclarationNode);
|
|
82
|
+
target(compiler: Compiler): NodeSymbol | undefined;
|
|
83
|
+
owners(compiler: Compiler): NodeSymbol[];
|
|
84
|
+
}
|
|
76
85
|
export declare class ProjectMetadata extends NodeMetadata {
|
|
77
86
|
readonly kind = MetadataKind.Project;
|
|
78
87
|
constructor(declaration: SyntaxNode);
|
|
@@ -24,6 +24,7 @@ export declare enum SymbolKind {
|
|
|
24
24
|
DiagramViewTableGroup = "DiagramView tablegroup",
|
|
25
25
|
DiagramViewNote = "DiagramView note",
|
|
26
26
|
DiagramViewSchema = "DiagramView schema",
|
|
27
|
+
Metadata = "Metadata",
|
|
27
28
|
Program = "Program"
|
|
28
29
|
}
|
|
29
30
|
export declare const ImportKind: {
|
|
@@ -33,8 +34,17 @@ export declare const ImportKind: {
|
|
|
33
34
|
TablePartial: SymbolKind;
|
|
34
35
|
Note: SymbolKind;
|
|
35
36
|
Schema: SymbolKind;
|
|
37
|
+
Metadata: SymbolKind;
|
|
36
38
|
};
|
|
37
39
|
export type ImportKind = (typeof ImportKind)[keyof typeof ImportKind];
|
|
40
|
+
export declare enum MetadataTargetKind {
|
|
41
|
+
Table = "table",
|
|
42
|
+
Schema = "schema",
|
|
43
|
+
Column = "column",
|
|
44
|
+
TableGroup = "tablegroup",
|
|
45
|
+
Note = "note"
|
|
46
|
+
}
|
|
47
|
+
export declare const ALLOWED_METADATA_TARGET_KINDS: readonly MetadataTargetKind[];
|
|
38
48
|
declare const __nodeSymbolBrand: unique symbol;
|
|
39
49
|
export type NodeSymbolId = number & {
|
|
40
50
|
readonly [__nodeSymbolBrand]: true;
|
|
@@ -8,7 +8,7 @@ export declare function extractElementName(nameNode: SyntaxNode): {
|
|
|
8
8
|
schemaName: string[];
|
|
9
9
|
name: string;
|
|
10
10
|
};
|
|
11
|
-
export declare function extractColor(node
|
|
11
|
+
export declare function extractColor(node?: SyntaxNode): Color | undefined;
|
|
12
12
|
export declare function processDefaultValue(valueNode?: SyntaxNode): {
|
|
13
13
|
type: 'number' | 'string' | 'boolean' | 'expression';
|
|
14
14
|
value: string | number;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ElementDeclarationNode, SyntaxNode } from '../types/nodes';
|
|
1
|
+
import { ElementDeclarationNode, MetadataDeclarationNode, SyntaxNode } from '../types/nodes';
|
|
2
2
|
import { SyntaxToken } from '../types/tokens';
|
|
3
3
|
export declare function isOffsetWithinSpan(offset: number, nodeOrToken: SyntaxNode | SyntaxToken): boolean;
|
|
4
|
-
export declare function isOffsetWithinElementHeader(offset: number, element: ElementDeclarationNode): boolean;
|
|
4
|
+
export declare function isOffsetWithinElementHeader(offset: number, element: ElementDeclarationNode | MetadataDeclarationNode): boolean;
|
|
@@ -6,6 +6,9 @@ export declare function isAsKeyword(token?: SyntaxToken): token is SyntaxToken &
|
|
|
6
6
|
export declare function isUseKeyword(token?: SyntaxToken): token is SyntaxToken & {
|
|
7
7
|
kind: SyntaxTokenKind.IDENTIFIER;
|
|
8
8
|
};
|
|
9
|
+
export declare function isMetadataKeyword(token?: SyntaxToken): token is SyntaxToken & {
|
|
10
|
+
kind: SyntaxTokenKind.IDENTIFIER;
|
|
11
|
+
};
|
|
9
12
|
export declare function isFromKeyword(token?: SyntaxToken): token is SyntaxToken & {
|
|
10
13
|
kind: SyntaxTokenKind.IDENTIFIER;
|
|
11
14
|
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { CompileError, CompileErrorCode } from '../types/errors';
|
|
1
2
|
import { AttributeNode, BlockExpressionNode, ElementDeclarationNode, FunctionApplicationNode, FunctionExpressionNode, InfixExpressionNode, ListExpressionNode, LiteralNode, PrefixExpressionNode, PrimaryExpressionNode, ProgramNode, SyntaxNode, TupleExpressionNode, UseDeclarationNode, UseSpecifierNode, VariableNode, WildcardNode } from '../types/nodes';
|
|
2
3
|
import { default as Report } from '../types/report';
|
|
3
4
|
import { SyntaxToken, SyntaxTokenKind } from '../types/tokens';
|
|
@@ -24,7 +25,14 @@ export declare function isValidPartialInjection(node?: SyntaxNode): node is Pref
|
|
|
24
25
|
};
|
|
25
26
|
};
|
|
26
27
|
export declare function isRelationshipOp(op?: string): boolean;
|
|
27
|
-
export declare function
|
|
28
|
+
export declare function isValidHexColor(value?: SyntaxNode): value is PrimaryExpressionNode & {
|
|
29
|
+
expression: LiteralNode & {
|
|
30
|
+
literal: {
|
|
31
|
+
kind: SyntaxTokenKind.COLOR_LITERAL;
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
export declare function isValidColorOrNone(value?: SyntaxNode): boolean;
|
|
28
36
|
export declare function isValidDefaultValue(value?: SyntaxNode): boolean;
|
|
29
37
|
export type SignedNumberExpression = (PrimaryExpressionNode & {
|
|
30
38
|
expression: LiteralNode & {
|
|
@@ -45,6 +53,11 @@ export declare function isTupleOfVariables(value?: SyntaxNode): value is TupleEx
|
|
|
45
53
|
};
|
|
46
54
|
export declare function isValidColumnType(type: SyntaxNode): boolean;
|
|
47
55
|
export type Settings = Record<SettingName | string, AttributeNode[]>;
|
|
56
|
+
export declare function isValidMetadataValue(value?: SyntaxNode): boolean;
|
|
57
|
+
export declare function validateInlineMetadataSetting(name: string, attrs: AttributeNode[], codes: {
|
|
58
|
+
duplicate: CompileErrorCode;
|
|
59
|
+
invalidValue: CompileErrorCode;
|
|
60
|
+
}): CompileError[];
|
|
48
61
|
export declare function aggregateSettingList(settingList?: ListExpressionNode): Report<Settings>;
|
|
49
62
|
export declare function isExpressionAQuotedString(value?: unknown): value is PrimaryExpressionNode & ({
|
|
50
63
|
expression: VariableNode & {
|
|
@@ -84,7 +97,11 @@ type DotDelimitedIdentifier = PrimaryExpressionNode | (AccessExpression & {
|
|
|
84
97
|
});
|
|
85
98
|
export declare function isAccessExpression(node?: SyntaxNode): node is AccessExpression;
|
|
86
99
|
export declare function isDotDelimitedIdentifier(node?: SyntaxNode): node is DotDelimitedIdentifier;
|
|
87
|
-
export declare function isElementNode(node: SyntaxNode | undefined, kind:
|
|
100
|
+
export declare function isElementNode<T extends ElementKind>(node: SyntaxNode | undefined, kind: T): node is ElementDeclarationNode & {
|
|
101
|
+
type: {
|
|
102
|
+
value: T;
|
|
103
|
+
};
|
|
104
|
+
};
|
|
88
105
|
export declare function isUseDeclaration(node: SyntaxNode): node is UseDeclarationNode;
|
|
89
106
|
export declare function isUseSpecifier(node: SyntaxNode, kind?: ImportKind): node is UseSpecifierNode;
|
|
90
107
|
export declare function isWildcardSpecifier(node: SyntaxNode): node is WildcardNode;
|
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": "8.3.
|
|
4
|
+
"version": "8.3.1-custom-metadata.1",
|
|
5
5
|
"description": "DBML parser v2",
|
|
6
6
|
"author": "Holistics <dev@holistics.io>",
|
|
7
7
|
"license": "Apache-2.0",
|
|
@@ -50,5 +50,5 @@
|
|
|
50
50
|
"engines": {
|
|
51
51
|
"node": ">=18"
|
|
52
52
|
},
|
|
53
|
-
"gitHead": "
|
|
53
|
+
"gitHead": "152988f537ab87a9d8320bd41b478495c1acbb0c"
|
|
54
54
|
}
|