@dbml/parse 9.0.0-alpha.6 → 9.0.0-alpha.8
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/dbml-parse.js +8 -8
- package/dist/dbml-parse.mjs +224 -220
- package/dist/src/compiler/index.d.ts +6 -8
- package/dist/src/compiler/queries/transform/index.d.ts +2 -1
- package/dist/src/compiler/queries/transform/renameTable.d.ts +2 -2
- package/dist/src/compiler/queries/transform/types.d.ts +48 -0
- package/dist/src/compiler/queries/transform/updateElementSetting.d.ts +4 -0
- package/dist/src/compiler/queries/transform/utils.d.ts +6 -10
- package/dist/src/core/types/errors.d.ts +4 -3
- package/dist/src/core/utils/setting.d.ts +6 -2
- package/dist/src/index.d.ts +3 -0
- package/package.json +2 -2
|
@@ -3,11 +3,10 @@ import { SyntaxNode, SyntaxNodeIdGenerator } from '../core/types/nodes';
|
|
|
3
3
|
import { NodeSymbolIdGenerator, SymbolFactory } from '../core/types/symbol';
|
|
4
4
|
import { DBMLCompletionItemProvider, DBMLDefinitionProvider, DBMLDiagnosticsProvider, DBMLReferencesProvider } from '../services/index';
|
|
5
5
|
import { DbmlProjectLayout } from './projectLayout';
|
|
6
|
-
import { DiagramViewBlock, DepBlock, findDiagramViewBlocks, findDepBlocks } from './queries/transform';
|
|
7
6
|
import { addDoubleQuoteIfNeeded, escapeString, formatRecordValue, isValidIdentifier, splitQualifiedIdentifier, unescapeString } from './queries/utils';
|
|
8
7
|
export { ScopeKind } from './types';
|
|
9
|
-
export type {
|
|
10
|
-
export { addDoubleQuoteIfNeeded, escapeString, formatRecordValue, isValidIdentifier, splitQualifiedIdentifier, unescapeString,
|
|
8
|
+
export type { TextEdit } from './queries/transform';
|
|
9
|
+
export { addDoubleQuoteIfNeeded, escapeString, formatRecordValue, isValidIdentifier, splitQualifiedIdentifier, unescapeString, };
|
|
11
10
|
export default class Compiler {
|
|
12
11
|
layout: DbmlProjectLayout;
|
|
13
12
|
readonly nodeIdGenerator: SyntaxNodeIdGenerator;
|
|
@@ -72,17 +71,16 @@ export default class Compiler {
|
|
|
72
71
|
};
|
|
73
72
|
}>;
|
|
74
73
|
nodeAtPosition: (filepath: Filepath, offset: number) => SyntaxNode | import('..').SyntaxToken | undefined;
|
|
75
|
-
renameTable: (filepath: Filepath, oldName: import('
|
|
76
|
-
|
|
74
|
+
renameTable: (filepath: Filepath, oldName: string | import('..').TableIdentifier, newName: string | import('..').TableIdentifier) => Map<string, string>;
|
|
75
|
+
updateElementSetting: (filepath: Filepath, target: import('..').ElementIdentifier, settingName: string, value: string | null | undefined) => string;
|
|
76
|
+
syncDiagramView: (filepath: Filepath, operations: import('..').DiagramViewSyncOperation[], blocks?: import('..').DiagramViewBlock[] | undefined) => {
|
|
77
77
|
newDbml: string;
|
|
78
78
|
edits: import('.').TextEdit[];
|
|
79
79
|
};
|
|
80
|
-
|
|
81
|
-
syncDep: (filepath: Filepath, operations: import('..').DepSyncOperation[], blocks?: DepBlock[] | undefined) => {
|
|
80
|
+
syncDep: (filepath: Filepath, operations: import('..').DepSyncOperation[], blocks?: import('..').DepBlock[] | undefined) => {
|
|
82
81
|
newDbml: string;
|
|
83
82
|
edits: import('.').TextEdit[];
|
|
84
83
|
};
|
|
85
|
-
findDepBlocks(filepath: Filepath): DepBlock[];
|
|
86
84
|
readonly token: {
|
|
87
85
|
invalidStream: (filepath: Filepath) => readonly import('..').SyntaxToken[];
|
|
88
86
|
flatStream: (filepath: Filepath) => readonly import('..').SyntaxToken[];
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { renameTable } from './renameTable';
|
|
2
|
+
export { updateElementSetting } from './updateElementSetting';
|
|
2
3
|
export { syncDiagramView, findDiagramViewBlocks, type DiagramViewSyncOperation, type DiagramViewBlock, } from './syncDiagramView';
|
|
3
4
|
export { syncDep, findDepBlocks, generateDepBlock, type DepSyncOperation, type DepSyncEdge, type DepEndpointRef, type DepBlock, } from './syncDep';
|
|
4
5
|
export { applyTextEdits, type TextEdit } from './applyTextEdits';
|
|
5
|
-
export {
|
|
6
|
+
export type { ElementIdentifier, SchemaIdentifier, TableIdentifier, ColumnIdentifier, EnumIdentifier, EndpointRef, RefIdentifier, DepIdentifier, NoteIdentifier, TableGroupIdentifier, } from './types';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Filepath } from '../../../core/types/filepath';
|
|
2
2
|
import { default as Compiler } from '../../index';
|
|
3
|
-
import {
|
|
3
|
+
import { TableIdentifier } from './types';
|
|
4
4
|
/**
|
|
5
5
|
* Renames a table across every file in the project layout.
|
|
6
6
|
*
|
|
@@ -23,4 +23,4 @@ import { TableNameInput } from './utils';
|
|
|
23
23
|
* only the files that were actually changed by the rename. An empty map
|
|
24
24
|
* indicates a no-op (lookup miss, name collision, or alias rename attempt).
|
|
25
25
|
*/
|
|
26
|
-
export declare function renameTable(this: Compiler, filepath: Filepath, oldName:
|
|
26
|
+
export declare function renameTable(this: Compiler, filepath: Filepath, oldName: string | TableIdentifier, newName: string | TableIdentifier): Map<string, string>;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { SymbolKind } from '../../../core/types/symbol';
|
|
2
|
+
import { MetadataKind } from '../../../core/types/symbol/metadata';
|
|
3
|
+
export type ElementIdentifier = (SchemaIdentifier | TableIdentifier | ColumnIdentifier | EnumIdentifier | RefIdentifier | DepIdentifier | NoteIdentifier | TableGroupIdentifier) & {
|
|
4
|
+
kind: string;
|
|
5
|
+
};
|
|
6
|
+
export interface SchemaIdentifier {
|
|
7
|
+
kind?: typeof SymbolKind.Schema;
|
|
8
|
+
schema: string;
|
|
9
|
+
}
|
|
10
|
+
export interface TableIdentifier {
|
|
11
|
+
kind?: typeof SymbolKind.Table;
|
|
12
|
+
schema?: string;
|
|
13
|
+
table: string;
|
|
14
|
+
}
|
|
15
|
+
export interface ColumnIdentifier {
|
|
16
|
+
kind?: typeof SymbolKind.Column;
|
|
17
|
+
schema?: string;
|
|
18
|
+
table: string;
|
|
19
|
+
column: string;
|
|
20
|
+
}
|
|
21
|
+
export interface EnumIdentifier {
|
|
22
|
+
kind?: typeof SymbolKind.Enum;
|
|
23
|
+
schema?: string;
|
|
24
|
+
name: string;
|
|
25
|
+
}
|
|
26
|
+
export interface EndpointRef {
|
|
27
|
+
schema?: string;
|
|
28
|
+
table: string;
|
|
29
|
+
fields?: string[];
|
|
30
|
+
}
|
|
31
|
+
export interface RefIdentifier {
|
|
32
|
+
kind?: typeof MetadataKind.Ref;
|
|
33
|
+
endpoints: [EndpointRef, EndpointRef];
|
|
34
|
+
}
|
|
35
|
+
export interface DepIdentifier {
|
|
36
|
+
kind?: typeof MetadataKind.Dep;
|
|
37
|
+
upstream: EndpointRef;
|
|
38
|
+
downstream: EndpointRef;
|
|
39
|
+
}
|
|
40
|
+
export interface NoteIdentifier {
|
|
41
|
+
kind?: typeof SymbolKind.StickyNote;
|
|
42
|
+
name: string;
|
|
43
|
+
}
|
|
44
|
+
export interface TableGroupIdentifier {
|
|
45
|
+
kind?: typeof SymbolKind.TableGroup;
|
|
46
|
+
schema?: string;
|
|
47
|
+
name: string;
|
|
48
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { Filepath } from '../../../core/types/filepath';
|
|
2
|
+
import { default as Compiler } from '../../index';
|
|
3
|
+
import { ElementIdentifier } from './types';
|
|
4
|
+
export declare function updateElementSetting(this: Compiler, filepath: Filepath, target: ElementIdentifier, settingName: string, value: string | null | undefined): string;
|
|
@@ -1,22 +1,18 @@
|
|
|
1
1
|
import { Filepath } from '../../../core/types/filepath';
|
|
2
|
-
import { NodeSymbol } from '../../../core/types/symbol';
|
|
2
|
+
import { NodeSymbol, SymbolKind } from '../../../core/types/symbol';
|
|
3
3
|
import { default as Compiler } from '../../index';
|
|
4
|
-
export type
|
|
4
|
+
export type { ElementIdentifier } from './types';
|
|
5
|
+
export declare function normalizeTableName(input: string | {
|
|
5
6
|
schema?: string;
|
|
6
7
|
table: string;
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* Normalizes a table name input to { schema, table } format.
|
|
10
|
-
* Properly handles quoted identifiers with dots inside.
|
|
11
|
-
*/
|
|
12
|
-
export declare function normalizeTableName(input: TableNameInput): {
|
|
8
|
+
}): {
|
|
13
9
|
schema: string;
|
|
14
10
|
table: string;
|
|
15
11
|
};
|
|
16
12
|
/**
|
|
17
|
-
* Looks up
|
|
13
|
+
* Looks up an element symbol by its qualified name and kind.
|
|
18
14
|
*/
|
|
19
|
-
export declare function
|
|
15
|
+
export declare function lookupElementSymbol(compiler: Compiler, filepath: Filepath, schema: string, name: string, kind?: SymbolKind): NodeSymbol | null;
|
|
20
16
|
/**
|
|
21
17
|
* Removes surrounding double quotes from a string if present.
|
|
22
18
|
*/
|
|
@@ -113,9 +113,10 @@ export declare enum CompileErrorCode {
|
|
|
113
113
|
UNSUPPORTED = 5000,
|
|
114
114
|
CIRCULAR_REF = 5001,
|
|
115
115
|
SAME_ENDPOINT = 5002,
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
116
|
+
DEP_SELF_LOOP = 5003,
|
|
117
|
+
UNEQUAL_FIELDS_BINARY_REF = 5004,
|
|
118
|
+
CONFLICTING_SETTING = 5005,
|
|
119
|
+
TABLE_REAPPEAR_IN_TABLEGROUP = 5006
|
|
119
120
|
}
|
|
120
121
|
export declare class CompileError extends Error {
|
|
121
122
|
code: Readonly<CompileErrorCode>;
|
|
@@ -7,9 +7,13 @@ import { TextEdit } from '../../compiler/queries/transform/applyTextEdits';
|
|
|
7
7
|
*/
|
|
8
8
|
export declare function addSettingEdit(declaration: SyntaxNode, setting: string): TextEdit | undefined;
|
|
9
9
|
/**
|
|
10
|
-
* Produces a TextEdit that updates
|
|
10
|
+
* Produces a TextEdit that updates a setting's value in a declaration.
|
|
11
|
+
* value: string - update or create with "name: value"
|
|
12
|
+
* value: undefined - name-only setting (e.g. [pk])
|
|
13
|
+
* value: null - remove the setting
|
|
14
|
+
* If the setting does not exist, adds it.
|
|
11
15
|
*/
|
|
12
|
-
export declare function updateSettingEdit(declaration: SyntaxNode, settingName: string,
|
|
16
|
+
export declare function updateSettingEdit(declaration: SyntaxNode, settingName: string, value: string | null | undefined, source: string): TextEdit | undefined;
|
|
13
17
|
/**
|
|
14
18
|
* Produces a TextEdit that removes a setting from a declaration.
|
|
15
19
|
* If it's the only setting, removes the entire settings block [...].
|
package/dist/src/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export { Filepath } from './core/types/filepath';
|
|
|
4
4
|
export { UNHANDLED, type Unhandled, } from './core/types/module';
|
|
5
5
|
export { ElementKind } from './core/types/keywords';
|
|
6
6
|
export { type NodeSymbol, SymbolKind, } from './core/types/symbol';
|
|
7
|
+
export { MetadataKind } from './core/types/symbol/metadata';
|
|
7
8
|
export * from './core/global_modules/records/utils';
|
|
8
9
|
export * from './core/types/nodes';
|
|
9
10
|
export { SyntaxToken, SyntaxTokenKind, isTriviaToken, isOp, isOpToken, } from './core/types/tokens';
|
|
@@ -12,7 +13,9 @@ export type { Position, } from './core/types';
|
|
|
12
13
|
export { ScopeKind, splitQualifiedIdentifier, unescapeString, escapeString, formatRecordValue, isValidIdentifier, addDoubleQuoteIfNeeded, } from './compiler/index';
|
|
13
14
|
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 RelationCardinality, 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';
|
|
14
15
|
export type { DiagramViewSyncOperation, DiagramViewBlock, TextEdit, } from './compiler/queries/transform';
|
|
16
|
+
export { findDiagramViewBlocks, findDepBlocks } from './compiler/queries/transform';
|
|
15
17
|
export type { DepSyncOperation, DepSyncEdge, DepEndpointRef, DepBlock, } from './compiler/queries/transform';
|
|
18
|
+
export type { ElementIdentifier, SchemaIdentifier, TableIdentifier, ColumnIdentifier, EnumIdentifier, EndpointRef, RefIdentifier, DepIdentifier, NoteIdentifier, TableGroupIdentifier, } from './compiler/queries/transform';
|
|
16
19
|
export { dbmlLanguageConfig, dbmlMonarchTokensProvider, } from './services/monarch';
|
|
17
20
|
export * from './compiler/projectLayout/layout';
|
|
18
21
|
export { Compiler };
|
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-alpha.
|
|
4
|
+
"version": "9.0.0-alpha.8",
|
|
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": "
|
|
53
|
+
"gitHead": "3049d76952a6bf7e05aa51188bf5546145ba2b17"
|
|
54
54
|
}
|