@dbml/parse 10.4.0-alpha.3 → 10.4.0-metadata-type.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 +26 -26
- package/dist/dbml-parse.mjs +3558 -3698
- package/dist/src/compiler/index.d.ts +0 -19
- package/dist/src/core/global_modules/metadata/interpret.d.ts +2 -2
- package/dist/src/core/global_modules/metadata/registries.d.ts +19 -0
- package/dist/src/core/global_modules/metadata/utils.d.ts +24 -19
- package/dist/src/core/global_modules/note/interpret.d.ts +1 -3
- package/dist/src/core/global_modules/records/utils/data/values.d.ts +1 -2
- 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/global_modules/table/interpret.d.ts +1 -4
- package/dist/src/core/global_modules/tableGroup/interpret.d.ts +1 -3
- package/dist/src/core/local_modules/dep/validate.d.ts +1 -4
- package/dist/src/core/local_modules/note/validate.d.ts +0 -2
- package/dist/src/core/local_modules/table/validate.d.ts +1 -7
- package/dist/src/core/local_modules/tableGroup/validate.d.ts +1 -5
- package/dist/src/core/types/errors.d.ts +4 -0
- package/dist/src/core/types/schemaJson/types.d.ts +7 -11
- package/dist/src/core/types/symbol/symbols.d.ts +1 -11
- package/dist/src/core/utils/expression.d.ts +1 -0
- package/dist/src/core/utils/interpret.d.ts +14 -3
- package/dist/src/index.d.ts +1 -1
- package/dist/src/services/suggestions/provider.d.ts +1 -1
- package/package.json +2 -2
- 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[];
|
|
@@ -2,13 +2,13 @@ import { default as Compiler } from '../../../compiler';
|
|
|
2
2
|
import { Filepath } from '../../types';
|
|
3
3
|
import { MetadataElementMetadata } from '../../types/symbol/metadata';
|
|
4
4
|
import { default as Report } from '../../types/report';
|
|
5
|
-
import {
|
|
5
|
+
import { CustomMetadata } from '../../types/schemaJson';
|
|
6
6
|
export default class MetadataInterpreter {
|
|
7
7
|
private declarationNode;
|
|
8
8
|
private compiler;
|
|
9
9
|
private filepath;
|
|
10
10
|
private values;
|
|
11
11
|
constructor(compiler: Compiler, metadata: MetadataElementMetadata, filepath: Filepath);
|
|
12
|
-
interpret(): Report<
|
|
12
|
+
interpret(): Report<CustomMetadata>;
|
|
13
13
|
private interpretValues;
|
|
14
14
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { SettingName } from '../../types/keywords';
|
|
2
|
+
import { Color, Column, Note, Table, TableGroup } from '../../types/schemaJson';
|
|
3
|
+
import { MetadataTargetKind } from '../../types/symbol';
|
|
4
|
+
import { MetadataFieldRegistry } from './utils';
|
|
5
|
+
export declare const TABLE_METADATA_FIELDS: MetadataFieldRegistry<Table, {
|
|
6
|
+
[SettingName.Note]: string;
|
|
7
|
+
[SettingName.HeaderColor]: Color;
|
|
8
|
+
}>;
|
|
9
|
+
export declare const COLUMN_METADATA_FIELDS: MetadataFieldRegistry<Column, {
|
|
10
|
+
[SettingName.Note]: string;
|
|
11
|
+
}>;
|
|
12
|
+
export declare const TABLEGROUP_METADATA_FIELDS: MetadataFieldRegistry<TableGroup, {
|
|
13
|
+
[SettingName.Note]: string;
|
|
14
|
+
[SettingName.Color]: Color;
|
|
15
|
+
}>;
|
|
16
|
+
export declare const NOTE_METADATA_FIELDS: MetadataFieldRegistry<Note, {
|
|
17
|
+
[SettingName.Color]: Color;
|
|
18
|
+
}>;
|
|
19
|
+
export declare const METADATA_FIELDS_BY_KIND: Record<MetadataTargetKind, MetadataFieldRegistry<any, any>>;
|
|
@@ -1,31 +1,36 @@
|
|
|
1
1
|
import { default as Compiler } from '../../../compiler/index';
|
|
2
2
|
import { Filepath, SettingName } from '../../types';
|
|
3
|
-
import { Column, CustomMetadataValue,
|
|
4
|
-
import { SyntaxNode } from '../../types/nodes';
|
|
3
|
+
import { Column, CustomMetadataValue, CustomMetadataValueType, 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
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* - `
|
|
8
|
+
* Spec for one builtin metadata field (table's note, tablegroup's color, .etc) of an element kind.
|
|
9
|
+
* Used for both the inline settings list and Metadata blocks:
|
|
10
|
+
* - `parse`: Read the field's own value from a source node, `undefined` means the value is invalid
|
|
11
|
+
* - `assign`: Write the parsed value to the element builtin props (e.g. write `table.note` instead of `table.metadata`)
|
|
11
12
|
*/
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
|
|
13
|
+
type MetadataField<T, V> = {
|
|
14
|
+
/** Type of the parsed value, reported when the field is read as a metadata entry */
|
|
15
|
+
type: CustomMetadataValueType;
|
|
16
|
+
/** Parse the source node into the field's value, `undefined` if the node is not a valid value for this field */
|
|
17
|
+
parse(node?: SyntaxNode): V | undefined;
|
|
15
18
|
message: string;
|
|
16
|
-
/** Write the
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
export type MetadataFieldRegistry<T extends MetadataTarget,
|
|
20
|
-
|
|
19
|
+
/** Write the parsed value to the element builtin props (e.g. write to `table.note`) */
|
|
20
|
+
assign(element: Partial<T>, value: V, token: TokenPosition): void;
|
|
21
|
+
};
|
|
22
|
+
export type MetadataFieldRegistry<T extends MetadataTarget, R extends {
|
|
23
|
+
[K in SettingName]?: CustomMetadataValue['value'];
|
|
24
|
+
}> = {
|
|
25
|
+
[K in keyof R]: MetadataField<T, R[K]>;
|
|
26
|
+
};
|
|
27
|
+
type NameWithSymbolKind = {
|
|
21
28
|
name: string;
|
|
22
29
|
symbolKind: SymbolKind;
|
|
23
30
|
};
|
|
24
31
|
/** @internal Exported for testing only. */
|
|
25
|
-
export declare function mapNamePartToSymbolKind(nameParts: string[], targetKind:
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
* NOTE: Only run during interpret phase
|
|
29
|
-
*/
|
|
32
|
+
export declare function mapNamePartToSymbolKind(nameParts: string[], targetKind: MetadataTargetKind): NameWithSymbolKind[];
|
|
33
|
+
export declare function resolveMetadataTarget(compiler: Compiler, metadataNode: ElementDeclarationNode): NodeSymbol | undefined;
|
|
34
|
+
/** Merge every custom-metadata block, reachable from the current program, targeting element to it's `metadata` and other builtin (note/headercolor/...) fields */
|
|
30
35
|
export declare function attachCustomMetadata<T extends MetadataTarget>(compiler: Compiler, targetElement: Partial<T>, targetSymbol: NodeSymbol, fieldsRegistry: MetadataFieldRegistry<T, any>, filepath: Filepath): void;
|
|
31
36
|
export {};
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { Note } from '../../types/schemaJson';
|
|
2
2
|
import { default as Compiler } from '../../../compiler';
|
|
3
|
-
import {
|
|
3
|
+
import { Filepath, NoteSymbol } from '../../types';
|
|
4
4
|
import { default as Report } from '../../types/report';
|
|
5
|
-
import { MetadataFieldRegistry } from '../metadata/utils';
|
|
6
|
-
export declare const NOTE_METADATA_FIELDS: MetadataFieldRegistry<Note, SettingName.Color>;
|
|
7
5
|
export declare class StickyNoteInterpreter {
|
|
8
6
|
private declarationNode;
|
|
9
7
|
private symbol;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { FunctionExpressionNode, SyntaxNode } from '../../../../types/nodes';
|
|
2
|
-
export { extractNumericLiteral } from '../../../../utils/expression';
|
|
2
|
+
export { extractNumericLiteral, extractSignedNumber } from '../../../../utils/expression';
|
|
3
3
|
export declare function isNullish(value: SyntaxNode): boolean;
|
|
4
4
|
export declare function isEmptyStringLiteral(value: SyntaxNode): boolean;
|
|
5
5
|
export declare function isFunctionExpression(value: SyntaxNode): value is FunctionExpressionNode;
|
|
6
|
-
export declare function extractSignedNumber(node: SyntaxNode): number | null;
|
|
7
6
|
export declare function tryExtractNumeric(value: SyntaxNode | number | string | boolean | undefined | null): number | null;
|
|
8
7
|
export declare function tryExtractInteger(value: SyntaxNode | number | string | boolean | undefined | null): number | null;
|
|
9
8
|
export declare const TRUTHY_VALUES: string[];
|
|
@@ -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;
|
|
@@ -2,10 +2,9 @@ import { default as Compiler } from '../../../compiler';
|
|
|
2
2
|
import { SettingName } from '../../types/keywords';
|
|
3
3
|
import { ElementDeclarationNode } from '../../types/nodes';
|
|
4
4
|
import { default as Report } from '../../types/report';
|
|
5
|
-
import {
|
|
5
|
+
import { Table } from '../../types/schemaJson';
|
|
6
6
|
import { Filepath } from '../../types/filepath';
|
|
7
7
|
import { TableSymbol } from '../../types/symbol/symbols';
|
|
8
|
-
import { MetadataFieldRegistry } from '../metadata/utils';
|
|
9
8
|
export declare class TableInterpreter {
|
|
10
9
|
private declarationNode;
|
|
11
10
|
private compiler;
|
|
@@ -33,5 +32,3 @@ export declare class TableInterpreter {
|
|
|
33
32
|
* TODO: Catch these settings when we support more data types for custom metadata
|
|
34
33
|
*/
|
|
35
34
|
export declare const RECOGNIZED_COLUMN_SETTINGS: readonly SettingName[];
|
|
36
|
-
export declare const TABLE_METADATA_FIELDS: MetadataFieldRegistry<Table, SettingName.Note | SettingName.HeaderColor>;
|
|
37
|
-
export declare const COLUMN_METADATA_FIELDS: MetadataFieldRegistry<Column, SettingName.Note>;
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { TableGroup } from '../../types/schemaJson';
|
|
2
2
|
import { default as Compiler } from '../../../compiler';
|
|
3
|
-
import {
|
|
3
|
+
import { Filepath, TableGroupSymbol } from '../../types';
|
|
4
4
|
import { default as Report } from '../../types/report';
|
|
5
|
-
import { MetadataFieldRegistry } from '../metadata/utils';
|
|
6
|
-
export declare const TABLEGROUP_METADATA_FIELDS: MetadataFieldRegistry<TableGroup, SettingName.Note | SettingName.Color>;
|
|
7
5
|
export declare class TableGroupInterpreter {
|
|
8
6
|
private compiler;
|
|
9
7
|
private symbol;
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { default as Compiler } from '../../../compiler';
|
|
2
2
|
import { CompileError } from '../../types/errors';
|
|
3
|
-
import { BlockExpressionNode, ElementDeclarationNode, FunctionApplicationNode
|
|
4
|
-
import { default as Report } from '../../types/report';
|
|
5
|
-
import { Settings } from '../../utils/validate';
|
|
3
|
+
import { BlockExpressionNode, ElementDeclarationNode, FunctionApplicationNode } from '../../types/nodes';
|
|
6
4
|
export default class DepValidator {
|
|
7
5
|
private declarationNode;
|
|
8
6
|
private compiler;
|
|
@@ -16,4 +14,3 @@ export default class DepValidator {
|
|
|
16
14
|
validateFields(fields: FunctionApplicationNode[]): CompileError[];
|
|
17
15
|
private validateSubElements;
|
|
18
16
|
}
|
|
19
|
-
export declare function validateDepSettings(settings: ListExpressionNode): Report<Settings>;
|
|
@@ -9,8 +9,6 @@ export default class NoteValidator {
|
|
|
9
9
|
private validateContext;
|
|
10
10
|
private validateName;
|
|
11
11
|
private validateAlias;
|
|
12
|
-
private isStickyNote;
|
|
13
|
-
private validateSettingList;
|
|
14
12
|
validateBody(body?: FunctionApplicationNode | BlockExpressionNode): CompileError[];
|
|
15
13
|
validateFields(fields: FunctionApplicationNode[]): CompileError[];
|
|
16
14
|
private validateSubElements;
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { default as Compiler } from '../../../compiler';
|
|
2
2
|
import { CompileError } from '../../types/errors';
|
|
3
|
-
import { ElementDeclarationNode
|
|
4
|
-
import { default as Report } from '../../types/report';
|
|
5
|
-
import { Settings } from '../../utils/validate';
|
|
3
|
+
import { ElementDeclarationNode } from '../../types/nodes';
|
|
6
4
|
export default class TableValidator {
|
|
7
5
|
private declarationNode;
|
|
8
6
|
private compiler;
|
|
@@ -11,11 +9,7 @@ export default class TableValidator {
|
|
|
11
9
|
private validateContext;
|
|
12
10
|
private validateName;
|
|
13
11
|
private validateAlias;
|
|
14
|
-
private validateSettingList;
|
|
15
12
|
private validateBody;
|
|
16
13
|
private validateFields;
|
|
17
|
-
private validateFieldSetting;
|
|
18
14
|
private validateSubElements;
|
|
19
15
|
}
|
|
20
|
-
export declare function validateTableSettings(settingList?: ListExpressionNode): Report<Settings>;
|
|
21
|
-
export declare function validateFieldSetting(parts: ExpressionNode[]): Report<Settings>;
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { default as Compiler } from '../../../compiler';
|
|
2
2
|
import { CompileError } from '../../types/errors';
|
|
3
|
-
import { BlockExpressionNode, ElementDeclarationNode, FunctionApplicationNode
|
|
4
|
-
import { default as Report } from '../../types/report';
|
|
5
|
-
import { Settings } from '../../utils/validate';
|
|
3
|
+
import { BlockExpressionNode, ElementDeclarationNode, FunctionApplicationNode } from '../../types/nodes';
|
|
6
4
|
export default class TableGroupValidator {
|
|
7
5
|
private declarationNode;
|
|
8
6
|
private compiler;
|
|
@@ -11,9 +9,7 @@ export default class TableGroupValidator {
|
|
|
11
9
|
private validateContext;
|
|
12
10
|
private validateName;
|
|
13
11
|
private validateAlias;
|
|
14
|
-
private validateSettingList;
|
|
15
12
|
validateBody(body?: FunctionApplicationNode | BlockExpressionNode): CompileError[];
|
|
16
13
|
validateFields(fields: FunctionApplicationNode[]): CompileError[];
|
|
17
14
|
private validateSubElements;
|
|
18
15
|
}
|
|
19
|
-
export declare function validateSettingList(settingList?: ListExpressionNode): Report<Settings>;
|
|
@@ -112,6 +112,10 @@ export declare enum CompileErrorCode {
|
|
|
112
112
|
DUPLICATE_DIAGRAMVIEW_NAME = 3094,
|
|
113
113
|
INVALID_DIAGRAMVIEW_FIELD = 3095,
|
|
114
114
|
DUPLICATE_DIAGRAMVIEW_FIELD = 3096,
|
|
115
|
+
DUPLICATE_TABLEGROUP_SETTING = 3097,
|
|
116
|
+
INVALID_TABLEGROUP_SETTING_VALUE = 3098,
|
|
117
|
+
DUPLICATE_DEP_SETTING = 3099,
|
|
118
|
+
INVALID_DEP_SETTING_VALUE = 3100,
|
|
115
119
|
BINDING_ERROR = 4000,
|
|
116
120
|
NONEXISTENT_MODULE = 4001,
|
|
117
121
|
UNSUPPORTED = 5000,
|
|
@@ -2,7 +2,12 @@ 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 CustomMetadataValueType = 'string' | 'number' | 'bool' | 'color';
|
|
6
|
+
export interface CustomMetadataValue {
|
|
7
|
+
value: string | number | boolean;
|
|
8
|
+
type: CustomMetadataValueType;
|
|
9
|
+
token: TokenPosition;
|
|
10
|
+
}
|
|
6
11
|
export type CustomMetadata = Record<string, CustomMetadataValue>;
|
|
7
12
|
export type Color = `#${string}` | typeof NONE_COLOR;
|
|
8
13
|
export declare enum AliasKind {
|
|
@@ -165,14 +170,9 @@ export interface Ref {
|
|
|
165
170
|
name: string | null;
|
|
166
171
|
endpoints: RefEndpointPair;
|
|
167
172
|
color?: Color;
|
|
168
|
-
note?: {
|
|
169
|
-
value: string;
|
|
170
|
-
token: TokenPosition;
|
|
171
|
-
};
|
|
172
173
|
onDelete?: string;
|
|
173
174
|
onUpdate?: string;
|
|
174
175
|
inactive?: boolean;
|
|
175
|
-
metadata?: CustomMetadata;
|
|
176
176
|
token: TokenPosition;
|
|
177
177
|
}
|
|
178
178
|
export type RefEndpointPair = [RefEndpoint, RefEndpoint];
|
|
@@ -285,10 +285,6 @@ export interface TableRecord {
|
|
|
285
285
|
example?: boolean;
|
|
286
286
|
token: TokenPosition;
|
|
287
287
|
}
|
|
288
|
-
export type MetadataValues = Record<string, {
|
|
289
|
-
value: CustomMetadataValue;
|
|
290
|
-
token: TokenPosition;
|
|
291
|
-
}>;
|
|
292
288
|
export type Project = Record<string, never> | {
|
|
293
289
|
name: string | null;
|
|
294
290
|
tables: Table[];
|
|
@@ -303,4 +299,4 @@ export type Project = Record<string, never> | {
|
|
|
303
299
|
token: TokenPosition;
|
|
304
300
|
[index: string & Omit<any, 'name' | 'tables' | 'refs' | 'enums' | 'tableGroups' | 'note' | 'tablePartials' | 'records'>]: string;
|
|
305
301
|
};
|
|
306
|
-
export type SchemaElement = Database | Project | Table | Note | Column | ColumnType | Index | Check | InlineRef | InlineDep | Ref | RefEndpoint | Dep | DepEdge | DepEndpoint | Enum | EnumField | TableGroup | TableGroupField | Alias | TablePartial | TablePartialInjection | TableRecord | RecordValue |
|
|
302
|
+
export type SchemaElement = Database | Project | Table | Note | Column | ColumnType | Index | Check | InlineRef | InlineDep | Ref | RefEndpoint | Dep | DepEdge | DepEndpoint | Enum | EnumField | TableGroup | TableGroupField | Alias | TablePartial | TablePartialInjection | TableRecord | RecordValue | CustomMetadata;
|
|
@@ -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;
|
|
@@ -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 extractSignedNumber(node: SyntaxNode): number | null;
|
|
26
27
|
export declare function extractBooleanLiteral(node?: SyntaxNode): boolean | null;
|
|
27
28
|
export declare function destructureCallExpression(node?: SyntaxNode): {
|
|
28
29
|
variables: (PrimaryExpressionNode & {
|
|
@@ -4,12 +4,15 @@ import { SyntaxNode } from '../types/nodes';
|
|
|
4
4
|
import { default as Report } from '../types/report';
|
|
5
5
|
import { Settings } from './validate';
|
|
6
6
|
import { SettingName } from '../types';
|
|
7
|
+
import { MetadataFieldRegistry, MetadataTarget } from '../global_modules/metadata/utils';
|
|
7
8
|
export declare function getTokenPosition(node: SyntaxNode): TokenPosition;
|
|
8
9
|
export declare function normalizeNote(content: string): string;
|
|
9
10
|
export declare function extractElementName(nameNode: SyntaxNode): {
|
|
10
11
|
schemaName: string[];
|
|
11
12
|
name: string;
|
|
12
13
|
};
|
|
14
|
+
export declare function extractNote(node?: SyntaxNode): string | undefined;
|
|
15
|
+
export declare function extractHexColor(node?: SyntaxNode): Color | undefined;
|
|
13
16
|
export declare function extractColor(node?: SyntaxNode): Color | undefined;
|
|
14
17
|
export declare function processDefaultValue(valueNode?: SyntaxNode): {
|
|
15
18
|
type: 'number' | 'string' | 'boolean' | 'expression';
|
|
@@ -17,10 +20,18 @@ export declare function processDefaultValue(valueNode?: SyntaxNode): {
|
|
|
17
20
|
} | undefined;
|
|
18
21
|
export declare function processColumnType(compiler: Compiler, typeNode: SyntaxNode): Report<ColumnType>;
|
|
19
22
|
/**
|
|
20
|
-
* Extract inline custom metadata from an aggregated setting list,
|
|
21
|
-
*
|
|
23
|
+
* Extract inline custom metadata from an aggregated setting list, excluding the given recognized settings.
|
|
24
|
+
* Used for columns, whose recognized settings (pk, ref, note, .etc) are interpreted by the column symbol rather than field specs.
|
|
22
25
|
*
|
|
23
26
|
* NOTE: This is used during interpret phase, so no need to validate values, just extract them
|
|
24
27
|
*/
|
|
25
28
|
export declare function extractCustomInlineMetadata(settingMap: Settings, builtinSettings: readonly SettingName[]): CustomMetadata;
|
|
26
|
-
|
|
29
|
+
/**
|
|
30
|
+
* Interpret an element's aggregated setting list as metadata:
|
|
31
|
+
* - Builtin fields (headercolor and note in `table`, color in `tablegroup`, .etc) are parsed and assigned onto the element by their field spec
|
|
32
|
+
* - Every other key becomes free-form custom metadata on `element.metadata`
|
|
33
|
+
*
|
|
34
|
+
* Invalid values are skipped (reported at validate phase).
|
|
35
|
+
*/
|
|
36
|
+
export declare function assignInlineMetadata<T extends MetadataTarget>(element: Partial<T>, settingMap: Settings, registry: MetadataFieldRegistry<T, any>): void;
|
|
37
|
+
export declare function extractMetadataValue(node?: SyntaxNode): Omit<CustomMetadataValue, 'token'> | undefined;
|
package/dist/src/index.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ export { CompileError, CompileErrorCode, CompileWarning, CompileInfo, } from './
|
|
|
12
12
|
export type { Diagnostic, DiagnosticQuickFix } from './services/diagnostics/provider';
|
|
13
13
|
export type { Position, } from './core/types';
|
|
14
14
|
export { ScopeKind, splitQualifiedIdentifier, unescapeString, escapeString, formatRecordValue, isValidIdentifier, addDoubleQuoteIfNeeded, normalizeQualifiedName, } from './compiler/index';
|
|
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
|
+
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, type CustomMetadataValueType, } from './core/types/schemaJson';
|
|
16
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';
|
|
17
17
|
export type { DiagramViewSyncOperation, DiagramViewBlock, TextEdit, } from './compiler/queries/transform';
|
|
18
18
|
export { findDiagramViewBlocks } from './compiler/queries/transform';
|
|
@@ -29,4 +29,4 @@ export default class DBMLCompletionItemProvider implements CompletionItemProvide
|
|
|
29
29
|
constructor(compiler: Compiler, options?: DBMLCompletionItemProviderOptions);
|
|
30
30
|
provideCompletionItems(model: TextModel, position: Position): CompletionList;
|
|
31
31
|
}
|
|
32
|
-
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")[];
|
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-
|
|
4
|
+
"version": "10.4.0-metadata-type.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": "0346035c1c3c2bb1f8b1e524e43a43ad4cc9bb8e"
|
|
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[];
|