@dbml/parse 8.3.1-custom-metadata.0 → 8.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -100,7 +100,7 @@ export default class Compiler {
100
100
  token: undefined;
101
101
  index: undefined;
102
102
  };
103
- element: (filepath: Filepath, offset: number) => Readonly<import('../core/types/nodes').ElementDeclarationNode | import('../core/types/nodes').ProgramNode | import('../core/types/nodes').MetadataDeclarationNode>;
103
+ element: (filepath: Filepath, offset: number) => Readonly<import('../core/types/nodes').ElementDeclarationNode | import('../core/types/nodes').ProgramNode>;
104
104
  scope: (filepath: Filepath, offset: number) => import('../core/types/symbol').NodeSymbol[] | undefined;
105
105
  scopeKind: (filepath: Filepath, offset: number) => import('./types').ScopeKind;
106
106
  };
@@ -1,4 +1,4 @@
1
1
  import { Filepath } from '../../../core/types/filepath';
2
- import { ElementDeclarationNode, MetadataDeclarationNode, ProgramNode } from '../../../core/types/nodes';
2
+ import { ElementDeclarationNode, ProgramNode } from '../../../core/types/nodes';
3
3
  import { default as Compiler } from '../../index';
4
- export declare function containerElement(this: Compiler, filepath: Filepath, offset: number): Readonly<ElementDeclarationNode | MetadataDeclarationNode | ProgramNode>;
4
+ export declare function containerElement(this: Compiler, filepath: Filepath, offset: number): Readonly<ElementDeclarationNode | ProgramNode>;
@@ -11,6 +11,5 @@ export declare const enum ScopeKind {
11
11
  TABLEPARTIAL = 9,
12
12
  CHECKS = 10,
13
13
  RECORDS = 11,
14
- DIAGRAMVIEW = 12,
15
- METADATA = 13
14
+ DIAGRAMVIEW = 12
16
15
  }
@@ -1,5 +1,5 @@
1
1
  import { default as Compiler } from '../../compiler';
2
- import { Filepath, RelationCardinality } from '../types';
2
+ import { RelationCardinality } from '../types';
3
3
  import { PrimaryExpressionNode, SyntaxNode, VariableNode } from '../types/nodes';
4
4
  import { default as Report } from '../types/report';
5
5
  import { NodeSymbol } from '../types/symbol';
@@ -15,5 +15,3 @@ export declare function scanNonListNodeForBinding(node?: SyntaxNode): {
15
15
  }[];
16
16
  export declare function nodeRefereeOfLeftExpression(compiler: Compiler, node: SyntaxNode): NodeSymbol | undefined;
17
17
  export declare function getMultiplicities(op: string): [RelationCardinality, RelationCardinality] | undefined;
18
- export declare function getDefaultSchemaSymbol(compiler: Compiler, globalSymbol: NodeSymbol): NodeSymbol | undefined;
19
- export declare function getGlobalSymbol(compiler: Compiler, filepath: Filepath): NodeSymbol | undefined;
@@ -32,7 +32,6 @@ export default class Parser {
32
32
  private synchronizeUseSpecifierList;
33
33
  private useSpecifier;
34
34
  private synchronizeProgram;
35
- private metadataDeclaration;
36
35
  private elementDeclaration;
37
36
  private synchronizeElementDeclarationName;
38
37
  private synchronizeElementDeclarationAlias;
@@ -113,13 +113,7 @@ export declare enum CompileErrorCode {
113
113
  SAME_ENDPOINT = 5002,
114
114
  UNEQUAL_FIELDS_BINARY_REF = 5003,
115
115
  CONFLICTING_SETTING = 5004,
116
- TABLE_REAPPEAR_IN_TABLEGROUP = 5005,
117
- INVALID_METADATA_CONTEXT = 5006,
118
- INVALID_METADATA_TARGET_KIND = 5007,
119
- INVALID_METADATA_FIELD = 5008,
120
- DUPLICATE_METADATA_FIELD = 5009,
121
- METADATA_TARGET_NOT_FOUND = 5010,
122
- DUPLICATE_METADATA_KEY_ACROSS_BLOCKS = 5011
116
+ TABLE_REAPPEAR_IN_TABLEGROUP = 5005
123
117
  }
124
118
  export declare class CompileError extends Error {
125
119
  code: Readonly<CompileErrorCode>;
@@ -13,8 +13,7 @@ export declare enum ElementKind {
13
13
  DiagramViewTables = "tables",
14
14
  DiagramViewNotes = "notes",
15
15
  DiagramViewTableGroups = "tablegroups",
16
- DiagramViewSchemas = "schemas",
17
- Metadata = "metadata"
16
+ DiagramViewSchemas = "schemas"
18
17
  }
19
18
  export declare enum SettingName {
20
19
  Color = "color",
@@ -1,7 +1,7 @@
1
1
  import { Filepath } from './filepath';
2
2
  import { Internable } from './internable';
3
3
  import { ElementKind } from './keywords';
4
- import { ImportKind, MetadataTargetKind, SymbolKind } from './symbol';
4
+ import { ImportKind, SymbolKind } from './symbol';
5
5
  import { Position } from './position';
6
6
  import { SyntaxToken } from './tokens';
7
7
  export type SyntaxNodeId = number;
@@ -36,7 +36,6 @@ export declare class SyntaxNode implements Internable<InternedSyntaxNode> {
36
36
  export declare enum SyntaxNodeKind {
37
37
  PROGRAM = "<program>",
38
38
  ELEMENT_DECLARATION = "<element-declaration>",
39
- METADATA_DECLARATION = "<metadata-declaration>",
40
39
  USE_DECLARATION = "<use-declaration>",
41
40
  USE_SPECIFIER = "<use-specifier>",
42
41
  USE_SPECIFIER_LIST = "<use-specifier-list>",
@@ -61,17 +60,16 @@ export declare enum SyntaxNodeKind {
61
60
  WILDCARD = "<wildcard>"
62
61
  }
63
62
  export declare class ProgramNode extends SyntaxNode {
64
- body: (UseDeclarationNode | ElementDeclarationNode | MetadataDeclarationNode)[];
63
+ body: (UseDeclarationNode | ElementDeclarationNode)[];
65
64
  eof?: SyntaxToken;
66
65
  source: string;
67
66
  constructor({ body, eof, source, }: {
68
- body?: (UseDeclarationNode | ElementDeclarationNode | MetadataDeclarationNode)[];
67
+ body?: (UseDeclarationNode | ElementDeclarationNode)[];
69
68
  eof?: SyntaxToken;
70
69
  source: string;
71
70
  }, id: SyntaxNodeId, filepath: Filepath);
72
71
  get declarations(): ElementDeclarationNode[];
73
72
  get uses(): UseDeclarationNode[];
74
- get metadata(): MetadataDeclarationNode[];
75
73
  }
76
74
  export declare class UseDeclarationNode extends SyntaxNode {
77
75
  useKeyword?: SyntaxToken;
@@ -88,13 +86,11 @@ export declare class UseDeclarationNode extends SyntaxNode {
88
86
  }
89
87
  export declare class UseSpecifierNode extends SyntaxNode {
90
88
  importKind?: SyntaxToken;
91
- subKind?: SyntaxToken;
92
89
  name?: NormalExpressionNode;
93
90
  asKeyword?: SyntaxToken;
94
91
  alias?: NormalExpressionNode;
95
- constructor({ importKind, subKind, name, asKeyword, alias, }: {
92
+ constructor({ importKind, name, asKeyword, alias, }: {
96
93
  importKind?: SyntaxToken;
97
- subKind?: SyntaxToken;
98
94
  name?: NormalExpressionNode;
99
95
  asKeyword?: SyntaxToken;
100
96
  alias?: NormalExpressionNode;
@@ -112,21 +108,6 @@ export declare class UseSpecifierListNode extends SyntaxNode {
112
108
  closeBrace?: SyntaxToken;
113
109
  }, id: SyntaxNodeId, filepath: Filepath);
114
110
  }
115
- export declare class MetadataDeclarationNode extends SyntaxNode {
116
- metadataKeyword?: SyntaxToken;
117
- targetKind?: SyntaxToken;
118
- targetName?: NormalExpressionNode;
119
- bodyColon?: SyntaxToken;
120
- body?: FunctionApplicationNode | BlockExpressionNode;
121
- constructor({ metadataKeyword, targetKind, targetName, bodyColon, body, }: {
122
- metadataKeyword?: SyntaxToken;
123
- targetKind?: SyntaxToken;
124
- targetName?: NormalExpressionNode;
125
- bodyColon?: SyntaxToken;
126
- body?: BlockExpressionNode | FunctionApplicationNode;
127
- }, id: SyntaxNodeId, filepath: Filepath);
128
- getTargetKind(): MetadataTargetKind | undefined;
129
- }
130
111
  export declare class ElementDeclarationNode extends SyntaxNode {
131
112
  type?: SyntaxToken;
132
113
  name?: NormalExpressionNode;
@@ -144,17 +125,8 @@ export declare class ElementDeclarationNode extends SyntaxNode {
144
125
  bodyColon?: SyntaxToken;
145
126
  body?: BlockExpressionNode | FunctionApplicationNode;
146
127
  }, id: SyntaxNodeId, filepath: Filepath);
147
- isKind<T extends ElementKind>(...kinds: T[]): this is ElementDeclarationNode & {
148
- type: {
149
- value: T;
150
- };
151
- };
152
- getElementKind<T extends ElementKind>(this: ElementDeclarationNode & {
153
- type: {
154
- value: T;
155
- };
156
- }): T;
157
- getElementKind(this: ElementDeclarationNode): ElementKind | undefined;
128
+ isKind(...kinds: ElementKind[]): boolean;
129
+ getElementKind(): ElementKind | undefined;
158
130
  }
159
131
  export declare class IdentifierStreamNode extends SyntaxNode {
160
132
  identifiers: SyntaxToken[];
@@ -66,7 +66,6 @@ export interface Database {
66
66
  records: TableRecord[];
67
67
  externals: DatabaseExternals;
68
68
  diagramViews: DiagramView[];
69
- metadataElements: MetadataElement[];
70
69
  token?: TokenPosition;
71
70
  }
72
71
  export interface MasterDatabase {
@@ -239,16 +238,6 @@ export interface TableRecord {
239
238
  values: RecordValue[][];
240
239
  token: TokenPosition;
241
240
  }
242
- export interface MetadataElement {
243
- target: {
244
- kind: string;
245
- name: string[];
246
- };
247
- values: {
248
- [key: string]: unknown;
249
- };
250
- token: TokenPosition;
251
- }
252
241
  export type Project = Record<string, never> | {
253
242
  name: string | null;
254
243
  tables: Table[];
@@ -263,4 +252,4 @@ export type Project = Record<string, never> | {
263
252
  token: TokenPosition;
264
253
  [index: string & Omit<any, 'name' | 'tables' | 'refs' | 'enums' | 'tableGroups' | 'note' | 'tablePartials' | 'records'>]: string;
265
254
  };
266
- export type SchemaElement = Database | Project | Table | Note | Column | ColumnType | Index | Check | InlineRef | Ref | RefEndpoint | Enum | EnumField | TableGroup | TableGroupField | Alias | TablePartial | TablePartialInjection | TableRecord | RecordValue | MetadataElement;
255
+ export type SchemaElement = Database | Project | Table | Note | Column | ColumnType | Index | Check | InlineRef | Ref | RefEndpoint | Enum | EnumField | TableGroup | TableGroupField | Alias | TablePartial | TablePartialInjection | TableRecord | RecordValue;
@@ -1,5 +1,5 @@
1
1
  import { default as Compiler } from '../../../compiler';
2
- import { AttributeNode, ElementDeclarationNode, MetadataDeclarationNode, SyntaxNode } from '../nodes';
2
+ import { AttributeNode, ElementDeclarationNode, SyntaxNode } from '../nodes';
3
3
  import { ColumnSymbol, NodeSymbol, TablePartialSymbol, TableSymbol } from '../symbol';
4
4
  import { Internable } from '../internable';
5
5
  export declare enum MetadataKind {
@@ -8,8 +8,7 @@ export declare enum MetadataKind {
8
8
  TableChecks = "table checks",
9
9
  Indexes = "indexes",
10
10
  Records = "records",
11
- Project = "project",
12
- MetadataElement = "metadata element"
11
+ Project = "project"
13
12
  }
14
13
  declare const __nodeMetadataBrand: unique symbol;
15
14
  export type NodeMetadataId = number & {
@@ -27,7 +26,6 @@ export declare abstract class NodeMetadata implements Internable<InternedNodeMet
27
26
  constructor(declaration: SyntaxNode);
28
27
  intern(): InternedNodeMetadata;
29
28
  abstract owners(compiler: Compiler): NodeSymbol[];
30
- reachableOwners(compiler: Compiler, targets: NodeSymbol[]): NodeSymbol[];
31
29
  }
32
30
  export declare class RefMetadata extends NodeMetadata {
33
31
  declaration: ElementDeclarationNode | AttributeNode;
@@ -75,13 +73,6 @@ export declare class RecordsMetadata extends NodeMetadata {
75
73
  table(compiler: Compiler): TableSymbol | undefined;
76
74
  owners(compiler: Compiler): NodeSymbol[];
77
75
  }
78
- export declare class MetadataElementMetadata extends NodeMetadata {
79
- declaration: MetadataDeclarationNode;
80
- readonly kind = MetadataKind.MetadataElement;
81
- constructor(declaration: MetadataDeclarationNode);
82
- target(compiler: Compiler): NodeSymbol | undefined;
83
- owners(compiler: Compiler): NodeSymbol[];
84
- }
85
76
  export declare class ProjectMetadata extends NodeMetadata {
86
77
  readonly kind = MetadataKind.Project;
87
78
  constructor(declaration: SyntaxNode);
@@ -24,7 +24,6 @@ export declare enum SymbolKind {
24
24
  DiagramViewTableGroup = "DiagramView tablegroup",
25
25
  DiagramViewNote = "DiagramView note",
26
26
  DiagramViewSchema = "DiagramView schema",
27
- Metadata = "Metadata",
28
27
  Program = "Program"
29
28
  }
30
29
  export declare const ImportKind: {
@@ -34,17 +33,8 @@ export declare const ImportKind: {
34
33
  TablePartial: SymbolKind;
35
34
  Note: SymbolKind;
36
35
  Schema: SymbolKind;
37
- Metadata: SymbolKind;
38
36
  };
39
37
  export type ImportKind = (typeof ImportKind)[keyof typeof ImportKind];
40
- export declare enum MetadataTargetKind {
41
- Table = "table",
42
- Schema = "schema",
43
- Column = "column",
44
- TableGroup = "tablegroup",
45
- Note = "note"
46
- }
47
- export declare const ALLOWED_METADATA_TARGET_KINDS: readonly MetadataTargetKind[];
48
38
  declare const __nodeSymbolBrand: unique symbol;
49
39
  export type NodeSymbolId = number & {
50
40
  readonly [__nodeSymbolBrand]: true;
@@ -1,4 +1,4 @@
1
- import { ElementDeclarationNode, MetadataDeclarationNode, SyntaxNode } from '../types/nodes';
1
+ import { ElementDeclarationNode, SyntaxNode } from '../types/nodes';
2
2
  import { SyntaxToken } from '../types/tokens';
3
3
  export declare function isOffsetWithinSpan(offset: number, nodeOrToken: SyntaxNode | SyntaxToken): boolean;
4
- export declare function isOffsetWithinElementHeader(offset: number, element: ElementDeclarationNode | MetadataDeclarationNode): boolean;
4
+ export declare function isOffsetWithinElementHeader(offset: number, element: ElementDeclarationNode): boolean;
@@ -6,9 +6,6 @@ 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
- };
12
9
  export declare function isFromKeyword(token?: SyntaxToken): token is SyntaxToken & {
13
10
  kind: SyntaxTokenKind.IDENTIFIER;
14
11
  };
@@ -84,11 +84,7 @@ type DotDelimitedIdentifier = PrimaryExpressionNode | (AccessExpression & {
84
84
  });
85
85
  export declare function isAccessExpression(node?: SyntaxNode): node is AccessExpression;
86
86
  export declare function isDotDelimitedIdentifier(node?: SyntaxNode): node is DotDelimitedIdentifier;
87
- export declare function isElementNode<T extends ElementKind>(node: SyntaxNode | undefined, kind: T): node is ElementDeclarationNode & {
88
- type: {
89
- value: T;
90
- };
91
- };
87
+ export declare function isElementNode(node: SyntaxNode | undefined, kind: ElementKind): node is ElementDeclarationNode;
92
88
  export declare function isUseDeclaration(node: SyntaxNode): node is UseDeclarationNode;
93
89
  export declare function isUseSpecifier(node: SyntaxNode, kind?: ImportKind): node is UseSpecifierNode;
94
90
  export declare function isWildcardSpecifier(node: SyntaxNode): node is WildcardNode;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package",
3
3
  "name": "@dbml/parse",
4
- "version": "8.3.1-custom-metadata.0",
4
+ "version": "8.3.1",
5
5
  "description": "DBML parser v2",
6
6
  "author": "Holistics <dev@holistics.io>",
7
7
  "license": "Apache-2.0",
@@ -50,5 +50,5 @@
50
50
  "engines": {
51
51
  "node": ">=18"
52
52
  },
53
- "gitHead": "cca14935200249a97ec9575cbbe16f5d491c4fc4"
53
+ "gitHead": "b062d22d3608d8bb2969051721237cf5de28e069"
54
54
  }
@@ -1,11 +0,0 @@
1
- import { default as Compiler } from '../../../compiler';
2
- import { CompileError } from '../../types';
3
- import { MetadataDeclarationNode } from '../../types/nodes';
4
- export default class MetadataBinder {
5
- private compiler;
6
- private declarationNode;
7
- constructor(compiler: Compiler, declarationNode: MetadataDeclarationNode);
8
- bind(): CompileError[];
9
- private bindTargetElement;
10
- private bindBody;
11
- }
@@ -1,2 +0,0 @@
1
- import { GlobalModule } from '../types';
2
- export declare const metadataModule: GlobalModule;
@@ -1,17 +0,0 @@
1
- import { default as Compiler } from '../../../compiler';
2
- import { Filepath } from '../../types';
3
- import { MetadataElementMetadata } from '../../types/symbol/metadata';
4
- import { SyntaxNode } from '../../types/nodes';
5
- import { default as Report } from '../../types/report';
6
- import { Color, MetadataElement } from '../../types/schemaJson';
7
- export declare function extractValue(node?: SyntaxNode): string | number | boolean | Color | undefined;
8
- export default class MetadataInterpreter {
9
- private declarationNode;
10
- private compiler;
11
- private filepath;
12
- private metadata;
13
- constructor(compiler: Compiler, metadata: MetadataElementMetadata, filepath: Filepath);
14
- interpret(): Report<MetadataElement>;
15
- private interpretTarget;
16
- private interpretValues;
17
- }
@@ -1,4 +0,0 @@
1
- import { default as Compiler } from '../../../compiler/index';
2
- import { MetadataDeclarationNode } from '../../types/nodes';
3
- import { NodeSymbol } from '../../types/symbol';
4
- export declare function resolveMetadataTarget(compiler: Compiler, metadataNode: MetadataDeclarationNode): NodeSymbol | undefined;
@@ -1,2 +0,0 @@
1
- import { LocalModule } from '../types';
2
- export declare const metadataModule: LocalModule;
@@ -1,14 +0,0 @@
1
- import { default as Compiler } from '../../../compiler';
2
- import { CompileError } from '../../types/errors';
3
- import { MetadataDeclarationNode } from '../../types/nodes';
4
- export default class MetadataValidator {
5
- private compiler;
6
- private declarationNode;
7
- constructor(compiler: Compiler, declarationNode: MetadataDeclarationNode);
8
- validate(): CompileError[];
9
- private validateTargetKind;
10
- private validateTargetName;
11
- private validateBody;
12
- private validateFields;
13
- private validateSubElements;
14
- }