@dbml/parse 9.0.0-alpha.12 → 9.0.0-alpha.13
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 +22 -22
- package/dist/dbml-parse.mjs +7881 -7869
- package/dist/src/compiler/index.d.ts +3 -3
- package/dist/src/compiler/queries/transform/syncDep.d.ts +16 -24
- package/dist/src/compiler/queries/utils.d.ts +1 -0
- package/dist/src/core/global_modules/records/utils/constraints/helper.d.ts +4 -17
- package/dist/src/core/global_modules/utils.d.ts +2 -1
- package/dist/src/core/types/symbol/symbols.d.ts +1 -0
- package/dist/src/core/utils/validate.d.ts +2 -0
- package/dist/src/index.d.ts +1 -1
- package/package.json +2 -2
|
@@ -3,10 +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 { addDoubleQuoteIfNeeded, escapeString, formatRecordValue, isValidIdentifier, splitQualifiedIdentifier, unescapeString } from './queries/utils';
|
|
6
|
+
import { addDoubleQuoteIfNeeded, escapeString, formatRecordValue, isValidIdentifier, normalizeQualifiedName, splitQualifiedIdentifier, unescapeString } from './queries/utils';
|
|
7
7
|
export { ScopeKind } from './types';
|
|
8
8
|
export type { TextEdit } from './queries/transform';
|
|
9
|
-
export { addDoubleQuoteIfNeeded, escapeString, formatRecordValue, isValidIdentifier, splitQualifiedIdentifier, unescapeString, };
|
|
9
|
+
export { addDoubleQuoteIfNeeded, escapeString, formatRecordValue, isValidIdentifier, normalizeQualifiedName, splitQualifiedIdentifier, unescapeString, };
|
|
10
10
|
export default class Compiler {
|
|
11
11
|
layout: DbmlProjectLayout;
|
|
12
12
|
readonly nodeIdGenerator: SyntaxNodeIdGenerator;
|
|
@@ -29,7 +29,7 @@ export default class Compiler {
|
|
|
29
29
|
validateFile: (filepath: Filepath) => import('../core/types/report').default<void>;
|
|
30
30
|
nodeFullname: (node: SyntaxNode) => import('../core/types/report').default<string[] | undefined> | import('../core/types/report').default<typeof import('..').UNHANDLED>;
|
|
31
31
|
nodeAlias: (node: SyntaxNode) => import('../core/types/report').default<typeof import('..').UNHANDLED> | import('../core/types/report').default<string | undefined>;
|
|
32
|
-
nodeSettings: (node: SyntaxNode) => import('../core/types/report').default<
|
|
32
|
+
nodeSettings: (node: SyntaxNode) => import('../core/types/report').default<import('../core/utils/validate').Settings> | import('../core/types/report').default<typeof import('..').UNHANDLED>;
|
|
33
33
|
canonicalName: (filepath: Filepath, symbol: import('../core/types/symbol').NodeSymbol) => import('../core/types/report').default<import('./queries/canonicalName').CanonicalName | undefined>;
|
|
34
34
|
bindNode: (node: SyntaxNode) => import('../core/types/report').default<typeof import('..').UNHANDLED> | import('../core/types/report').default<void>;
|
|
35
35
|
bindFile: (filepath: Filepath) => import('../core/types/report').default<void>;
|
|
@@ -28,35 +28,27 @@ export interface DepBlock {
|
|
|
28
28
|
}
|
|
29
29
|
export interface InlineDep {
|
|
30
30
|
edge: DepSyncEdge;
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
fullStart: number;
|
|
32
|
+
fullEnd: number;
|
|
33
33
|
}
|
|
34
|
-
/**
|
|
35
|
-
* Returns every `Dep` block in `source`.
|
|
36
|
-
* On any lex or parse error, returns [] - there is no reliable way to read
|
|
37
|
-
* dep blocks from malformed DBML (mirrors findDiagramViewBlocks).
|
|
38
|
-
*/
|
|
39
|
-
export declare function findDepBlocks(source: string): DepBlock[];
|
|
40
|
-
export declare function findInlineDeps(source: string): InlineDep[];
|
|
41
|
-
export declare function depBlocksFromProgram(program: ProgramNode): DepBlock[];
|
|
42
|
-
export declare function inlineDepsFromProgram(source: string, program: ProgramNode): InlineDep[];
|
|
43
|
-
/**
|
|
44
|
-
* Emit a `Dep` block for one edge with a `[color]` setting:
|
|
45
|
-
*
|
|
46
|
-
* Dep [color: <hex>] {
|
|
47
|
-
* <upstream> -> <downstream>
|
|
48
|
-
* }
|
|
49
|
-
*/
|
|
50
|
-
export declare function generateDepBlock(edge: DepSyncEdge, color: string): string;
|
|
51
34
|
/**
|
|
52
35
|
* Synchronizes `Dep` blocks in the DBML source at `filepath`.
|
|
53
|
-
*
|
|
54
|
-
* @param filepath The file whose source should be rewritten.
|
|
55
|
-
* @param operations Array of create/update operations to apply.
|
|
56
|
-
* @param blocks Optional pre-parsed blocks from findDepBlocks.
|
|
57
|
-
* @returns The new DBML source and the text edits applied.
|
|
36
|
+
* Applies create/update/remove operations and returns the rewritten source.
|
|
58
37
|
*/
|
|
59
38
|
export declare function syncDep(this: Compiler, filepath: Filepath, operations: DepSyncOperation[], blocks?: DepBlock[]): {
|
|
60
39
|
newDbml: string;
|
|
61
40
|
edits: TextEdit[];
|
|
62
41
|
};
|
|
42
|
+
/**
|
|
43
|
+
* Returns every standalone `Dep` block in `source`.
|
|
44
|
+
* On lex/parse error returns [] (mirrors findDiagramViewBlocks).
|
|
45
|
+
*/
|
|
46
|
+
export declare function findDepBlocks(source: string): DepBlock[];
|
|
47
|
+
/** Returns every inline `[dep: -> target]` setting on columns in `source`. */
|
|
48
|
+
export declare function findInlineDeps(source: string): InlineDep[];
|
|
49
|
+
/** Emit a `Dep` block string for one edge with a `[color]` setting. */
|
|
50
|
+
export declare function generateDepBlock(edge: DepSyncEdge, color: string): string;
|
|
51
|
+
/** Extract `DepBlock[]` from an already-parsed program AST. */
|
|
52
|
+
export declare function depBlocksFromProgram(program: ProgramNode): DepBlock[];
|
|
53
|
+
/** Extract `InlineDep[]` from an already-parsed program AST. */
|
|
54
|
+
export declare function inlineDepsFromProgram(source: string, program: ProgramNode): InlineDep[];
|
|
@@ -35,6 +35,7 @@ export declare function isValidIdentifier(name: string): boolean;
|
|
|
35
35
|
* addDoubleQuoteIfNeeded('user-name') => '"user-name"'
|
|
36
36
|
*/
|
|
37
37
|
export declare function addDoubleQuoteIfNeeded(identifier: string): string;
|
|
38
|
+
export declare function normalizeQualifiedName(...parts: string[]): string;
|
|
38
39
|
/**
|
|
39
40
|
* Unescapes a string by processing escape sequences.
|
|
40
41
|
* Handles escaped quotes (\"), common escape sequences, unicode (\uHHHH), and arbitrary escapes.
|
|
@@ -2,25 +2,12 @@ import { default as Compiler } from '../../../../../compiler/index';
|
|
|
2
2
|
import { CompileWarning } from '../../../../types/errors';
|
|
3
3
|
import { RecordValue, TableRecord } from '../../../../types/schemaJson';
|
|
4
4
|
import { ColumnSymbol } from '../../../../types/symbol';
|
|
5
|
-
export interface ColumnInfo {
|
|
6
|
-
name: string;
|
|
7
|
-
pk: boolean;
|
|
8
|
-
unique: boolean;
|
|
9
|
-
increment: boolean;
|
|
10
|
-
notNull: boolean;
|
|
11
|
-
dbdefault?: {
|
|
12
|
-
value: string | number;
|
|
13
|
-
type: string;
|
|
14
|
-
};
|
|
15
|
-
typeName: string;
|
|
16
|
-
}
|
|
17
|
-
export declare function columnInfoFromSymbol(col: ColumnSymbol, compiler: Compiler): ColumnInfo;
|
|
18
5
|
export declare function toKeyedRows(record: TableRecord): Record<string, RecordValue>[];
|
|
19
6
|
export declare function makeTableKey(schema: string | null, table: string): string;
|
|
20
|
-
export declare function extractKeyValueWithDefault(row: Record<string, RecordValue>,
|
|
21
|
-
export declare function hasNullWithoutDefaultInKey(row: Record<string, RecordValue>,
|
|
22
|
-
export declare function isAutoIncrementColumn(column: ColumnInfo): boolean;
|
|
7
|
+
export declare function extractKeyValueWithDefault(compiler: Compiler, row: Record<string, RecordValue>, columns: ColumnSymbol[]): string;
|
|
8
|
+
export declare function hasNullWithoutDefaultInKey(compiler: Compiler, row: Record<string, RecordValue>, columns: ColumnSymbol[]): boolean;
|
|
23
9
|
export declare function formatFullColumnName(schemaName: string | null, tableName: string, columnName: string): string;
|
|
24
10
|
export declare function formatFullColumnNames(schemaName: string | null, tableName: string, columnNames: string[]): string;
|
|
25
|
-
export declare function formatValues(row: Record<string, RecordValue>,
|
|
11
|
+
export declare function formatValues(compiler: Compiler, row: Record<string, RecordValue>, columns: ColumnSymbol[]): string;
|
|
12
|
+
export declare function getDiagnosticAnchorValues(row: Record<string, RecordValue>, columnNames: string[]): RecordValue[];
|
|
26
13
|
export declare function createConstraintWarning(compiler: Compiler, recordValue: RecordValue, message: string): CompileWarning;
|
|
@@ -2,7 +2,7 @@ import { default as Compiler } from '../../compiler';
|
|
|
2
2
|
import { RelationCardinality } from '../types';
|
|
3
3
|
import { PrimaryExpressionNode, SyntaxNode, VariableNode } from '../types/nodes';
|
|
4
4
|
import { default as Report } from '../types/report';
|
|
5
|
-
import { NodeSymbol } from '../types/symbol';
|
|
5
|
+
import { SymbolKind, NodeSymbol } from '../types/symbol';
|
|
6
6
|
export declare function shouldInterpretNode(compiler: Compiler, node: SyntaxNode): boolean;
|
|
7
7
|
export declare function getNodeMemberSymbols(compiler: Compiler, node: SyntaxNode): Report<NodeSymbol[]>;
|
|
8
8
|
export declare function scanNonListNodeForBinding(node?: SyntaxNode): {
|
|
@@ -14,4 +14,5 @@ export declare function scanNonListNodeForBinding(node?: SyntaxNode): {
|
|
|
14
14
|
})[];
|
|
15
15
|
}[];
|
|
16
16
|
export declare function nodeRefereeOfLeftExpression(compiler: Compiler, node: SyntaxNode): NodeSymbol | undefined;
|
|
17
|
+
export declare function nodeRefereeOfEndpoint(compiler: Compiler, globalSymbol: NodeSymbol, node: SyntaxNode, terminalKind: SymbolKind.Column | SymbolKind.Table): Report<NodeSymbol | undefined>;
|
|
17
18
|
export declare function getMultiplicities(op: string): [RelationCardinality, RelationCardinality] | undefined;
|
|
@@ -150,6 +150,7 @@ export declare class ColumnSymbol extends NodeSymbol {
|
|
|
150
150
|
pk(compiler: Compiler): boolean;
|
|
151
151
|
unique(compiler: Compiler): boolean;
|
|
152
152
|
nullable(compiler: Compiler): boolean | undefined;
|
|
153
|
+
isIncrementSet(compiler: Compiler): boolean;
|
|
153
154
|
increment(compiler: Compiler): boolean;
|
|
154
155
|
default(compiler: Compiler): {
|
|
155
156
|
type: 'number' | 'string' | 'boolean' | 'expression';
|
|
@@ -24,6 +24,7 @@ export declare function isValidPartialInjection(node?: SyntaxNode): node is Pref
|
|
|
24
24
|
};
|
|
25
25
|
};
|
|
26
26
|
export declare function isRelationshipOp(op?: string): boolean;
|
|
27
|
+
export declare function isDependencyOp(op?: string): boolean;
|
|
27
28
|
export declare function isValidColor(value?: SyntaxNode): boolean;
|
|
28
29
|
export declare function isValidDefaultValue(value?: SyntaxNode): boolean;
|
|
29
30
|
export type SignedNumberExpression = (PrimaryExpressionNode & {
|
|
@@ -38,6 +39,7 @@ export type SignedNumberExpression = (PrimaryExpressionNode & {
|
|
|
38
39
|
});
|
|
39
40
|
export declare function isExpressionASignedNumberExpression(value?: SyntaxNode): value is SignedNumberExpression;
|
|
40
41
|
export declare function isUnaryRelationship(value?: SyntaxNode): value is PrefixExpressionNode;
|
|
42
|
+
export declare function isUnaryDependency(value?: SyntaxNode): value is PrefixExpressionNode;
|
|
41
43
|
export declare function isTupleOfVariables(value?: SyntaxNode): value is TupleExpressionNode & {
|
|
42
44
|
elementList: (PrimaryExpressionNode & {
|
|
43
45
|
expression: VariableNode;
|
package/dist/src/index.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ export * from './core/types/nodes';
|
|
|
10
10
|
export { SyntaxToken, SyntaxTokenKind, isTriviaToken, isOp, isOpToken, } from './core/types/tokens';
|
|
11
11
|
export { CompileError, CompileErrorCode, } from './core/types/errors';
|
|
12
12
|
export type { Position, } from './core/types';
|
|
13
|
-
export { ScopeKind, splitQualifiedIdentifier, unescapeString, escapeString, formatRecordValue, isValidIdentifier, addDoubleQuoteIfNeeded, } from './compiler/index';
|
|
13
|
+
export { ScopeKind, splitQualifiedIdentifier, unescapeString, escapeString, formatRecordValue, isValidIdentifier, addDoubleQuoteIfNeeded, normalizeQualifiedName, } from './compiler/index';
|
|
14
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';
|
|
15
15
|
export type { DiagramViewSyncOperation, DiagramViewBlock, TextEdit, } from './compiler/queries/transform';
|
|
16
16
|
export { findDiagramViewBlocks, findDepBlocks } from './compiler/queries/transform';
|
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.13",
|
|
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": "aad3f5808c07679bd201d4da15561beb8abf05f1"
|
|
54
54
|
}
|