@dbml/parse 9.0.0-optional-ref.12 → 9.1.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.
@@ -11,5 +11,6 @@ export declare const enum ScopeKind {
11
11
  TABLEPARTIAL = 9,
12
12
  CHECKS = 10,
13
13
  RECORDS = 11,
14
- DIAGRAMVIEW = 12
14
+ DIAGRAMVIEW = 12,
15
+ METADATA = 13
15
16
  }
@@ -0,0 +1,11 @@
1
+ import { default as Compiler } from '../../../compiler';
2
+ import { CompileError } from '../../types';
3
+ import { ElementDeclarationNode } from '../../types/nodes';
4
+ export default class MetadataBinder {
5
+ private compiler;
6
+ private declarationNode;
7
+ constructor(compiler: Compiler, declarationNode: ElementDeclarationNode);
8
+ bind(): CompileError[];
9
+ private bindTargetElement;
10
+ private bindBody;
11
+ }
@@ -0,0 +1,2 @@
1
+ import { GlobalModule } from '../types';
2
+ export declare const metadataModule: GlobalModule;
@@ -0,0 +1,14 @@
1
+ import { default as Compiler } from '../../../compiler';
2
+ import { Filepath } from '../../types';
3
+ import { MetadataElementMetadata } from '../../types/symbol/metadata';
4
+ import { default as Report } from '../../types/report';
5
+ import { MetadataValues } from '../../types/schemaJson';
6
+ export default class MetadataInterpreter {
7
+ private declarationNode;
8
+ private compiler;
9
+ private filepath;
10
+ private values;
11
+ constructor(compiler: Compiler, metadata: MetadataElementMetadata, filepath: Filepath);
12
+ interpret(): Report<MetadataValues>;
13
+ private interpretValues;
14
+ }
@@ -0,0 +1,29 @@
1
+ import { default as Compiler } from '../../../compiler/index';
2
+ import { Filepath, SettingName } from '../../types';
3
+ import { Column, Note, Table, TableGroup, TokenPosition } from '../../types/schemaJson';
4
+ import { ElementDeclarationNode, SyntaxNode } from '../../types/nodes';
5
+ import { NodeSymbol, SymbolKind, MetadataTargetKind } from '../../types/symbol';
6
+ export type MetadataTarget = Table | TableGroup | Note | Column;
7
+ /**
8
+ * Specs for builtin metadata (table's note, tablegroup's color, .etc) for different element types. Does 2 things:
9
+ * - `validate`: Validating if the metadata value is syntactically correct
10
+ * - `assign`: Write the metadata value to the element builtin props (e.g. write `table.note` instead of `table.metadata`)
11
+ */
12
+ interface MetadataField<T extends MetadataTarget> {
13
+ /** Check if the metadata value is syntactically correct */
14
+ isValidBuiltinFieldValue(node?: SyntaxNode): boolean;
15
+ message: string;
16
+ /** Write the metadata value to the element builtin props (e.g. write to `table.note`) */
17
+ assignBuiltinField(element: Partial<T>, value: string, token: TokenPosition): void;
18
+ }
19
+ export type MetadataFieldRegistry<T extends MetadataTarget, K extends SettingName = SettingName> = Record<K, MetadataField<T>>;
20
+ type NameWithSymbolKind = {
21
+ name: string;
22
+ symbolKind: SymbolKind;
23
+ };
24
+ /** @internal Exported for testing only. */
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 */
28
+ export declare function attachCustomMetadata<T extends MetadataTarget>(compiler: Compiler, targetElement: Partial<T>, targetSymbol: NodeSymbol, fieldsRegistry: MetadataFieldRegistry<T, any>, filepath: Filepath): void;
29
+ export {};
@@ -1,7 +1,9 @@
1
1
  import { Note } from '../../types/schemaJson';
2
2
  import { default as Compiler } from '../../../compiler';
3
- import { Filepath, NoteSymbol } from '../../types';
3
+ import { SettingName, 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>;
5
7
  export declare class StickyNoteInterpreter {
6
8
  private declarationNode;
7
9
  private symbol;
@@ -1,9 +1,11 @@
1
1
  import { default as Compiler } from '../../../compiler';
2
+ import { SettingName } from '../../types/keywords';
2
3
  import { ElementDeclarationNode } from '../../types/nodes';
3
4
  import { default as Report } from '../../types/report';
4
- import { Table } from '../../types/schemaJson';
5
+ import { Column, Table } from '../../types/schemaJson';
5
6
  import { Filepath } from '../../types/filepath';
6
7
  import { TableSymbol } from '../../types/symbol/symbols';
8
+ import { MetadataFieldRegistry } from '../metadata/utils';
7
9
  export declare class TableInterpreter {
8
10
  private declarationNode;
9
11
  private compiler;
@@ -13,6 +15,7 @@ export declare class TableInterpreter {
13
15
  private pkColumns;
14
16
  constructor(compiler: Compiler, declarationNode: ElementDeclarationNode, symbol: TableSymbol, filepath: Filepath);
15
17
  interpret(): Report<Table>;
18
+ private attachTableAndColumnMetadata;
16
19
  private interpretName;
17
20
  private interpretAlias;
18
21
  private interpretSettingList;
@@ -24,3 +27,11 @@ export declare class TableInterpreter {
24
27
  private interpretIndexes;
25
28
  private interpretChecks;
26
29
  }
30
+ /**
31
+ * Settings that are excluded from custom metadata for inline metadata for Column
32
+ * Different from what we extract from metadata block for Column because some settings value types are not supported yet, mostly boolean keys without values ([pk, not null])
33
+ * TODO: Catch these settings when we support more data types for custom metadata
34
+ */
35
+ 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,7 +1,9 @@
1
1
  import { TableGroup } from '../../types/schemaJson';
2
2
  import { default as Compiler } from '../../../compiler';
3
- import { Filepath, TableGroupSymbol } from '../../types';
3
+ import { SettingName, 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>;
5
7
  export declare class TableGroupInterpreter {
6
8
  private compiler;
7
9
  private symbol;
@@ -1,4 +1,5 @@
1
1
  import { default as Compiler } from '../../compiler';
2
+ import { Filepath, ProgramSymbol } from '../types';
2
3
  import { PrimaryExpressionNode, SyntaxNode, VariableNode } from '../types/nodes';
3
4
  import { default as Report } from '../types/report';
4
5
  import { NodeSymbol } from '../types/symbol';
@@ -13,3 +14,5 @@ export declare function scanNonListNodeForBinding(node?: SyntaxNode): {
13
14
  })[];
14
15
  }[];
15
16
  export declare function nodeRefereeOfLeftExpression(compiler: Compiler, node: SyntaxNode): NodeSymbol | undefined;
17
+ export declare function getDefaultSchemaSymbol(compiler: Compiler, globalSymbol: NodeSymbol): NodeSymbol | undefined;
18
+ export declare function getProgramSymbol(compiler: Compiler, filepath: Filepath): ProgramSymbol | undefined;
@@ -0,0 +1,2 @@
1
+ import { LocalModule } from '../types';
2
+ export declare const metadataModule: LocalModule;
@@ -0,0 +1,7 @@
1
+ import { CompileError, CompileErrorCode, MetadataTargetKind } from '../../types';
2
+ import { AttributeNode, ElementDeclarationNode } from '../../types/nodes';
3
+ export declare function getMetadataTargetKind(node: ElementDeclarationNode): MetadataTargetKind | undefined;
4
+ export declare function validateCustomInlineMetadata(name: string, attrs: AttributeNode[], errorCodes: {
5
+ duplicate: CompileErrorCode;
6
+ invalidValue: CompileErrorCode;
7
+ }): CompileError[];
@@ -0,0 +1,14 @@
1
+ import { default as Compiler } from '../../../compiler';
2
+ import { CompileError } from '../../types/errors';
3
+ import { ElementDeclarationNode } from '../../types/nodes';
4
+ export default class MetadataValidator {
5
+ private compiler;
6
+ private declarationNode;
7
+ constructor(compiler: Compiler, declarationNode: ElementDeclarationNode);
8
+ validate(): CompileError[];
9
+ private validateTargetKind;
10
+ private validateTargetName;
11
+ private validateBody;
12
+ private validateFields;
13
+ private validateSubElements;
14
+ }
@@ -114,7 +114,10 @@ export declare enum CompileErrorCode {
114
114
  SAME_ENDPOINT = 5002,
115
115
  UNEQUAL_FIELDS_BINARY_REF = 5003,
116
116
  CONFLICTING_SETTING = 5004,
117
- TABLE_REAPPEAR_IN_TABLEGROUP = 5005
117
+ TABLE_REAPPEAR_IN_TABLEGROUP = 5005,
118
+ INVALID_METADATA_TARGET_KIND = 5006,
119
+ INVALID_METADATA_FIELD = 5007,
120
+ DUPLICATE_METADATA_FIELD = 5008
118
121
  }
119
122
  export interface RelatedLocation {
120
123
  nodeOrToken: SyntaxNode | SyntaxToken;
@@ -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",
@@ -110,14 +110,16 @@ export declare class UseSpecifierListNode extends SyntaxNode {
110
110
  }
111
111
  export declare class ElementDeclarationNode extends SyntaxNode {
112
112
  type?: SyntaxToken;
113
+ targetKind?: SyntaxToken;
113
114
  name?: NormalExpressionNode;
114
115
  as?: SyntaxToken;
115
116
  alias?: NormalExpressionNode;
116
117
  attributeList?: ListExpressionNode;
117
118
  bodyColon?: SyntaxToken;
118
119
  body?: FunctionApplicationNode | BlockExpressionNode;
119
- constructor({ type, name, as, alias, attributeList, bodyColon, body, }: {
120
+ constructor({ type, targetKind, name, as, alias, attributeList, bodyColon, body, }: {
120
121
  type?: SyntaxToken;
122
+ targetKind?: SyntaxToken;
121
123
  name?: NormalExpressionNode;
122
124
  as?: SyntaxToken;
123
125
  alias?: NormalExpressionNode;
@@ -125,8 +127,17 @@ export declare class ElementDeclarationNode extends SyntaxNode {
125
127
  bodyColon?: SyntaxToken;
126
128
  body?: BlockExpressionNode | FunctionApplicationNode;
127
129
  }, id: SyntaxNodeId, filepath: Filepath);
128
- isKind(...kinds: ElementKind[]): boolean;
129
- getElementKind(): ElementKind | undefined;
130
+ isKind<T extends ElementKind>(...kinds: T[]): this is ElementDeclarationNode & {
131
+ type: {
132
+ value: T;
133
+ };
134
+ };
135
+ getElementKind<T extends ElementKind>(this: ElementDeclarationNode & {
136
+ type: {
137
+ value: T;
138
+ };
139
+ }): T;
140
+ getElementKind(this: ElementDeclarationNode): ElementKind | undefined;
130
141
  }
131
142
  export declare class IdentifierStreamNode extends SyntaxNode {
132
143
  identifiers: SyntaxToken[];
@@ -2,6 +2,7 @@ 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 CustomMetadata = Record<string, string>;
5
6
  export type Color = `#${string}` | typeof NONE_COLOR;
6
7
  export declare enum AliasKind {
7
8
  Table = "table"
@@ -86,12 +87,14 @@ export interface Table {
86
87
  value: string;
87
88
  token: TokenPosition;
88
89
  };
90
+ metadata?: CustomMetadata;
89
91
  }
90
92
  export interface Note {
91
93
  name: string;
92
94
  content: string;
93
95
  token: TokenPosition;
94
96
  color?: Color;
97
+ metadata?: CustomMetadata;
95
98
  }
96
99
  export interface ColumnType {
97
100
  schemaName: string | null;
@@ -124,6 +127,7 @@ export interface Column {
124
127
  value: string;
125
128
  token: TokenPosition;
126
129
  };
130
+ metadata?: CustomMetadata;
127
131
  }
128
132
  export interface Index {
129
133
  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,10 @@ export interface TableRecord {
238
243
  values: RecordValue[][];
239
244
  token: TokenPosition;
240
245
  }
246
+ export type MetadataValues = Record<string, {
247
+ value: string;
248
+ token: TokenPosition;
249
+ }>;
241
250
  export type Project = Record<string, never> | {
242
251
  name: string | null;
243
252
  tables: Table[];
@@ -252,4 +261,4 @@ export type Project = Record<string, never> | {
252
261
  token: TokenPosition;
253
262
  [index: string & Omit<any, 'name' | 'tables' | 'refs' | 'enums' | 'tableGroups' | 'note' | 'tablePartials' | 'records'>]: string;
254
263
  };
255
- export type SchemaElement = Database | Project | Table | Note | Column | ColumnType | Index | Check | InlineRef | Ref | RefEndpoint | Enum | EnumField | TableGroup | TableGroupField | Alias | TablePartial | TablePartialInjection | TableRecord | RecordValue;
264
+ export type SchemaElement = Database | Project | Table | Note | Column | ColumnType | Index | Check | InlineRef | Ref | RefEndpoint | Enum | EnumField | TableGroup | TableGroupField | Alias | TablePartial | TablePartialInjection | TableRecord | RecordValue | MetadataValues;
@@ -1,7 +1,7 @@
1
1
  import { default as Compiler } from '../../../compiler';
2
2
  import { AttributeNode, ElementDeclarationNode, SyntaxNode } from '../nodes';
3
3
  import { SyntaxToken } from '../tokens';
4
- import { ColumnSymbol, NodeSymbol, TablePartialSymbol, TableSymbol } from '../symbol';
4
+ import { ColumnSymbol, NodeSymbol, ProgramSymbol, TablePartialSymbol, TableSymbol } from '../symbol';
5
5
  import { Internable } from '../internable';
6
6
  import { RelationshipOp, RelationCardinality } from '../relation';
7
7
  export declare enum MetadataKind {
@@ -10,7 +10,8 @@ export declare enum MetadataKind {
10
10
  TableChecks = "table checks",
11
11
  Indexes = "indexes",
12
12
  Records = "records",
13
- Project = "project"
13
+ Project = "project",
14
+ MetadataElement = "metadata element"
14
15
  }
15
16
  declare const __nodeMetadataBrand: unique symbol;
16
17
  export type NodeMetadataId = number & {
@@ -28,6 +29,11 @@ export declare abstract class NodeMetadata implements Internable<InternedNodeMet
28
29
  constructor(declaration: SyntaxNode);
29
30
  intern(): InternedNodeMetadata;
30
31
  abstract owners(compiler: Compiler): NodeSymbol[];
32
+ /** Get programs (source files) that can both
33
+ * - reach this metadata's declaration file and
34
+ * - see all the given target symbols in their nested schema.
35
+ */
36
+ resolveOwnerPrograms(compiler: Compiler, targets: NodeSymbol[]): ProgramSymbol[];
31
37
  }
32
38
  export declare class RefMetadata extends NodeMetadata {
33
39
  declaration: ElementDeclarationNode | AttributeNode;
@@ -87,6 +93,13 @@ export declare class RecordsMetadata extends NodeMetadata {
87
93
  table(compiler: Compiler): TableSymbol | undefined;
88
94
  owners(compiler: Compiler): NodeSymbol[];
89
95
  }
96
+ export declare class MetadataElementMetadata extends NodeMetadata {
97
+ declaration: ElementDeclarationNode;
98
+ readonly kind = MetadataKind.MetadataElement;
99
+ constructor(declaration: ElementDeclarationNode);
100
+ target(compiler: Compiler): NodeSymbol | undefined;
101
+ owners(compiler: Compiler): NodeSymbol[];
102
+ }
90
103
  export declare class ProjectMetadata extends NodeMetadata {
91
104
  readonly kind = MetadataKind.Project;
92
105
  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: {
@@ -35,6 +36,13 @@ export declare const ImportKind: {
35
36
  Schema: SymbolKind;
36
37
  };
37
38
  export type ImportKind = (typeof ImportKind)[keyof typeof ImportKind];
39
+ /** Allowed target element types for a Metadata element header */
40
+ export declare enum MetadataTargetKind {
41
+ Table = "Table",
42
+ Column = "Column",
43
+ TableGroup = "TableGroup",
44
+ Note = "Note"
45
+ }
38
46
  declare const __nodeSymbolBrand: unique symbol;
39
47
  export type NodeSymbolId = number & {
40
48
  readonly [__nodeSymbolBrand]: true;
@@ -1,16 +1,26 @@
1
1
  import { default as Compiler } from '../../compiler';
2
- import { Color, ColumnType, TokenPosition } from '../types/schemaJson';
2
+ import { Color, ColumnType, CustomMetadata, TokenPosition } from '../types/schemaJson';
3
3
  import { SyntaxNode } from '../types/nodes';
4
4
  import { default as Report } from '../types/report';
5
+ import { Settings } from './validate';
6
+ import { SettingName } from '../types';
5
7
  export declare function getTokenPosition(node: SyntaxNode): TokenPosition;
6
8
  export declare function normalizeNote(content: string): string;
7
9
  export declare function extractElementName(nameNode: SyntaxNode): {
8
10
  schemaName: string[];
9
11
  name: string;
10
12
  };
11
- export declare function extractColor(node: unknown): Color | undefined;
13
+ export declare function extractColor(node?: SyntaxNode): Color | undefined;
12
14
  export declare function processDefaultValue(valueNode?: SyntaxNode): {
13
15
  type: 'number' | 'string' | 'boolean' | 'expression';
14
16
  value: string | number;
15
17
  } | undefined;
16
18
  export declare function processColumnType(compiler: Compiler, typeNode: SyntaxNode): Report<ColumnType>;
19
+ /**
20
+ * Extract inline custom metadata from an aggregated setting list,
21
+ * excluding keys that are natively attached to the element (headercolor and note in `table`, color in `tablegroup`, .etc).
22
+ *
23
+ * NOTE: This is used during interpret phase, so no need to validate values, just extract them
24
+ */
25
+ export declare function extractCustomInlineMetadata(settingMap: Settings, builtinSettings: readonly SettingName[]): CustomMetadata;
26
+ export declare function extractMetadataValue(node?: SyntaxNode): string | Color | undefined;
@@ -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
  };
@@ -24,7 +24,14 @@ export declare function isValidPartialInjection(node?: SyntaxNode): node is Pref
24
24
  };
25
25
  };
26
26
  export declare function isRelationshipOp(op?: string): boolean;
27
- export declare function isValidColor(value?: SyntaxNode): boolean;
27
+ export declare function isValidHexColor(value?: SyntaxNode): value is PrimaryExpressionNode & {
28
+ expression: LiteralNode & {
29
+ literal: {
30
+ kind: SyntaxTokenKind.COLOR_LITERAL;
31
+ };
32
+ };
33
+ };
34
+ export declare function isValidColorOrNone(value?: SyntaxNode): boolean;
28
35
  export declare function isValidDefaultValue(value?: SyntaxNode): boolean;
29
36
  export type SignedNumberExpression = (PrimaryExpressionNode & {
30
37
  expression: LiteralNode & {
@@ -45,6 +52,7 @@ export declare function isTupleOfVariables(value?: SyntaxNode): value is TupleEx
45
52
  };
46
53
  export declare function isValidColumnType(type: SyntaxNode): boolean;
47
54
  export type Settings = Record<SettingName | string, AttributeNode[]>;
55
+ export declare function isValidMetadataValue(value?: SyntaxNode): boolean;
48
56
  export declare function aggregateSettingList(settingList?: ListExpressionNode): Report<Settings>;
49
57
  export declare function isExpressionAQuotedString(value?: unknown): value is PrimaryExpressionNode & ({
50
58
  expression: VariableNode & {
@@ -84,7 +92,11 @@ type DotDelimitedIdentifier = PrimaryExpressionNode | (AccessExpression & {
84
92
  });
85
93
  export declare function isAccessExpression(node?: SyntaxNode): node is AccessExpression;
86
94
  export declare function isDotDelimitedIdentifier(node?: SyntaxNode): node is DotDelimitedIdentifier;
87
- export declare function isElementNode(node: SyntaxNode | undefined, kind: ElementKind): node is ElementDeclarationNode;
95
+ export declare function isElementNode<T extends ElementKind>(node: SyntaxNode | undefined, kind: T): node is ElementDeclarationNode & {
96
+ type: {
97
+ value: T;
98
+ };
99
+ };
88
100
  export declare function isUseDeclaration(node: SyntaxNode): node is UseDeclarationNode;
89
101
  export declare function isUseSpecifier(node: SyntaxNode, kind?: ImportKind): node is UseSpecifierNode;
90
102
  export declare function isWildcardSpecifier(node: SyntaxNode): node is WildcardNode;
@@ -10,7 +10,7 @@ export { SyntaxToken, SyntaxTokenKind, isTriviaToken, isOp, isOpToken, } from '.
10
10
  export { CompileError, CompileErrorCode, } from './core/types/errors';
11
11
  export type { Position, } from './core/types';
12
12
  export { ScopeKind, splitQualifiedIdentifier, unescapeString, escapeString, formatRecordValue, isValidIdentifier, addDoubleQuoteIfNeeded, } from './compiler/index';
13
- 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, } from './core/types/schemaJson';
13
+ 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';
14
14
  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';
15
15
  export type { DiagramViewSyncOperation, DiagramViewBlock, TextEdit, } from './compiler/queries/transform';
16
16
  export { dbmlLanguageConfig, dbmlMonarchTokensProvider, } from './services/monarch';
@@ -1,5 +1,23 @@
1
1
  import { default as Compiler } from '../../compiler';
2
+ import { SettingName } from '../../core/types/keywords';
2
3
  import { CompletionItemProvider, CompletionList, Position, TextModel } from '../types';
4
+ export declare const COLUMN_TYPE_SUGGESTION_LABELS: readonly ["integer", "int", "tinyint", "smallint", "mediumint", "bigint", "bit", "bool", "binary", "varbinary", "logical", "char", "nchar", "varchar", "varchar2", "nvarchar", "nvarchar2", "binary_float", "binary_double", "float", "double", "decimal", "dec", "real", "money", "smallmoney", "enum", "tinyblob", "tinytext", "blob", "text", "mediumblob", "mediumtext", "longblob", "longtext", "ntext", "set", "inet6", "uuid", "image", "date", "time", "datetime", "datetime2", "timestamp", "year", "smalldatetime", "datetimeoffset", "XML", "sql_variant", "uniqueidentifier", "CURSOR", "BFILE", "CLOB", "NCLOB", "RAW"];
5
+ export declare const TABLE_SETTING_SUGGESTION_LABELS: readonly [SettingName.HeaderColor, SettingName.Note];
6
+ export declare const TABLE_SETTING_SUGGESTION_TEXT_INSERTS: string[];
7
+ export declare const COLUMN_SUGGESTION_LABELS: (SettingName.Note | SettingName.PK | SettingName.PrimaryKey | SettingName.Unique | SettingName.Ref | SettingName.NotNull | SettingName.Null | SettingName.Increment | SettingName.Default | SettingName.Check)[];
8
+ export declare const COLUMN_SUGGESTION_TEXT_INSERTS: string[];
9
+ export declare const INDEX_SETTING_SUGGESTION_LABELS: (SettingName.Note | SettingName.PK | SettingName.Unique | SettingName.Name | SettingName.Type)[];
10
+ export declare const INDEX_SETTING_SUGGESTION_TEXT_INSERTS: string[];
11
+ export declare const REF_SETTING_SUGGESTION_LABELS: (SettingName.Color | SettingName.Update | SettingName.Delete | SettingName.Inactive)[];
12
+ export declare const REF_SETTING_SUGGESTION_TEXT_INSERTS: string[];
13
+ export declare const ENUM_SETTING_SUGGESTION_LABELS: readonly [SettingName.Note];
14
+ export declare const ENUM_SETTING_SUGGESTION_TEXT_INSERTS: string[];
15
+ export declare const CHECK_SETTING_SUGGESTION_LABELS: readonly [SettingName.Name];
16
+ export declare const CHECK_SETTING_SUGGESTION_TEXT_INSERTS: string[];
17
+ export declare const REF_ACTION_VALUE_SUGGESTIONS: readonly ["cascade", "set default", "set null", "restrict"];
18
+ export declare const INDEX_TYPE_VALUE_SUGGESTIONS: readonly ["btree", "hash"];
19
+ export declare const TABLE_BODY_SUGGESTION_LABELS: ("indexes" | "checks" | "Note" | "Records")[];
20
+ export declare const PROJECT_FIELD_SUGGESTION_LABELS: ("Table" | "Enum" | "TableGroup" | "TablePartial" | "Note" | "Ref")[];
3
21
  export interface DBMLCompletionItemProviderOptions {
4
22
  triggerCharacters?: string[];
5
23
  }
@@ -9,3 +27,4 @@ export default class DBMLCompletionItemProvider implements CompletionItemProvide
9
27
  constructor(compiler: Compiler, options?: DBMLCompletionItemProviderOptions);
10
28
  provideCompletionItems(model: TextModel, position: Position): CompletionList;
11
29
  }
30
+ export declare const TOP_LEVEL_SUGGESTION_LABELS: ("Table" | "Enum" | "TableGroup" | "TablePartial" | "Note" | "DiagramView" | "Metadata" | "Ref" | "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": "9.0.0-optional-ref.12",
4
+ "version": "9.1.0-alpha.0",
5
5
  "description": "DBML parser v2",
6
6
  "author": "Holistics <dev@holistics.io>",
7
7
  "license": "Apache-2.0",
@@ -31,7 +31,8 @@
31
31
  "test:watch": "vitest watch",
32
32
  "coverage": "vitest run --coverage",
33
33
  "prepare": "npm run build",
34
- "lint": "eslint .",
34
+ "lint": "eslint $(git diff --relative --name-only --diff-filter=ACMRTUXB master -- . | grep -E '\\.ts$')",
35
+ "lint:all": "eslint .",
35
36
  "lint:fix": "eslint --fix .",
36
37
  "bench": "npx tsx __benchmarks__/compiler.benchmark.ts",
37
38
  "profile:build": "vite build --config vite.profile.config.mts && cp -r __benchmarks__/input dist-profile/input",
@@ -50,5 +51,5 @@
50
51
  "engines": {
51
52
  "node": ">=18"
52
53
  },
53
- "gitHead": "57741244adba234137bc9a3c0a841ad24351923b"
54
+ "gitHead": "ded9225eb7ea81cc83ed07f44c9c795f978c1836"
54
55
  }