@dbml/parse 11.0.0-alpha.6 → 11.0.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.
Files changed (49) hide show
  1. package/LICENSE +0 -0
  2. package/dist/dbml-parse.js +28 -38
  3. package/dist/dbml-parse.mjs +5138 -6094
  4. package/dist/src/compiler/index.d.ts +8 -28
  5. package/dist/src/compiler/projectLayout/layout.d.ts +7 -0
  6. package/dist/src/compiler/queries/transform/index.d.ts +1 -2
  7. package/dist/src/compiler/queries/transform/types.d.ts +1 -10
  8. package/dist/src/core/global_modules/index.d.ts +1 -2
  9. package/dist/src/core/global_modules/metadata/interpret.d.ts +2 -2
  10. package/dist/src/core/global_modules/metadata/registries.d.ts +19 -0
  11. package/dist/src/core/global_modules/metadata/utils.d.ts +19 -14
  12. package/dist/src/core/global_modules/note/interpret.d.ts +1 -3
  13. package/dist/src/core/global_modules/program/bind.d.ts +0 -1
  14. package/dist/src/core/global_modules/program/interpret.d.ts +0 -2
  15. package/dist/src/core/global_modules/records/utils/data/values.d.ts +1 -2
  16. package/dist/src/core/global_modules/table/interpret.d.ts +1 -4
  17. package/dist/src/core/global_modules/tableGroup/interpret.d.ts +1 -3
  18. package/dist/src/core/lexer/lexer.d.ts +1 -6
  19. package/dist/src/core/local_modules/dep/validate.d.ts +1 -4
  20. package/dist/src/core/local_modules/index.d.ts +0 -1
  21. package/dist/src/core/local_modules/note/validate.d.ts +0 -2
  22. package/dist/src/core/local_modules/table/validate.d.ts +1 -7
  23. package/dist/src/core/local_modules/tableGroup/validate.d.ts +1 -5
  24. package/dist/src/core/parser/parser.d.ts +1 -5
  25. package/dist/src/core/types/errors.d.ts +5 -17
  26. package/dist/src/core/types/filepath.d.ts +3 -1
  27. package/dist/src/core/types/nodes.d.ts +0 -1
  28. package/dist/src/core/types/schemaJson/types.d.ts +8 -47
  29. package/dist/src/core/types/symbol/metadata.d.ts +1 -13
  30. package/dist/src/core/types/symbol/symbols.d.ts +0 -9
  31. package/dist/src/core/types/tokens.d.ts +0 -1
  32. package/dist/src/core/utils/expression.d.ts +2 -0
  33. package/dist/src/core/utils/interpret.d.ts +15 -4
  34. package/dist/src/core/utils/validate.d.ts +0 -1
  35. package/dist/src/index.d.ts +4 -11
  36. package/dist/src/services/definition/provider.d.ts +1 -0
  37. package/dist/src/services/suggestions/provider.d.ts +2 -0
  38. package/dist/src/services/suggestions/use.d.ts +4 -1
  39. package/package.json +3 -3
  40. package/dist/src/compiler/queries/files/fileKind.d.ts +0 -12
  41. package/dist/src/compiler/queries/transform/renameElement.d.ts +0 -8
  42. package/dist/src/compiler/queries/transform/utils/arch.d.ts +0 -17
  43. package/dist/src/core/arch/icons.d.ts +0 -6
  44. package/dist/src/core/arch/read.d.ts +0 -59
  45. package/dist/src/core/arch/vocabulary.d.ts +0 -10
  46. package/dist/src/core/global_modules/arch/index.d.ts +0 -2
  47. package/dist/src/core/global_modules/arch/interpret.d.ts +0 -9
  48. package/dist/src/core/global_modules/arch/utils.d.ts +0 -5
  49. package/dist/src/core/local_modules/arch/index.d.ts +0 -2
@@ -1,18 +1,9 @@
1
- import { GlobalModule } from '../core/global_modules/types';
2
- import { ParserOptions } from '../core/parser/parser';
3
- import { LexerOptions } from '../core/lexer/lexer';
4
- import { SyntaxToken } from '../core/types/tokens';
5
- import { FileKind, FileScan } from './queries/files/fileKind';
6
1
  import { Filepath } from '../core/types/filepath';
7
2
  import { SyntaxNode, SyntaxNodeIdGenerator } from '../core/types/nodes';
8
3
  import { NodeSymbolIdGenerator, SymbolFactory } from '../core/types/symbol';
9
4
  import { DBMLCodeActionProvider, DBMLCompletionItemProvider, DBMLDefinitionProvider, DBMLDiagnosticsProvider, DBMLReferencesProvider } from '../services/index';
10
5
  import { DbmlProjectLayout } from './projectLayout';
11
6
  import { addDoubleQuoteIfNeeded, escapeString, formatRecordValue, isValidIdentifier, normalizeQualifiedName, splitQualifiedIdentifier, unescapeString } from './queries/utils';
12
- export interface DialectOptions {
13
- lexer?: LexerOptions;
14
- parser?: ParserOptions;
15
- }
16
7
  export { ScopeKind } from './types';
17
8
  export type { TextEdit } from './queries/transform';
18
9
  export { addDoubleQuoteIfNeeded, escapeString, formatRecordValue, isValidIdentifier, normalizeQualifiedName, splitQualifiedIdentifier, unescapeString, };
@@ -21,19 +12,8 @@ export default class Compiler {
21
12
  readonly nodeIdGenerator: SyntaxNodeIdGenerator;
22
13
  readonly symbolIdGenerator: NodeSymbolIdGenerator;
23
14
  readonly symbolFactory: SymbolFactory;
24
- readonly explicitModules: GlobalModule[] | undefined;
25
- private readonly explicitDialect;
26
- readonly dialect: DialectOptions;
27
- constructor(layout: DbmlProjectLayout, modules?: GlobalModule[], dialect?: DialectOptions);
15
+ constructor(layout: DbmlProjectLayout);
28
16
  getSource(filepath: Filepath): string | undefined;
29
- lexerOptions(): LexerOptions;
30
- parserOptions(kind: FileKind): ParserOptions;
31
- private fileScans;
32
- private fileKinds;
33
- scanFile(filepath: Filepath, tokens?: readonly SyntaxToken[]): FileScan;
34
- fileKind(filepath: Filepath): FileKind;
35
- fileKindForParse(filepath: Filepath, tokens?: readonly SyntaxToken[]): FileKind;
36
- parsedFileKind(filepath: Filepath): FileKind;
37
17
  private sourceSnapshot;
38
18
  private cleanStaleLocalCache;
39
19
  private entrypointsSnapshot;
@@ -90,9 +70,8 @@ export default class Compiler {
90
70
  }[];
91
71
  };
92
72
  }>;
93
- nodeAtPosition: (filepath: Filepath, offset: number) => SyntaxNode | SyntaxToken | undefined;
73
+ nodeAtPosition: (filepath: Filepath, offset: number) => SyntaxNode | import('..').SyntaxToken | undefined;
94
74
  renameTable: (filepath: Filepath, oldName: string | import('..').TableIdentifier, newName: string | import('..').TableIdentifier) => Map<string, string>;
95
- renameElement: (filepath: Filepath, oldHandle: string, newName: string) => Map<string, string>;
96
75
  updateElementSetting: (filepath: Filepath, target: import('..').ElementIdentifier, settingName: string, value: string | null | undefined) => string;
97
76
  updateElementSettingEdit: (filepath: Filepath, target: import('..').ElementIdentifier, settingName: string, value: string | null | undefined) => import('.').TextEdit[];
98
77
  syncDiagramView: (filepath: Filepath, operations: import('..').DiagramViewSyncOperation[], blocks?: import('..').DiagramViewBlock[] | undefined) => {
@@ -104,22 +83,22 @@ export default class Compiler {
104
83
  edits: import('.').TextEdit[];
105
84
  };
106
85
  readonly token: {
107
- invalidStream: (filepath: Filepath) => readonly SyntaxToken[];
108
- flatStream: (filepath: Filepath) => readonly SyntaxToken[];
86
+ invalidStream: (filepath: Filepath) => readonly import('..').SyntaxToken[];
87
+ flatStream: (filepath: Filepath) => readonly import('..').SyntaxToken[];
109
88
  };
110
89
  readonly parse: {
111
90
  source: (filepath: Filepath) => string;
112
91
  ast: (filepath?: Filepath) => Readonly<import('../core/types/nodes').ProgramNode>;
113
92
  errors: (filepath?: Filepath) => readonly Readonly<import('..').CompileError>[];
114
- warnings: (filepath?: Filepath) => readonly Readonly<import('../core/types').CompileWarning>[];
115
- tokens: (filepath?: Filepath) => readonly Readonly<SyntaxToken>[];
93
+ warnings: (filepath?: Filepath) => readonly Readonly<import('..').CompileWarning>[];
94
+ tokens: (filepath?: Filepath) => readonly Readonly<import('..').SyntaxToken>[];
116
95
  rawDb: (filepath?: Filepath) => Readonly<import('..').Database> | undefined;
117
96
  publicSymbolTable: (filepath?: Filepath) => readonly Readonly<import('../core/types/symbol').NodeSymbol>[] | undefined;
118
97
  };
119
98
  readonly container: {
120
99
  stack: (filepath: Filepath, offset: number) => readonly Readonly<SyntaxNode>[];
121
100
  token: (filepath: Filepath, offset: number) => {
122
- token: SyntaxToken;
101
+ token: import('..').SyntaxToken;
123
102
  index: number;
124
103
  } | {
125
104
  token: undefined;
@@ -132,6 +111,7 @@ export default class Compiler {
132
111
  initMonacoServices(options?: {
133
112
  autocompletion?: {
134
113
  triggerCharacters?: string[];
114
+ fileListDepth?: number;
135
115
  };
136
116
  }): {
137
117
  definitionProvider: DBMLDefinitionProvider;
@@ -1,6 +1,12 @@
1
1
  import { Filepath } from '../../core/types/filepath';
2
+ export interface FileSpecifierInfo {
3
+ specifier: string;
4
+ label?: string;
5
+ detail?: string;
6
+ }
2
7
  export interface DbmlProjectLayout {
3
8
  resolveFileSpecifier(currentFilepath: Filepath, specifier: string): Filepath | undefined;
9
+ getFileSpecifierInfo(currentFilepath: Filepath, targetFilepath: Filepath): FileSpecifierInfo | undefined;
4
10
  getSource(filePath: Filepath): string | undefined;
5
11
  exists(filePath: Filepath): boolean;
6
12
  isFile(filePath: Filepath): boolean;
@@ -12,6 +18,7 @@ export declare class MemoryProjectLayout implements DbmlProjectLayout {
12
18
  private readonly files;
13
19
  constructor(files?: Map<string, string> | Record<string, string>);
14
20
  resolveFileSpecifier(currentFilepath: Filepath, relativePath: string): Filepath | undefined;
21
+ getFileSpecifierInfo(currentFilepath: Filepath, targetFilepath: Filepath): FileSpecifierInfo | undefined;
15
22
  setSource(filePath: Filepath, content: string): void;
16
23
  getSource(filePath: Filepath): string | undefined;
17
24
  deleteSource(filePath: Filepath): void;
@@ -1,7 +1,6 @@
1
1
  export { renameTable } from './renameTable';
2
- export { renameElement } from './renameElement';
3
2
  export { updateElementSetting, updateElementSettingEdit } from './updateElementSetting';
4
3
  export { syncDiagramView, findDiagramViewBlocks, type DiagramViewSyncOperation, type DiagramViewBlock, } from './syncDiagramView';
5
4
  export { syncDep, generateDepBlock, type DepSyncOperation, type DepSyncEdge, type DepEndpointRef, } from './syncDep';
6
5
  export { applyTextEdits, type TextEdit } from './applyTextEdits';
7
- export type { ElementIdentifier, SchemaIdentifier, TableIdentifier, ColumnIdentifier, EnumIdentifier, EndpointRef, RefIdentifier, DepIdentifier, NoteIdentifier, TableGroupIdentifier, ArchElementIdentifier, ArchLinkIdentifier, } from './types';
6
+ export type { ElementIdentifier, SchemaIdentifier, TableIdentifier, ColumnIdentifier, EnumIdentifier, EndpointRef, RefIdentifier, DepIdentifier, NoteIdentifier, TableGroupIdentifier, } from './types';
@@ -1,6 +1,6 @@
1
1
  import { SymbolKind } from '../../../core/types/symbol';
2
2
  import { MetadataKind } from '../../../core/types/symbol/metadata';
3
- export type ElementIdentifier = (SchemaIdentifier | TableIdentifier | ColumnIdentifier | EnumIdentifier | RefIdentifier | DepIdentifier | NoteIdentifier | TableGroupIdentifier | ArchElementIdentifier | ArchLinkIdentifier) & {
3
+ export type ElementIdentifier = (SchemaIdentifier | TableIdentifier | ColumnIdentifier | EnumIdentifier | RefIdentifier | DepIdentifier | NoteIdentifier | TableGroupIdentifier) & {
4
4
  kind: string;
5
5
  };
6
6
  export interface SchemaIdentifier {
@@ -46,12 +46,3 @@ export interface TableGroupIdentifier {
46
46
  schema?: string;
47
47
  name: string;
48
48
  }
49
- export interface ArchElementIdentifier {
50
- kind?: typeof SymbolKind.Element;
51
- name: string;
52
- }
53
- export interface ArchLinkIdentifier {
54
- kind?: 'Link';
55
- from: string;
56
- to: string;
57
- }
@@ -7,8 +7,7 @@ import { NodeMetadata } from '../types/symbol/metadata';
7
7
  import { SchemaElement } from '../types/schemaJson';
8
8
  import { NodeSymbol } from '../types/symbol';
9
9
  import { GlobalModule } from './types';
10
- export declare const dbmlModules: GlobalModule[];
11
- export declare const archModules: GlobalModule[];
10
+ export declare const modules: GlobalModule[];
12
11
  export declare function nodeSymbol(this: Compiler, node: SyntaxNode): Report<NodeSymbol> | Report<Unhandled>;
13
12
  export declare function symbolMembers(this: Compiler, symbol: NodeSymbol): Report<NodeSymbol[]> | Report<Unhandled>;
14
13
  export declare function nodeReferee(this: Compiler, node: SyntaxNode): Report<NodeSymbol | undefined> | Report<Unhandled>;
@@ -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 { MetadataValues } from '../../types/schemaJson';
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<MetadataValues>;
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,22 +1,29 @@
1
1
  import { default as Compiler } from '../../../compiler/index';
2
- import { Filepath, FilepathId, SettingName } from '../../types';
3
- import { Column, Note, Table, TableGroup, TokenPosition } from '../../types/schemaJson';
2
+ import { Filepath, SettingName } from '../../types';
3
+ import { Column, CustomMetadataValue, CustomMetadataValueType, Note, Table, TableGroup, TokenPosition } from '../../types/schemaJson';
4
4
  import { ElementDeclarationNode, SyntaxNode } from '../../types/nodes';
5
5
  import { NodeSymbol, SymbolKind, MetadataTargetKind } from '../../types/symbol';
6
6
  export type MetadataTarget = Table | TableGroup | Note | Column;
7
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`)
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
- interface MetadataField<T extends MetadataTarget> {
13
- /** Check if the metadata value is syntactically correct */
14
- isValidBuiltinFieldValue(node?: SyntaxNode): boolean;
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 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>>;
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
+ };
20
27
  type NameWithSymbolKind = {
21
28
  name: string;
22
29
  symbolKind: SymbolKind;
@@ -24,8 +31,6 @@ type NameWithSymbolKind = {
24
31
  /** @internal Exported for testing only. */
25
32
  export declare function mapNamePartToSymbolKind(nameParts: string[], targetKind: MetadataTargetKind): NameWithSymbolKind[];
26
33
  export declare function resolveMetadataTarget(compiler: Compiler, metadataNode: ElementDeclarationNode): NodeSymbol | undefined;
27
- /** Get precedence score of files in import tree, lower score means lower precedence */
28
- export declare function metadataFilePrecedence(compiler: Compiler, root: Filepath): Map<FilepathId, number>;
29
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 { SettingName, Filepath, NoteSymbol } from '../../types';
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;
@@ -6,7 +6,6 @@ export default class Binder {
6
6
  private compiler;
7
7
  constructor(ast: ProgramNode, compiler: Compiler);
8
8
  resolve(): Report<void>;
9
- private isArchFile;
10
9
  private checkDuplicateRefs;
11
10
  private checkStandaloneRefs;
12
11
  private checkInlineRefs;
@@ -14,8 +14,6 @@ export default class ProgramInterpreter {
14
14
  private db;
15
15
  constructor(compiler: Compiler, symbol: ProgramSymbol, filepath: Filepath);
16
16
  interpret(): Report<SchemaElement | SchemaElement[] | undefined>;
17
- private arch;
18
- private finishArch;
19
17
  private interpretAllSymbols;
20
18
  private interpretUseSymbol;
21
19
  private interpretAllMetadata;
@@ -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,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 { Column, Table } from '../../types/schemaJson';
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 { SettingName, Filepath, TableGroupSymbol } from '../../types';
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,9 +1,6 @@
1
1
  import { Filepath } from '../types/filepath';
2
2
  import { default as Report } from '../types/report';
3
3
  import { SyntaxToken, SyntaxTokenKind } from '../types/tokens';
4
- export interface LexerOptions {
5
- allowFrontMatter?: boolean;
6
- }
7
4
  export default class Lexer {
8
5
  private start;
9
6
  private current;
@@ -11,9 +8,7 @@ export default class Lexer {
11
8
  private filepath;
12
9
  private tokens;
13
10
  private errors;
14
- private readonly options;
15
- constructor(text: string, filepath: Filepath, options?: LexerOptions);
16
- private scanFrontMatter;
11
+ constructor(text: string, filepath: Filepath);
17
12
  private isAtEnd;
18
13
  private advance;
19
14
  private peek;
@@ -1,8 +1,6 @@
1
1
  import { default as Compiler } from '../../../compiler';
2
2
  import { CompileError } from '../../types/errors';
3
- import { BlockExpressionNode, ElementDeclarationNode, FunctionApplicationNode, ListExpressionNode } from '../../types/nodes';
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>;
@@ -4,7 +4,6 @@ import { SyntaxNode } from '../types/nodes';
4
4
  import { default as Report } from '../types/report';
5
5
  import { LocalModule, Settings } from './types';
6
6
  export declare const modules: LocalModule[];
7
- export declare const archModules: LocalModule[];
8
7
  export declare function validateNode(this: Compiler, node: SyntaxNode): Report<void> | Report<Unhandled>;
9
8
  export declare function nodeSettings(this: Compiler, node: SyntaxNode): Report<Settings> | Report<Unhandled>;
10
9
  export declare function nodeFullname(this: Compiler, node: SyntaxNode): Report<string[] | undefined> | Report<Unhandled>;
@@ -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, ExpressionNode, ListExpressionNode } from '../../types/nodes';
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, ListExpressionNode } from '../../types/nodes';
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>;
@@ -2,9 +2,6 @@ import { Filepath } from '../types/filepath';
2
2
  import { ProgramNode, SyntaxNodeIdGenerator } from '../types/nodes';
3
3
  import { default as Report } from '../types/report';
4
4
  import { SyntaxToken } from '../types/tokens';
5
- export interface ParserOptions {
6
- allowBodylessElement?: boolean;
7
- }
8
5
  export default class Parser {
9
6
  private tokens;
10
7
  private current;
@@ -13,8 +10,7 @@ export default class Parser {
13
10
  private nodeFactory;
14
11
  private source;
15
12
  private filepath;
16
- private readonly options;
17
- constructor(source: string, tokens: SyntaxToken[], nodeIdGenerator: SyntaxNodeIdGenerator, filepath: Filepath, options?: ParserOptions);
13
+ constructor(source: string, tokens: SyntaxToken[], nodeIdGenerator: SyntaxNodeIdGenerator, filepath: Filepath);
18
14
  private isAtEnd;
19
15
  private advance;
20
16
  private peek;
@@ -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,
@@ -126,23 +130,7 @@ export declare enum CompileErrorCode {
126
130
  TABLE_REAPPEAR_IN_TABLEGROUP = 5009,
127
131
  INVALID_METADATA_TARGET_KIND = 5010,
128
132
  INVALID_METADATA_FIELD = 5011,
129
- DUPLICATE_METADATA_FIELD = 5012,
130
- UNKNOWN_ROLE = 6000,
131
- MISSING_NAME = 6001,
132
- NO_CUSTOM_ROLE = 6002,
133
- UNKNOWN_ENDPOINT = 6003,
134
- EMPTY_LINK = 6004,
135
- BAD_LINK = 6005,
136
- UNKNOWN_METADATA_TARGET = 6006,
137
- BAD_PROPERTY = 6007,
138
- DUPLICATE_PROPERTY = 6008,
139
- DIAGRAM_TYPE_NOT_HERE = 6009,
140
- METADATA_ROLE_MISMATCH = 6010,
141
- UNKNOWN_TYPE = 6011,
142
- UNKNOWN_ICON = 6012,
143
- BAD_IMAGE = 6013,
144
- DUPLICATE_LINK = 6014,
145
- NESTED_ENDPOINTS = 6015
133
+ DUPLICATE_METADATA_FIELD = 5012
146
134
  }
147
135
  export interface RelatedLocation {
148
136
  nodeOrToken: SyntaxNode | SyntaxToken;
@@ -5,10 +5,12 @@ export type FilepathId = string & {
5
5
  };
6
6
  export declare class Filepath implements Internable<FilepathId> {
7
7
  private readonly protocol?;
8
- private readonly path;
8
+ private readonly root;
9
+ private readonly segments;
9
10
  constructor(absolutePath: string, options?: {
10
11
  protocol?: string;
11
12
  });
13
+ private get path();
12
14
  intern(): FilepathId;
13
15
  static from(absolutePath: string): Filepath;
14
16
  static resolve(fromDir: string, relativePath: string): Filepath;
@@ -95,7 +95,6 @@ export declare class UseSpecifierNode extends SyntaxNode {
95
95
  asKeyword?: SyntaxToken;
96
96
  alias?: NormalExpressionNode;
97
97
  }, id: SyntaxNodeId, filepath: Filepath);
98
- archImport?: boolean;
99
98
  isKind(...importKinds: ImportKind[]): boolean;
100
99
  getSymbolKind(): SymbolKind | undefined;
101
100
  }
@@ -2,7 +2,13 @@ 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
+ export type CustomMetadataValueType = 'string' | 'number' | 'bool' | 'color';
6
+ export interface CustomMetadataValue {
7
+ value: string | number | boolean;
8
+ type: CustomMetadataValueType;
9
+ token: TokenPosition;
10
+ }
11
+ export type CustomMetadata = Record<string, CustomMetadataValue>;
6
12
  export type Color = `#${string}` | typeof NONE_COLOR;
7
13
  export declare enum AliasKind {
8
14
  Table = "table"
@@ -27,8 +33,6 @@ export interface DatabaseExternals {
27
33
  tableGroups: ElementRef[];
28
34
  tablePartials: ElementRef[];
29
35
  notes: ElementRef[];
30
- nodes?: ElementRef[];
31
- groups?: ElementRef[];
32
36
  }
33
37
  /**
34
38
  * FilterConfig is a tri-state filter:
@@ -72,45 +76,6 @@ export interface Database {
72
76
  externals: DatabaseExternals;
73
77
  diagramViews: DiagramView[];
74
78
  token?: TokenPosition;
75
- nodes?: Node[];
76
- groups?: Group[];
77
- links?: Link[];
78
- frontMatter?: Record<string, string>;
79
- diagramType?: 'arch';
80
- }
81
- export type ArchSettingValue = string | number | boolean;
82
- export type ArchSettings = Record<string, ArchSettingValue>;
83
- export interface Node {
84
- name: string;
85
- alias: string | null;
86
- role: string;
87
- type: string | null;
88
- image: string | null;
89
- settings: ArchSettings;
90
- note: {
91
- value: string;
92
- token: TokenPosition;
93
- } | null;
94
- token: TokenPosition;
95
- }
96
- export interface Group {
97
- name: string;
98
- alias: string | null;
99
- children: string[];
100
- settings: ArchSettings;
101
- note: {
102
- value: string;
103
- token: TokenPosition;
104
- } | null;
105
- token: TokenPosition;
106
- }
107
- export type LinkOp = '>' | '<' | '<>' | '-';
108
- export interface Link {
109
- from: string;
110
- to: string;
111
- op: LinkOp;
112
- settings: ArchSettings;
113
- token: TokenPosition;
114
79
  }
115
80
  export interface MasterDatabase {
116
81
  files: Record<string, Database>;
@@ -320,10 +285,6 @@ export interface TableRecord {
320
285
  example?: boolean;
321
286
  token: TokenPosition;
322
287
  }
323
- export type MetadataValues = Record<string, {
324
- value: string;
325
- token: TokenPosition;
326
- }>;
327
288
  export type Project = Record<string, never> | {
328
289
  name: string | null;
329
290
  tables: Table[];
@@ -338,4 +299,4 @@ export type Project = Record<string, never> | {
338
299
  token: TokenPosition;
339
300
  [index: string & Omit<any, 'name' | 'tables' | 'refs' | 'enums' | 'tableGroups' | 'note' | 'tablePartials' | 'records'>]: string;
340
301
  };
341
- 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 | MetadataValues | Node | Group | Link | ArchSettings;
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;
@@ -12,8 +12,7 @@ export declare enum MetadataKind {
12
12
  Indexes = "indexes",
13
13
  Records = "records",
14
14
  Project = "project",
15
- MetadataElement = "metadata element",
16
- Link = "link"
15
+ MetadataElement = "metadata element"
17
16
  }
18
17
  declare const __nodeMetadataBrand: unique symbol;
19
18
  export type NodeMetadataId = number & {
@@ -116,17 +115,6 @@ export declare class MetadataElementMetadata extends NodeMetadata {
116
115
  target(compiler: Compiler): NodeSymbol | undefined;
117
116
  owners(compiler: Compiler): NodeSymbol[];
118
117
  }
119
- export declare class LinkMetadata extends NodeMetadata {
120
- declaration: ElementDeclarationNode | AttributeNode;
121
- readonly kind = MetadataKind.Link;
122
- constructor(declaration: ElementDeclarationNode | AttributeNode);
123
- op(): string | undefined;
124
- endpoints(compiler: Compiler): [NodeSymbol | undefined, NodeSymbol | undefined];
125
- owners(compiler: Compiler): NodeSymbol[];
126
- }
127
- export declare class ArchMetadataElementMetadata extends MetadataElementMetadata {
128
- target(compiler: Compiler): NodeSymbol | undefined;
129
- }
130
118
  export declare class ProjectMetadata extends NodeMetadata {
131
119
  readonly kind = MetadataKind.Project;
132
120
  constructor(declaration: SyntaxNode);
@@ -25,7 +25,6 @@ export declare enum SymbolKind {
25
25
  DiagramViewNote = "DiagramView note",
26
26
  DiagramViewSchema = "DiagramView schema",
27
27
  Metadata = "Metadata",
28
- Element = "Element",
29
28
  Program = "Program"
30
29
  }
31
30
  export declare const ImportKind: {
@@ -204,14 +203,6 @@ export declare class TableGroupFieldSymbol extends NodeSymbol {
204
203
  get canBeImported(): boolean;
205
204
  get originalSymbol(): NodeSymbol;
206
205
  }
207
- export declare class ElementSymbol extends NodeSymbol {
208
- constructor({ declaration, name, }: {
209
- declaration?: SyntaxNode;
210
- name?: string;
211
- }, id: NodeSymbolId, filepath: Filepath);
212
- get canBeImported(): boolean;
213
- get originalSymbol(): NodeSymbol;
214
- }
215
206
  export declare class NoteSymbol extends NodeSymbol {
216
207
  constructor({ declaration, name, }: {
217
208
  declaration?: SyntaxNode;
@@ -25,7 +25,6 @@ export declare enum SyntaxTokenKind {
25
25
  COLON = "<colon>",
26
26
  SINGLE_LINE_COMMENT = "<single-line-comment>",
27
27
  MULTILINE_COMMENT = "<multiline-comment>",
28
- FRONT_MATTER = "<front-matter>",
29
28
  WILDCARD = "<wildcard>"
30
29
  }
31
30
  export declare function isTriviaToken(token: SyntaxToken): boolean;