@dbml/parse 10.1.0 → 10.1.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.
- package/dist/dbml-parse.js +26 -26
- package/dist/dbml-parse.mjs +1982 -2074
- package/dist/src/compiler/index.d.ts +1 -1
- package/dist/src/compiler/queries/transform/index.d.ts +1 -1
- package/dist/src/compiler/queries/transform/syncDep.d.ts +1 -24
- package/dist/src/compiler/queries/transform/utils/dep.d.ts +26 -0
- package/dist/src/compiler/queries/transform/utils/index.d.ts +1 -2
- package/dist/src/index.d.ts +2 -2
- package/package.json +2 -2
|
@@ -78,7 +78,7 @@ export default class Compiler {
|
|
|
78
78
|
newDbml: string;
|
|
79
79
|
edits: import('.').TextEdit[];
|
|
80
80
|
};
|
|
81
|
-
syncDep: (filepath: Filepath, operations: import('..').DepSyncOperation[]
|
|
81
|
+
syncDep: (filepath: Filepath, operations: import('..').DepSyncOperation[]) => {
|
|
82
82
|
newDbml: string;
|
|
83
83
|
edits: import('.').TextEdit[];
|
|
84
84
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { renameTable } from './renameTable';
|
|
2
2
|
export { updateElementSetting, updateElementSettingEdit } from './updateElementSetting';
|
|
3
3
|
export { syncDiagramView, findDiagramViewBlocks, type DiagramViewSyncOperation, type DiagramViewBlock, } from './syncDiagramView';
|
|
4
|
-
export { syncDep,
|
|
4
|
+
export { syncDep, generateDepBlock, type DepSyncOperation, type DepSyncEdge, type DepEndpointRef, } from './syncDep';
|
|
5
5
|
export { applyTextEdits, type TextEdit } from './applyTextEdits';
|
|
6
6
|
export type { ElementIdentifier, SchemaIdentifier, TableIdentifier, ColumnIdentifier, EnumIdentifier, EndpointRef, RefIdentifier, DepIdentifier, NoteIdentifier, TableGroupIdentifier, } from './types';
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Filepath } from '../../../core/types/filepath';
|
|
2
|
-
import { ElementDeclarationNode, ProgramNode } from '../../../core/types/nodes';
|
|
3
2
|
import { default as Compiler } from '../../index';
|
|
4
3
|
import { TextEdit } from './applyTextEdits';
|
|
5
4
|
export interface DepEndpointRef {
|
|
@@ -20,35 +19,13 @@ export interface DepSyncOperation {
|
|
|
20
19
|
/** Set to a value to create/update, null to remove, undefined to leave unchanged. */
|
|
21
20
|
note?: string | null;
|
|
22
21
|
}
|
|
23
|
-
export interface DepBlock {
|
|
24
|
-
startIndex: number;
|
|
25
|
-
endIndex: number;
|
|
26
|
-
declaration: ElementDeclarationNode;
|
|
27
|
-
edges: DepSyncEdge[];
|
|
28
|
-
}
|
|
29
|
-
export interface InlineDep {
|
|
30
|
-
edge: DepSyncEdge;
|
|
31
|
-
fullStart: number;
|
|
32
|
-
fullEnd: number;
|
|
33
|
-
}
|
|
34
22
|
/**
|
|
35
23
|
* Synchronizes `Dep` blocks in the DBML source at `filepath`.
|
|
36
24
|
* Applies create/update/remove operations and returns the rewritten source.
|
|
37
25
|
*/
|
|
38
|
-
export declare function syncDep(this: Compiler, filepath: Filepath, operations: DepSyncOperation[]
|
|
26
|
+
export declare function syncDep(this: Compiler, filepath: Filepath, operations: DepSyncOperation[]): {
|
|
39
27
|
newDbml: string;
|
|
40
28
|
edits: TextEdit[];
|
|
41
29
|
};
|
|
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
30
|
/** Emit a `Dep` block string for one edge with a `[color]` setting. */
|
|
50
31
|
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[];
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ElementDeclarationNode } from '../../../../core/types/nodes';
|
|
2
|
+
import { Filepath } from '../../../../core/types/filepath';
|
|
3
|
+
import { default as Compiler } from '../../../index';
|
|
4
|
+
import { DepIdentifier } from '../types';
|
|
5
|
+
export interface InlineDepDefinition {
|
|
6
|
+
kind: 'inline';
|
|
7
|
+
op: string;
|
|
8
|
+
fullStart: number;
|
|
9
|
+
fullEnd: number;
|
|
10
|
+
}
|
|
11
|
+
export interface BlockDepDefinition {
|
|
12
|
+
kind: 'block';
|
|
13
|
+
declaration: ElementDeclarationNode;
|
|
14
|
+
}
|
|
15
|
+
export type DepDefinition = InlineDepDefinition | BlockDepDefinition;
|
|
16
|
+
/**
|
|
17
|
+
* Finds the `Dep` block or inline `[dep: …]` setting that carries the edge `target` names.
|
|
18
|
+
*
|
|
19
|
+
* Matching runs on resolved table and column symbols, the way {@link findRefDefinition} does.
|
|
20
|
+
* The endpoints' source text cannot be compared instead: `a.b` is `schema.table` or
|
|
21
|
+
* `table.field` depending on what `a` resolves to, so a mixed-level edge such as
|
|
22
|
+
* `a.x -> b` is not describable without the symbol table.
|
|
23
|
+
*
|
|
24
|
+
* A target with no field names matches only an edge with no columns on that side.
|
|
25
|
+
*/
|
|
26
|
+
export declare function findDepDefinition(compiler: Compiler, filepath: Filepath, target: DepIdentifier): DepDefinition | undefined;
|
|
@@ -4,9 +4,8 @@ import { default as Compiler } from '../../../index';
|
|
|
4
4
|
import { EndpointRef } from '../types';
|
|
5
5
|
export type { ElementIdentifier } from '../types';
|
|
6
6
|
export { findRefDefinition, type InlineRef, type StandaloneRef } from './ref';
|
|
7
|
+
export { findDepDefinition, type DepDefinition, type InlineDepDefinition, type BlockDepDefinition, } from './dep';
|
|
7
8
|
export declare function normalizeSchema(schema?: string | null): string;
|
|
8
|
-
export declare function endpointsEqual(left: EndpointRef, right: EndpointRef): boolean;
|
|
9
|
-
export declare function endpointMatches(candidate: EndpointRef, target: EndpointRef): boolean;
|
|
10
9
|
export declare function normalizeTableName(input: string | {
|
|
11
10
|
schema?: string;
|
|
12
11
|
table: string;
|
package/dist/src/index.d.ts
CHANGED
|
@@ -14,8 +14,8 @@ export { ScopeKind, splitQualifiedIdentifier, unescapeString, escapeString, form
|
|
|
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 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, type CustomMetadata, } from './core/types/schemaJson';
|
|
15
15
|
export { type RelationCardinality, type RelationshipOp, getRelationshipOp, getMultiplicities, parseCardinality, makeCardinalityRequired, makeCardinalityOptional, makeRelationshipRequired, isEndpointOneSide, isEndpointManySide, isEndpointOptional, isEndpointRequired, CARDINALITY_ONE, CARDINALITY_MAYBE, CARDINALITY_SOME, CARDINALITY_MANY, } from './core/types/relation';
|
|
16
16
|
export type { DiagramViewSyncOperation, DiagramViewBlock, TextEdit, } from './compiler/queries/transform';
|
|
17
|
-
export { findDiagramViewBlocks
|
|
18
|
-
export type { DepSyncOperation, DepSyncEdge, DepEndpointRef,
|
|
17
|
+
export { findDiagramViewBlocks } from './compiler/queries/transform';
|
|
18
|
+
export type { DepSyncOperation, DepSyncEdge, DepEndpointRef, } from './compiler/queries/transform';
|
|
19
19
|
export type { ElementIdentifier, SchemaIdentifier, TableIdentifier, ColumnIdentifier, EnumIdentifier, EndpointRef, RefIdentifier, DepIdentifier, NoteIdentifier, TableGroupIdentifier, } from './compiler/queries/transform';
|
|
20
20
|
export { dbmlLanguageConfig, dbmlMonarchTokensProvider, } from './services/monarch';
|
|
21
21
|
export * from './compiler/projectLayout/layout';
|
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": "10.1.
|
|
4
|
+
"version": "10.1.1",
|
|
5
5
|
"description": "DBML parser v2",
|
|
6
6
|
"author": "Holistics <dev@holistics.io>",
|
|
7
7
|
"license": "Apache-2.0",
|
|
@@ -51,5 +51,5 @@
|
|
|
51
51
|
"engines": {
|
|
52
52
|
"node": ">=18"
|
|
53
53
|
},
|
|
54
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "55464498db51a06a228981d5a57d5f9d870fe3e7"
|
|
55
55
|
}
|