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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,8 +3,14 @@ import { Filepath } from '../../types';
3
3
  import { MetadataElementMetadata } from '../../types/symbol/metadata';
4
4
  import { SyntaxNode } from '../../types/nodes';
5
5
  import { default as Report } from '../../types/report';
6
- import { Color, MetadataElement } from '../../types/schemaJson';
6
+ import { Color, CustomMetadata, MetadataElement } from '../../types/schemaJson';
7
+ import { Settings } from '../../utils/validate';
7
8
  export declare function extractValue(node?: SyntaxNode): string | number | boolean | Color | undefined;
9
+ export declare const TABLE_BUILTIN_SETTINGS: readonly ["headercolor", "note"];
10
+ export declare const TABLEGROUP_BUILTIN_SETTINGS: readonly ["color", "note"];
11
+ export declare const NOTE_BUILTIN_SETTINGS: readonly ["color"];
12
+ export declare const COLUMN_BUILTIN_SETTINGS: readonly ["pk", "primary key", "unique", "note", "ref", "default", "check", "increment", "not null", "null"];
13
+ export declare function extractInlineMetadata(settingMap: Settings, builtinSettingNames: readonly string[]): CustomMetadata;
8
14
  export default class MetadataInterpreter {
9
15
  private declarationNode;
10
16
  private compiler;
@@ -0,0 +1,14 @@
1
+ import { MetadataTargetKind } from '../../types/symbol';
2
+ export declare enum OverlapValueKind {
3
+ Note = "note",
4
+ Color = "color",
5
+ HeaderColor = "headercolor"
6
+ }
7
+ export type OverlapInlineField = 'note' | 'color' | 'headerColor';
8
+ export interface OverlapKey {
9
+ metaKey: string;
10
+ field: OverlapInlineField;
11
+ reshape: OverlapValueKind;
12
+ }
13
+ export declare const OVERLAP_KEYS: Partial<Record<MetadataTargetKind, OverlapKey[]>>;
14
+ export declare function findOverlapKey(kind: MetadataTargetKind | undefined, key: string): OverlapKey | undefined;
@@ -11,13 +11,17 @@ export default class ProgramInterpreter {
11
11
  private errors;
12
12
  private warnings;
13
13
  private db;
14
+ private emittedBySymbol;
14
15
  constructor(compiler: Compiler, symbol: ProgramSymbol, filepath: Filepath);
15
16
  interpret(): Report<SchemaElement | SchemaElement[] | undefined>;
16
17
  private interpretAllSymbols;
17
18
  private interpretUseSymbol;
18
19
  private interpretAllMetadata;
20
+ private promoteOverlapKeys;
21
+ private attachMetadata;
19
22
  private interpretAllAliases;
20
23
  private validateRecords;
21
24
  private collectPartialRefs;
22
25
  private pushElement;
26
+ private recordEmitted;
23
27
  }
@@ -118,8 +118,7 @@ export declare enum CompileErrorCode {
118
118
  INVALID_METADATA_TARGET_KIND = 5007,
119
119
  INVALID_METADATA_FIELD = 5008,
120
120
  DUPLICATE_METADATA_FIELD = 5009,
121
- METADATA_TARGET_NOT_FOUND = 5010,
122
- DUPLICATE_METADATA_KEY_ACROSS_BLOCKS = 5011
121
+ METADATA_TARGET_NOT_FOUND = 5010
123
122
  }
124
123
  export declare class CompileError extends Error {
125
124
  code: Readonly<CompileErrorCode>;
@@ -1,6 +1,7 @@
1
1
  import { NONE_COLOR } from '../../constants';
2
2
  import { Filepath } from './filepath';
3
3
  import { Position } from './position';
4
+ export type CustomMetadata = Record<string, unknown>;
4
5
  export type Color = `#${string}` | typeof NONE_COLOR;
5
6
  export declare enum AliasKind {
6
7
  Table = "table"
@@ -66,7 +67,6 @@ export interface Database {
66
67
  records: TableRecord[];
67
68
  externals: DatabaseExternals;
68
69
  diagramViews: DiagramView[];
69
- metadataElements: MetadataElement[];
70
70
  token?: TokenPosition;
71
71
  }
72
72
  export interface MasterDatabase {
@@ -86,12 +86,14 @@ export interface Table {
86
86
  value: string;
87
87
  token: TokenPosition;
88
88
  };
89
+ metadata?: CustomMetadata;
89
90
  }
90
91
  export interface Note {
91
92
  name: string;
92
93
  content: string;
93
94
  token: TokenPosition;
94
95
  color?: Color;
96
+ metadata?: CustomMetadata;
95
97
  }
96
98
  export interface ColumnType {
97
99
  schemaName: string | null;
@@ -124,6 +126,7 @@ export interface Column {
124
126
  value: string;
125
127
  token: TokenPosition;
126
128
  };
129
+ metadata?: CustomMetadata;
127
130
  }
128
131
  export interface Index {
129
132
  columns: {
@@ -196,6 +199,7 @@ export interface TableGroup {
196
199
  value: string;
197
200
  token: TokenPosition;
198
201
  };
202
+ metadata?: CustomMetadata;
199
203
  }
200
204
  export interface TableGroupField {
201
205
  name: string;
@@ -244,9 +248,8 @@ export interface MetadataElement {
244
248
  kind: string;
245
249
  name: string[];
246
250
  };
247
- values: {
248
- [key: string]: unknown;
249
- };
251
+ values: CustomMetadata;
252
+ valueTokens: Record<string, TokenPosition>;
250
253
  token: TokenPosition;
251
254
  }
252
255
  export type Project = Record<string, never> | {
@@ -8,7 +8,7 @@ export declare function extractElementName(nameNode: SyntaxNode): {
8
8
  schemaName: string[];
9
9
  name: string;
10
10
  };
11
- export declare function extractColor(node: unknown): Color | undefined;
11
+ export declare function extractColor(node?: SyntaxNode): Color | undefined;
12
12
  export declare function processDefaultValue(valueNode?: SyntaxNode): {
13
13
  type: 'number' | 'string' | 'boolean' | 'expression';
14
14
  value: string | number;
@@ -1,3 +1,4 @@
1
+ import { CompileError, CompileErrorCode } from '../types/errors';
1
2
  import { AttributeNode, BlockExpressionNode, ElementDeclarationNode, FunctionApplicationNode, FunctionExpressionNode, InfixExpressionNode, ListExpressionNode, LiteralNode, PrefixExpressionNode, PrimaryExpressionNode, ProgramNode, SyntaxNode, TupleExpressionNode, UseDeclarationNode, UseSpecifierNode, VariableNode, WildcardNode } from '../types/nodes';
2
3
  import { default as Report } from '../types/report';
3
4
  import { SyntaxToken, SyntaxTokenKind } from '../types/tokens';
@@ -24,7 +25,14 @@ export declare function isValidPartialInjection(node?: SyntaxNode): node is Pref
24
25
  };
25
26
  };
26
27
  export declare function isRelationshipOp(op?: string): boolean;
27
- export declare function isValidColor(value?: SyntaxNode): boolean;
28
+ export declare function isValidHexColor(value?: SyntaxNode): value is PrimaryExpressionNode & {
29
+ expression: LiteralNode & {
30
+ literal: {
31
+ kind: SyntaxTokenKind.COLOR_LITERAL;
32
+ };
33
+ };
34
+ };
35
+ export declare function isValidColorOrNone(value?: SyntaxNode): boolean;
28
36
  export declare function isValidDefaultValue(value?: SyntaxNode): boolean;
29
37
  export type SignedNumberExpression = (PrimaryExpressionNode & {
30
38
  expression: LiteralNode & {
@@ -45,6 +53,11 @@ export declare function isTupleOfVariables(value?: SyntaxNode): value is TupleEx
45
53
  };
46
54
  export declare function isValidColumnType(type: SyntaxNode): boolean;
47
55
  export type Settings = Record<SettingName | string, AttributeNode[]>;
56
+ export declare function isValidMetadataValue(value?: SyntaxNode): boolean;
57
+ export declare function validateInlineMetadataSetting(name: string, attrs: AttributeNode[], codes: {
58
+ duplicate: CompileErrorCode;
59
+ invalidValue: CompileErrorCode;
60
+ }): CompileError[];
48
61
  export declare function aggregateSettingList(settingList?: ListExpressionNode): Report<Settings>;
49
62
  export declare function isExpressionAQuotedString(value?: unknown): value is PrimaryExpressionNode & ({
50
63
  expression: VariableNode & {
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-custom-metadata.1",
5
5
  "description": "DBML parser v2",
6
6
  "author": "Holistics <dev@holistics.io>",
7
7
  "license": "Apache-2.0",
@@ -50,5 +50,5 @@
50
50
  "engines": {
51
51
  "node": ">=18"
52
52
  },
53
- "gitHead": "cca14935200249a97ec9575cbbe16f5d491c4fc4"
53
+ "gitHead": "152988f537ab87a9d8320bd41b478495c1acbb0c"
54
54
  }