@dbml/parse 8.2.4 → 8.2.6-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.
- package/dist/__benchmarks__/compiler.benchmark.d.ts +1 -0
- package/dist/__benchmarks__/compiler.profile.d.ts +1 -0
- package/dist/dbml-parse.js +18 -21
- package/dist/dbml-parse.mjs +10483 -10121
- package/dist/src/compiler/index.d.ts +2 -0
- package/dist/src/compiler/queries/symbol/lookupMembers.d.ts +1 -0
- package/dist/src/compiler/queries/transform/syncDiagramView.d.ts +2 -6
- package/dist/src/constants.d.ts +1 -0
- package/dist/src/core/local_modules/note/validate.d.ts +1 -0
- package/dist/src/core/types/errors.d.ts +45 -42
- package/dist/src/core/types/report.d.ts +3 -3
- package/dist/src/core/types/schemaJson.d.ts +7 -5
- package/dist/src/core/utils/interpret.d.ts +2 -2
- package/package.json +8 -4
|
@@ -20,6 +20,7 @@ export default class Compiler {
|
|
|
20
20
|
private entrypointsSnapshot;
|
|
21
21
|
private cleanStaleGlobalCache;
|
|
22
22
|
private globalCache;
|
|
23
|
+
private globallyQuerying;
|
|
23
24
|
private globalQuery;
|
|
24
25
|
private localCache;
|
|
25
26
|
private localQuery;
|
|
@@ -41,6 +42,7 @@ export default class Compiler {
|
|
|
41
42
|
nodeSymbol: (node: SyntaxNode) => import('../core/types/report').default<typeof import('..').UNHANDLED> | import('../core/types/report').default<import('../core/types/symbol').NodeSymbol>;
|
|
42
43
|
nodeMetadata: (node: SyntaxNode) => import('../core/types/report').default<typeof import('..').UNHANDLED> | import('../core/types/report').default<import('../core/types/symbol').NodeMetadata>;
|
|
43
44
|
symbolMembers: (symbol: import('../core/types/symbol').NodeSymbol) => import('../core/types/report').default<typeof import('..').UNHANDLED> | import('../core/types/report').default<import('../core/types/symbol').NodeSymbol[]>;
|
|
45
|
+
symbolMembersLookupMap: (symbol: import('../core/types/symbol').NodeSymbol) => Map<string, import('../core/types/symbol').NodeSymbol[]>;
|
|
44
46
|
lookupMembers: (symbolOrNode: import('../core/types/symbol').NodeSymbol | SyntaxNode, targetKinds: import('../core/types/symbol').SymbolKind | import('../core/types/symbol').SymbolKind[], targetName: string) => import('../core/types/symbol').NodeSymbol | undefined;
|
|
45
47
|
nodeReferee: (node: SyntaxNode) => import('../core/types/report').default<typeof import('..').UNHANDLED> | import('../core/types/report').default<import('../core/types/symbol').NodeSymbol | undefined>;
|
|
46
48
|
resolutionIndex: () => import('./queries/resolutionIndex').ResolutionIndex;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { SyntaxNode } from '../../../core/types/nodes';
|
|
2
2
|
import { NodeSymbol, SymbolKind } from '../../../core/types/symbol';
|
|
3
3
|
import { default as Compiler } from '../../index';
|
|
4
|
+
export declare function symbolMembersLookupMap(this: Compiler, symbol: NodeSymbol): Map<string, NodeSymbol[]>;
|
|
4
5
|
export declare function lookupMembers(this: Compiler, symbolOrNode: NodeSymbol | SyntaxNode, targetKinds: SymbolKind | SymbolKind[], targetName: string): NodeSymbol | undefined;
|
|
@@ -27,12 +27,8 @@ export interface DiagramViewBlock {
|
|
|
27
27
|
endIndex: number;
|
|
28
28
|
}
|
|
29
29
|
/**
|
|
30
|
-
* Returns the
|
|
31
|
-
*
|
|
32
|
-
* Returns an empty array on any lex or parse error - callers cannot
|
|
33
|
-
* distinguish "no DiagramView blocks present" from "malformed DBML" based on
|
|
34
|
-
* the return value alone. If you need to detect malformed input, lex/parse
|
|
35
|
-
* the source separately and check for errors before calling this function.
|
|
30
|
+
* Returns the position of every DiagramView block in `source`
|
|
31
|
+
* Note that onany lex or parse errors, we return [], as there's no reliable way to detect diagram views from malformed DBML
|
|
36
32
|
*/
|
|
37
33
|
export declare function findDiagramViewBlocks(source: string): DiagramViewBlock[];
|
|
38
34
|
/**
|
package/dist/src/constants.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Filepath } from './core/types/filepath';
|
|
2
2
|
export declare const KEYWORDS_OF_DEFAULT_SETTING: readonly string[];
|
|
3
|
+
export declare const NONE_COLOR: "none";
|
|
3
4
|
export declare const DBML_EXT = ".dbml";
|
|
4
5
|
export declare const NUMERIC_LITERAL_PREFIX: readonly string[];
|
|
5
6
|
export declare const DEFAULT_SCHEMA_NAME: "public";
|
|
@@ -9,6 +9,7 @@ export default class NoteValidator {
|
|
|
9
9
|
private validateContext;
|
|
10
10
|
private validateName;
|
|
11
11
|
private validateAlias;
|
|
12
|
+
private isStickyNote;
|
|
12
13
|
private validateSettingList;
|
|
13
14
|
validateBody(body?: FunctionApplicationNode | BlockExpressionNode): CompileError[];
|
|
14
15
|
validateFields(fields: FunctionApplicationNode[]): CompileError[];
|
|
@@ -61,48 +61,51 @@ export declare enum CompileErrorCode {
|
|
|
61
61
|
NOTE_REDEFINED = 3044,
|
|
62
62
|
NOTE_CONTENT_REDEFINED = 3045,
|
|
63
63
|
EMPTY_NOTE = 3046,
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
64
|
+
UNKNOWN_NOTE_SETTING = 3047,
|
|
65
|
+
DUPLICATE_NOTE_SETTING = 3048,
|
|
66
|
+
INVALID_NOTE_SETTING_VALUE = 3049,
|
|
67
|
+
INVALID_INDEXES_CONTEXT = 3050,
|
|
68
|
+
INVALID_INDEXES_FIELD = 3051,
|
|
69
|
+
INVALID_INDEX = 3052,
|
|
70
|
+
UNKNOWN_INDEX_SETTING = 3053,
|
|
71
|
+
DUPLICATE_INDEX_SETTING = 3054,
|
|
72
|
+
UNEXPECTED_INDEX_SETTING_VALUE = 3055,
|
|
73
|
+
INVALID_INDEX_SETTING_VALUE = 3056,
|
|
74
|
+
INVALID_PROJECT_CONTEXT = 3057,
|
|
75
|
+
PROJECT_REDEFINED = 3058,
|
|
76
|
+
INVALID_PROJECT_FIELD = 3059,
|
|
77
|
+
INVALID_CUSTOM_CONTEXT = 3060,
|
|
78
|
+
INVALID_CUSTOM_ELEMENT_VALUE = 3061,
|
|
79
|
+
INVALID_ELEMENT_IN_SIMPLE_BODY = 3062,
|
|
80
|
+
INVALID_TABLE_PARTIAL_CONTEXT = 3063,
|
|
81
|
+
INVALID_TABLE_PARTIAL_ELEMENT_NAME = 3064,
|
|
82
|
+
INVALID_TABLE_PARTIAL_SETTING_VALUE = 3065,
|
|
83
|
+
DUPLICATE_TABLE_PARTIAL_ELEMENT_NAME = 3066,
|
|
84
|
+
DUPLICATE_TABLE_PARTIAL_SETTING = 3067,
|
|
85
|
+
INVALID_TABLE_PARTIAL_INJECTION = 3068,
|
|
86
|
+
INVALID_TABLE_PARTIAL_INJECTION_OP = 3069,
|
|
87
|
+
INVALID_TABLE_PARTIAL_INJECTION_NAME = 3070,
|
|
88
|
+
DUPLICATE_TABLE_PARTIAL_INJECTION_NAME = 3071,
|
|
89
|
+
UNKNOWN_TABLE_PARTIAL_SETTING = 3072,
|
|
90
|
+
INVALID_TABLE_SETTING_VALUE = 3073,
|
|
91
|
+
INVALID_CHECKS_CONTEXT = 3074,
|
|
92
|
+
INVALID_CHECKS_FIELD = 3075,
|
|
93
|
+
INVALID_CHECK = 3076,
|
|
94
|
+
UNKNOWN_CHECK_SETTING = 3077,
|
|
95
|
+
DUPLICATE_CHECK_SETTING = 3078,
|
|
96
|
+
INVALID_CHECK_SETTING_VALUE = 3079,
|
|
97
|
+
INVALID_RECORDS_CONTEXT = 3080,
|
|
98
|
+
INVALID_RECORDS_NAME = 3081,
|
|
99
|
+
INVALID_RECORDS_FIELD = 3082,
|
|
100
|
+
DUPLICATE_COLUMN_REFERENCES_IN_RECORDS = 3083,
|
|
101
|
+
DUPLICATE_RECORDS_FOR_TABLE = 3084,
|
|
102
|
+
INVALID_USE_CONTEXT = 3085,
|
|
103
|
+
INVALID_USE_SPECIFIER_KIND = 3086,
|
|
104
|
+
INVALID_USE_SPECIFIER_NAME = 3087,
|
|
105
|
+
INVALID_DIAGRAMVIEW_CONTEXT = 3088,
|
|
106
|
+
DUPLICATE_DIAGRAMVIEW_NAME = 3089,
|
|
107
|
+
INVALID_DIAGRAMVIEW_FIELD = 3090,
|
|
108
|
+
DUPLICATE_DIAGRAMVIEW_FIELD = 3091,
|
|
106
109
|
BINDING_ERROR = 4000,
|
|
107
110
|
NONEXISTENT_MODULE = 4001,
|
|
108
111
|
UNSUPPORTED = 5000,
|
|
@@ -7,12 +7,12 @@ export default class Report<T> {
|
|
|
7
7
|
constructor(value: T, errors?: CompileError[], warnings?: CompileWarning[]);
|
|
8
8
|
filter<S extends symbol>(filteredValue: S): Report<undefined | Exclude<T, S>>;
|
|
9
9
|
hasValue<S>(value: S): this is Report<S>;
|
|
10
|
-
getFiltered<S extends symbol | undefined | null>(
|
|
10
|
+
getFiltered<S extends symbol | undefined | null>(filteredValue: S): Exclude<T, S> | undefined;
|
|
11
11
|
getValue(): T;
|
|
12
12
|
getErrors(): CompileError[];
|
|
13
13
|
getWarnings(): CompileWarning[];
|
|
14
|
-
chainFiltered<S extends symbol | undefined | null, U>(fn: (_: Exclude<T, S>) => Report<U>,
|
|
14
|
+
chainFiltered<S extends symbol | undefined | null, U>(fn: (_: Exclude<T, S>) => Report<U>, filteredValue: S): Report<U | undefined>;
|
|
15
15
|
chain<U>(fn: (_: T) => Report<U>): Report<U>;
|
|
16
|
-
mapFiltered<S extends symbol | undefined | null, U>(fn: (_: Exclude<T, S>) => U,
|
|
16
|
+
mapFiltered<S extends symbol | undefined | null, U>(fn: (_: Exclude<T, S>) => U, filteredValue: S): Report<U | undefined>;
|
|
17
17
|
map<U>(fn: (_: T) => U): Report<U>;
|
|
18
18
|
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { NONE_COLOR } from '../../constants';
|
|
1
2
|
import { Filepath } from './filepath';
|
|
2
3
|
import { Position } from './position';
|
|
4
|
+
export type Color = `#${string}` | typeof NONE_COLOR;
|
|
3
5
|
export declare enum AliasKind {
|
|
4
6
|
Table = "table"
|
|
5
7
|
}
|
|
@@ -78,7 +80,7 @@ export interface Table {
|
|
|
78
80
|
partials: TablePartialInjection[];
|
|
79
81
|
token: TokenPosition;
|
|
80
82
|
indexes: Index[];
|
|
81
|
-
headerColor?:
|
|
83
|
+
headerColor?: Color;
|
|
82
84
|
note?: {
|
|
83
85
|
value: string;
|
|
84
86
|
token: TokenPosition;
|
|
@@ -88,7 +90,7 @@ export interface Note {
|
|
|
88
90
|
name: string;
|
|
89
91
|
content: string;
|
|
90
92
|
token: TokenPosition;
|
|
91
|
-
|
|
93
|
+
color?: Color;
|
|
92
94
|
}
|
|
93
95
|
export interface ColumnType {
|
|
94
96
|
schemaName: string | null;
|
|
@@ -154,7 +156,7 @@ export interface Ref {
|
|
|
154
156
|
schemaName: string | null;
|
|
155
157
|
name: string | null;
|
|
156
158
|
endpoints: RefEndpointPair;
|
|
157
|
-
color?:
|
|
159
|
+
color?: Color;
|
|
158
160
|
onDelete?: string;
|
|
159
161
|
onUpdate?: string;
|
|
160
162
|
inactive?: boolean;
|
|
@@ -188,7 +190,7 @@ export interface TableGroup {
|
|
|
188
190
|
schemaName: string | null;
|
|
189
191
|
tables: TableGroupField[];
|
|
190
192
|
token: TokenPosition;
|
|
191
|
-
color?:
|
|
193
|
+
color?: Color;
|
|
192
194
|
note?: {
|
|
193
195
|
value: string;
|
|
194
196
|
token: TokenPosition;
|
|
@@ -212,7 +214,7 @@ export interface TablePartial {
|
|
|
212
214
|
token: TokenPosition;
|
|
213
215
|
indexes: Index[];
|
|
214
216
|
checks: Check[];
|
|
215
|
-
headerColor?:
|
|
217
|
+
headerColor?: Color;
|
|
216
218
|
note?: {
|
|
217
219
|
value: string;
|
|
218
220
|
token: TokenPosition;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { default as Compiler } from '../../compiler';
|
|
2
|
-
import { ColumnType, TokenPosition } from '../types/schemaJson';
|
|
2
|
+
import { Color, ColumnType, TokenPosition } from '../types/schemaJson';
|
|
3
3
|
import { SyntaxNode } from '../types/nodes';
|
|
4
4
|
import { default as Report } from '../types/report';
|
|
5
5
|
export declare function getTokenPosition(node: SyntaxNode): TokenPosition;
|
|
@@ -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):
|
|
11
|
+
export declare function extractColor(node: unknown): Color | undefined;
|
|
12
12
|
export declare function processDefaultValue(valueNode?: SyntaxNode): {
|
|
13
13
|
type: 'number' | 'string' | 'boolean' | 'expression';
|
|
14
14
|
value: string | number;
|
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.2.
|
|
4
|
+
"version": "8.2.6-alpha.0",
|
|
5
5
|
"description": "DBML parser v2",
|
|
6
6
|
"author": "Holistics <dev@holistics.io>",
|
|
7
7
|
"license": "Apache-2.0",
|
|
@@ -32,11 +32,15 @@
|
|
|
32
32
|
"coverage": "vitest run --coverage",
|
|
33
33
|
"prepare": "npm run build",
|
|
34
34
|
"lint": "eslint .",
|
|
35
|
-
"lint:fix": "eslint --fix ."
|
|
35
|
+
"lint:fix": "eslint --fix .",
|
|
36
|
+
"bench": "npx tsx __benchmarks__/compiler.benchmark.ts",
|
|
37
|
+
"profile:build": "vite build --config vite.profile.config.mts && cp -r __benchmarks__/input dist-profile/input",
|
|
38
|
+
"profile": "yarn profile:build && node --cpu-prof --cpu-prof-dir __benchmarks__/output/ dist-profile/__benchmarks__/compiler.profile.mjs"
|
|
36
39
|
},
|
|
37
40
|
"devDependencies": {
|
|
38
41
|
"@types/luxon": "^3.7.1",
|
|
39
|
-
"monaco-editor-core": "^0.44.0"
|
|
42
|
+
"monaco-editor-core": "^0.44.0",
|
|
43
|
+
"vite-plugin-no-bundle": "^4.0.0"
|
|
40
44
|
},
|
|
41
45
|
"dependencies": {
|
|
42
46
|
"lodash-es": "^4.18.1",
|
|
@@ -46,5 +50,5 @@
|
|
|
46
50
|
"engines": {
|
|
47
51
|
"node": ">=18"
|
|
48
52
|
},
|
|
49
|
-
"gitHead": "
|
|
53
|
+
"gitHead": "7fd6ef492c751cda7c583531ddd8052fd8addd67"
|
|
50
54
|
}
|