@dbml/parse 10.0.0-optional-ref.0 → 10.0.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/dbml-parse.js +29 -19
- package/dist/dbml-parse.mjs +5951 -4730
- package/dist/src/compiler/index.d.ts +11 -7
- package/dist/src/compiler/queries/transform/index.d.ts +3 -1
- package/dist/src/compiler/queries/transform/renameTable.d.ts +2 -2
- package/dist/src/compiler/queries/transform/syncDep.d.ts +54 -0
- package/dist/src/compiler/queries/transform/types.d.ts +48 -0
- package/dist/src/compiler/queries/transform/updateElementSetting.d.ts +6 -0
- package/dist/src/compiler/queries/transform/utils/index.d.ts +26 -0
- package/dist/src/compiler/queries/transform/utils/ref.d.ts +15 -0
- package/dist/src/compiler/queries/utils.d.ts +6 -0
- package/dist/src/compiler/types.d.ts +9 -7
- package/dist/src/core/global_modules/dep/bind.d.ts +18 -0
- package/dist/src/core/global_modules/dep/index.d.ts +2 -0
- package/dist/src/core/global_modules/dep/interpret.d.ts +18 -0
- package/dist/src/core/global_modules/metadata/bind.d.ts +11 -0
- package/dist/src/core/global_modules/metadata/index.d.ts +2 -0
- package/dist/src/core/global_modules/metadata/interpret.d.ts +14 -0
- package/dist/src/core/global_modules/metadata/utils.d.ts +29 -0
- package/dist/src/core/global_modules/note/interpret.d.ts +3 -1
- package/dist/src/core/global_modules/program/utils/dep.d.ts +4 -0
- package/dist/src/core/global_modules/program/utils/external.d.ts +3 -0
- package/dist/src/core/global_modules/program/utils/index.d.ts +3 -0
- package/dist/src/core/global_modules/program/utils/records.d.ts +6 -0
- package/dist/src/core/global_modules/table/bind.d.ts +2 -0
- package/dist/src/core/global_modules/table/interpret.d.ts +12 -1
- package/dist/src/core/global_modules/tableGroup/interpret.d.ts +3 -1
- package/dist/src/core/global_modules/utils.d.ts +5 -1
- package/dist/src/core/local_modules/dep/index.d.ts +2 -0
- package/dist/src/core/local_modules/dep/validate.d.ts +19 -0
- package/dist/src/core/local_modules/metadata/index.d.ts +2 -0
- package/dist/src/core/local_modules/metadata/utils.d.ts +7 -0
- package/dist/src/core/local_modules/metadata/validate.d.ts +14 -0
- package/dist/src/core/types/errors.d.ts +62 -53
- package/dist/src/core/types/keywords.d.ts +4 -1
- package/dist/src/core/types/nodes.d.ts +14 -3
- package/dist/src/core/types/relation.d.ts +6 -2
- package/dist/src/core/types/schemaJson/types.d.ts +45 -1
- package/dist/src/core/types/symbol/metadata.d.ts +30 -11
- package/dist/src/core/types/symbol/symbols.d.ts +10 -1
- package/dist/src/core/utils/expression.d.ts +2 -1
- package/dist/src/core/utils/interpret.d.ts +12 -2
- package/dist/src/core/utils/note.d.ts +18 -0
- package/dist/src/core/utils/setting.d.ts +13 -14
- package/dist/src/core/utils/tokens.d.ts +3 -0
- package/dist/src/core/utils/validate.d.ts +16 -2
- package/dist/src/index.d.ts +7 -3
- package/dist/src/services/suggestions/provider.d.ts +19 -0
- package/package.json +4 -3
- package/dist/src/compiler/queries/transform/utils.d.ts +0 -23
- package/dist/src/core/global_modules/program/utils.d.ts +0 -3
|
@@ -3,11 +3,10 @@ import { SyntaxNode, SyntaxNodeIdGenerator } from '../core/types/nodes';
|
|
|
3
3
|
import { NodeSymbolIdGenerator, SymbolFactory } from '../core/types/symbol';
|
|
4
4
|
import { DBMLCodeActionProvider, DBMLCompletionItemProvider, DBMLDefinitionProvider, DBMLDiagnosticsProvider, DBMLReferencesProvider } from '../services/index';
|
|
5
5
|
import { DbmlProjectLayout } from './projectLayout';
|
|
6
|
-
import {
|
|
7
|
-
import { addDoubleQuoteIfNeeded, escapeString, formatRecordValue, isValidIdentifier, splitQualifiedIdentifier, unescapeString } from './queries/utils';
|
|
6
|
+
import { addDoubleQuoteIfNeeded, escapeString, formatRecordValue, isValidIdentifier, normalizeQualifiedName, 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, normalizeQualifiedName, splitQualifiedIdentifier, unescapeString, };
|
|
11
10
|
export default class Compiler {
|
|
12
11
|
layout: DbmlProjectLayout;
|
|
13
12
|
readonly nodeIdGenerator: SyntaxNodeIdGenerator;
|
|
@@ -72,12 +71,17 @@ 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
|
+
updateElementSettingEdit: (filepath: Filepath, target: import('..').ElementIdentifier, settingName: string, value: string | null | undefined) => import('.').TextEdit[];
|
|
77
|
+
syncDiagramView: (filepath: Filepath, operations: import('..').DiagramViewSyncOperation[], blocks?: import('..').DiagramViewBlock[] | undefined) => {
|
|
78
|
+
newDbml: string;
|
|
79
|
+
edits: import('.').TextEdit[];
|
|
80
|
+
};
|
|
81
|
+
syncDep: (filepath: Filepath, operations: import('..').DepSyncOperation[], blocks?: import('..').DepBlock[] | undefined) => {
|
|
77
82
|
newDbml: string;
|
|
78
83
|
edits: import('.').TextEdit[];
|
|
79
84
|
};
|
|
80
|
-
findDiagramViewBlocks(filepath: Filepath): DiagramViewBlock[];
|
|
81
85
|
readonly token: {
|
|
82
86
|
invalidStream: (filepath: Filepath) => readonly import('..').SyntaxToken[];
|
|
83
87
|
flatStream: (filepath: Filepath) => readonly import('..').SyntaxToken[];
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export { renameTable } from './renameTable';
|
|
2
|
+
export { updateElementSetting, updateElementSettingEdit } from './updateElementSetting';
|
|
2
3
|
export { syncDiagramView, findDiagramViewBlocks, type DiagramViewSyncOperation, type DiagramViewBlock, } from './syncDiagramView';
|
|
4
|
+
export { syncDep, findDepBlocks, generateDepBlock, type DepSyncOperation, type DepSyncEdge, type DepEndpointRef, type DepBlock, } from './syncDep';
|
|
3
5
|
export { applyTextEdits, type TextEdit } from './applyTextEdits';
|
|
4
|
-
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,54 @@
|
|
|
1
|
+
import { Filepath } from '../../../core/types/filepath';
|
|
2
|
+
import { ElementDeclarationNode, ProgramNode } from '../../../core/types/nodes';
|
|
3
|
+
import { default as Compiler } from '../../index';
|
|
4
|
+
import { TextEdit } from './applyTextEdits';
|
|
5
|
+
export interface DepEndpointRef {
|
|
6
|
+
schemaName?: string | null;
|
|
7
|
+
tableName: string;
|
|
8
|
+
fieldNames?: string[];
|
|
9
|
+
}
|
|
10
|
+
export interface DepSyncEdge {
|
|
11
|
+
upstream: DepEndpointRef;
|
|
12
|
+
downstream: DepEndpointRef;
|
|
13
|
+
}
|
|
14
|
+
export interface DepSyncOperation {
|
|
15
|
+
operation: 'create' | 'update' | 'remove';
|
|
16
|
+
/** The edge that identifies the target block (table-level: empty fields). */
|
|
17
|
+
edge: DepSyncEdge;
|
|
18
|
+
/** Set to a value to create/update, null to remove, undefined to leave unchanged. */
|
|
19
|
+
color?: string | null;
|
|
20
|
+
/** Set to a value to create/update, null to remove, undefined to leave unchanged. */
|
|
21
|
+
note?: string | null;
|
|
22
|
+
}
|
|
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
|
+
/**
|
|
35
|
+
* Synchronizes `Dep` blocks in the DBML source at `filepath`.
|
|
36
|
+
* Applies create/update/remove operations and returns the rewritten source.
|
|
37
|
+
*/
|
|
38
|
+
export declare function syncDep(this: Compiler, filepath: Filepath, operations: DepSyncOperation[], blocks?: DepBlock[]): {
|
|
39
|
+
newDbml: string;
|
|
40
|
+
edits: TextEdit[];
|
|
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[];
|
|
@@ -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
|
+
schemaName?: string | null;
|
|
28
|
+
tableName: string;
|
|
29
|
+
fieldNames?: 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,6 @@
|
|
|
1
|
+
import { Filepath } from '../../../core/types/filepath';
|
|
2
|
+
import { default as Compiler } from '../../index';
|
|
3
|
+
import { TextEdit } from './applyTextEdits';
|
|
4
|
+
import { ElementIdentifier } from './types';
|
|
5
|
+
export declare function updateElementSettingEdit(this: Compiler, filepath: Filepath, target: ElementIdentifier, settingName: string, value: string | null | undefined): TextEdit[];
|
|
6
|
+
export declare function updateElementSetting(this: Compiler, filepath: Filepath, target: ElementIdentifier, settingName: string, value: string | null | undefined): string;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Filepath } from '../../../../core/types/filepath';
|
|
2
|
+
import { NodeSymbol, SymbolKind } from '../../../../core/types/symbol';
|
|
3
|
+
import { default as Compiler } from '../../../index';
|
|
4
|
+
import { EndpointRef } from '../types';
|
|
5
|
+
export type { ElementIdentifier } from '../types';
|
|
6
|
+
export { findRefDefinition, type InlineRef, type StandaloneRef } from './ref';
|
|
7
|
+
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
|
+
export declare function normalizeTableName(input: string | {
|
|
11
|
+
schema?: string;
|
|
12
|
+
table: string;
|
|
13
|
+
}): {
|
|
14
|
+
schema: string;
|
|
15
|
+
table: string;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Looks up an element symbol by its qualified name and kind.
|
|
19
|
+
*/
|
|
20
|
+
export declare function lookupElementSymbol(compiler: Compiler, filepath: Filepath, schema: string, name: string, kind?: SymbolKind): NodeSymbol | undefined;
|
|
21
|
+
/**
|
|
22
|
+
* Removes surrounding double quotes from a string if present.
|
|
23
|
+
*/
|
|
24
|
+
export declare function stripQuotes(str: string): string;
|
|
25
|
+
export declare function formatEndpoint(ep: EndpointRef): string;
|
|
26
|
+
export declare function formatSetting(name: string, value: string | null | undefined): string;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { FunctionApplicationNode } from '../../../../core/types/nodes';
|
|
2
|
+
import { Filepath } from '../../../../core/types/filepath';
|
|
3
|
+
import { default as Compiler } from '../../../index';
|
|
4
|
+
import { RefIdentifier } from '../types';
|
|
5
|
+
export interface InlineRef {
|
|
6
|
+
kind: 'inline';
|
|
7
|
+
op: string;
|
|
8
|
+
fullStart: number;
|
|
9
|
+
fullEnd: number;
|
|
10
|
+
}
|
|
11
|
+
export interface StandaloneRef {
|
|
12
|
+
kind: 'standalone';
|
|
13
|
+
node: FunctionApplicationNode;
|
|
14
|
+
}
|
|
15
|
+
export declare function findRefDefinition(compiler: Compiler, filepath: Filepath, target: RefIdentifier): InlineRef | StandaloneRef | undefined;
|
|
@@ -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.
|
|
@@ -99,3 +100,8 @@ export declare function formatRecordValue(recordValue: {
|
|
|
99
100
|
export declare function splitQualifiedIdentifier(identifier: string): string[];
|
|
100
101
|
export declare function collectTransitiveDependencies(compiler: Compiler, entrypoints: Filepath[]): Filepath[];
|
|
101
102
|
export declare function allVisibleMembers(compiler: Compiler): Report<NodeSymbol[]>;
|
|
103
|
+
/**
|
|
104
|
+
* Wraps a note value in the appropriate DBML quote style.
|
|
105
|
+
* Uses triple quotes for multiline content, single quotes otherwise.
|
|
106
|
+
*/
|
|
107
|
+
export declare function quoteNoteValue(value: string): string;
|
|
@@ -5,11 +5,13 @@ export declare const enum ScopeKind {
|
|
|
5
5
|
INDEXES = 3,
|
|
6
6
|
NOTE = 4,
|
|
7
7
|
REF = 5,
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
8
|
+
DEP = 6,
|
|
9
|
+
PROJECT = 7,
|
|
10
|
+
CUSTOM = 8,
|
|
11
|
+
TOPLEVEL = 9,
|
|
12
|
+
TABLEPARTIAL = 10,
|
|
13
|
+
CHECKS = 11,
|
|
14
|
+
RECORDS = 12,
|
|
15
|
+
DIAGRAMVIEW = 13,
|
|
16
|
+
METADATA = 14
|
|
15
17
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { default as Compiler } from '../../../compiler';
|
|
2
|
+
import { CompileError } from '../../types/errors';
|
|
3
|
+
import { ElementDeclarationNode } from '../../types/nodes';
|
|
4
|
+
import { SyntaxToken } from '../../types/tokens';
|
|
5
|
+
export default class DepBinder {
|
|
6
|
+
private compiler;
|
|
7
|
+
private declarationNode;
|
|
8
|
+
constructor(compiler: Compiler, declarationNode: ElementDeclarationNode & {
|
|
9
|
+
type: SyntaxToken;
|
|
10
|
+
});
|
|
11
|
+
bind(): CompileError[];
|
|
12
|
+
private bindBody;
|
|
13
|
+
private bindFields;
|
|
14
|
+
private checkColumnSelfLoop;
|
|
15
|
+
private endpointSymbol;
|
|
16
|
+
private endpointLevel;
|
|
17
|
+
private bindSubElements;
|
|
18
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Dep } from '../../types/schemaJson';
|
|
2
|
+
import { DepMetadata, Filepath } from '../../types';
|
|
3
|
+
import { default as Compiler } from '../../../compiler';
|
|
4
|
+
import { default as Report } from '../../types/report';
|
|
5
|
+
export declare class DepInterpreter {
|
|
6
|
+
private compiler;
|
|
7
|
+
private metadata;
|
|
8
|
+
private declarationNode;
|
|
9
|
+
private filepath;
|
|
10
|
+
private dep;
|
|
11
|
+
constructor(compiler: Compiler, metadata: DepMetadata, filepath: Filepath);
|
|
12
|
+
interpret(): Report<Dep>;
|
|
13
|
+
private interpretName;
|
|
14
|
+
private interpretEdges;
|
|
15
|
+
private interpretSettings;
|
|
16
|
+
private consumeSettings;
|
|
17
|
+
private extractAttrValue;
|
|
18
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { default as Compiler } from '../../../compiler';
|
|
2
|
+
import { CompileError } from '../../types';
|
|
3
|
+
import { ElementDeclarationNode } from '../../types/nodes';
|
|
4
|
+
export default class MetadataBinder {
|
|
5
|
+
private compiler;
|
|
6
|
+
private declarationNode;
|
|
7
|
+
constructor(compiler: Compiler, declarationNode: ElementDeclarationNode);
|
|
8
|
+
bind(): CompileError[];
|
|
9
|
+
private bindTargetElement;
|
|
10
|
+
private bindBody;
|
|
11
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { default as Compiler } from '../../../compiler';
|
|
2
|
+
import { Filepath } from '../../types';
|
|
3
|
+
import { MetadataElementMetadata } from '../../types/symbol/metadata';
|
|
4
|
+
import { default as Report } from '../../types/report';
|
|
5
|
+
import { MetadataValues } from '../../types/schemaJson';
|
|
6
|
+
export default class MetadataInterpreter {
|
|
7
|
+
private declarationNode;
|
|
8
|
+
private compiler;
|
|
9
|
+
private filepath;
|
|
10
|
+
private values;
|
|
11
|
+
constructor(compiler: Compiler, metadata: MetadataElementMetadata, filepath: Filepath);
|
|
12
|
+
interpret(): Report<MetadataValues>;
|
|
13
|
+
private interpretValues;
|
|
14
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { default as Compiler } from '../../../compiler/index';
|
|
2
|
+
import { Filepath, SettingName } from '../../types';
|
|
3
|
+
import { Column, Note, Table, TableGroup, TokenPosition } from '../../types/schemaJson';
|
|
4
|
+
import { ElementDeclarationNode, SyntaxNode } from '../../types/nodes';
|
|
5
|
+
import { NodeSymbol, SymbolKind, MetadataTargetKind } from '../../types/symbol';
|
|
6
|
+
export type MetadataTarget = Table | TableGroup | Note | Column;
|
|
7
|
+
/**
|
|
8
|
+
* Specs for builtin metadata (table's note, tablegroup's color, .etc) for different element types. Does 2 things:
|
|
9
|
+
* - `validate`: Validating if the metadata value is syntactically correct
|
|
10
|
+
* - `assign`: Write the metadata value to the element builtin props (e.g. write `table.note` instead of `table.metadata`)
|
|
11
|
+
*/
|
|
12
|
+
interface MetadataField<T extends MetadataTarget> {
|
|
13
|
+
/** Check if the metadata value is syntactically correct */
|
|
14
|
+
isValidBuiltinFieldValue(node?: SyntaxNode): boolean;
|
|
15
|
+
message: string;
|
|
16
|
+
/** Write the metadata value to the element builtin props (e.g. write to `table.note`) */
|
|
17
|
+
assignBuiltinField(element: Partial<T>, value: string, token: TokenPosition): void;
|
|
18
|
+
}
|
|
19
|
+
export type MetadataFieldRegistry<T extends MetadataTarget, K extends SettingName = SettingName> = Record<K, MetadataField<T>>;
|
|
20
|
+
type NameWithSymbolKind = {
|
|
21
|
+
name: string;
|
|
22
|
+
symbolKind: SymbolKind;
|
|
23
|
+
};
|
|
24
|
+
/** @internal Exported for testing only. */
|
|
25
|
+
export declare function mapNamePartToSymbolKind(nameParts: string[], targetKind: MetadataTargetKind): NameWithSymbolKind[];
|
|
26
|
+
export declare function resolveMetadataTarget(compiler: Compiler, metadataNode: ElementDeclarationNode): NodeSymbol | undefined;
|
|
27
|
+
/** Merge every custom-metadata block, reachable from the current program, targeting element to it's `metadata` and other builtin (note/headercolor/...) fields */
|
|
28
|
+
export declare function attachCustomMetadata<T extends MetadataTarget>(compiler: Compiler, targetElement: Partial<T>, targetSymbol: NodeSymbol, fieldsRegistry: MetadataFieldRegistry<T, any>, filepath: Filepath): void;
|
|
29
|
+
export {};
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { Note } from '../../types/schemaJson';
|
|
2
2
|
import { default as Compiler } from '../../../compiler';
|
|
3
|
-
import { Filepath, NoteSymbol } from '../../types';
|
|
3
|
+
import { SettingName, Filepath, NoteSymbol } from '../../types';
|
|
4
4
|
import { default as Report } from '../../types/report';
|
|
5
|
+
import { MetadataFieldRegistry } from '../metadata/utils';
|
|
6
|
+
export declare const NOTE_METADATA_FIELDS: MetadataFieldRegistry<Note, SettingName.Color>;
|
|
5
7
|
export declare class StickyNoteInterpreter {
|
|
6
8
|
private declarationNode;
|
|
7
9
|
private symbol;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { default as Compiler } from '../../../../compiler/index';
|
|
2
|
+
import { CompileWarning } from '../../../types/errors';
|
|
3
|
+
import { Filepath } from '../../../types/filepath';
|
|
4
|
+
import { Ref } from '../../../types/schemaJson';
|
|
5
|
+
import { ProgramSymbol } from '../../../types/symbol';
|
|
6
|
+
export declare function validateRecords(compiler: Compiler, programSymbol: ProgramSymbol, refs: Ref[], filepath: Filepath): CompileWarning[];
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { default as Compiler } from '../../../compiler';
|
|
2
|
+
import { SettingName } from '../../types/keywords';
|
|
2
3
|
import { ElementDeclarationNode } from '../../types/nodes';
|
|
3
4
|
import { default as Report } from '../../types/report';
|
|
4
|
-
import { Table } from '../../types/schemaJson';
|
|
5
|
+
import { Column, Table } from '../../types/schemaJson';
|
|
5
6
|
import { Filepath } from '../../types/filepath';
|
|
6
7
|
import { TableSymbol } from '../../types/symbol/symbols';
|
|
8
|
+
import { MetadataFieldRegistry } from '../metadata/utils';
|
|
7
9
|
export declare class TableInterpreter {
|
|
8
10
|
private declarationNode;
|
|
9
11
|
private compiler;
|
|
@@ -13,6 +15,7 @@ export declare class TableInterpreter {
|
|
|
13
15
|
private pkColumns;
|
|
14
16
|
constructor(compiler: Compiler, declarationNode: ElementDeclarationNode, symbol: TableSymbol, filepath: Filepath);
|
|
15
17
|
interpret(): Report<Table>;
|
|
18
|
+
private attachTableAndColumnMetadata;
|
|
16
19
|
private interpretName;
|
|
17
20
|
private interpretAlias;
|
|
18
21
|
private interpretSettingList;
|
|
@@ -24,3 +27,11 @@ export declare class TableInterpreter {
|
|
|
24
27
|
private interpretIndexes;
|
|
25
28
|
private interpretChecks;
|
|
26
29
|
}
|
|
30
|
+
/**
|
|
31
|
+
* Settings that are excluded from custom metadata for inline metadata for Column
|
|
32
|
+
* Different from what we extract from metadata block for Column because some settings value types are not supported yet, mostly boolean keys without values ([pk, not null])
|
|
33
|
+
* TODO: Catch these settings when we support more data types for custom metadata
|
|
34
|
+
*/
|
|
35
|
+
export declare const RECOGNIZED_COLUMN_SETTINGS: readonly SettingName[];
|
|
36
|
+
export declare const TABLE_METADATA_FIELDS: MetadataFieldRegistry<Table, SettingName.Note | SettingName.HeaderColor>;
|
|
37
|
+
export declare const COLUMN_METADATA_FIELDS: MetadataFieldRegistry<Column, SettingName.Note>;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { TableGroup } from '../../types/schemaJson';
|
|
2
2
|
import { default as Compiler } from '../../../compiler';
|
|
3
|
-
import { Filepath, TableGroupSymbol } from '../../types';
|
|
3
|
+
import { SettingName, Filepath, TableGroupSymbol } from '../../types';
|
|
4
4
|
import { default as Report } from '../../types/report';
|
|
5
|
+
import { MetadataFieldRegistry } from '../metadata/utils';
|
|
6
|
+
export declare const TABLEGROUP_METADATA_FIELDS: MetadataFieldRegistry<TableGroup, SettingName.Note | SettingName.Color>;
|
|
5
7
|
export declare class TableGroupInterpreter {
|
|
6
8
|
private compiler;
|
|
7
9
|
private symbol;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { default as Compiler } from '../../compiler';
|
|
2
|
+
import { Filepath, ProgramSymbol } from '../types';
|
|
2
3
|
import { PrimaryExpressionNode, SyntaxNode, VariableNode } from '../types/nodes';
|
|
3
4
|
import { default as Report } from '../types/report';
|
|
4
|
-
import { NodeSymbol } from '../types/symbol';
|
|
5
|
+
import { SymbolKind, NodeSymbol } from '../types/symbol';
|
|
5
6
|
export declare function shouldInterpretNode(compiler: Compiler, node: SyntaxNode): boolean;
|
|
6
7
|
export declare function getNodeMemberSymbols(compiler: Compiler, node: SyntaxNode): Report<NodeSymbol[]>;
|
|
7
8
|
export declare function scanNonListNodeForBinding(node?: SyntaxNode): {
|
|
@@ -13,3 +14,6 @@ export declare function scanNonListNodeForBinding(node?: SyntaxNode): {
|
|
|
13
14
|
})[];
|
|
14
15
|
}[];
|
|
15
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>;
|
|
18
|
+
export declare function getDefaultSchemaSymbol(compiler: Compiler, globalSymbol: NodeSymbol): NodeSymbol | undefined;
|
|
19
|
+
export declare function getProgramSymbol(compiler: Compiler, filepath: Filepath): ProgramSymbol | undefined;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { default as Compiler } from '../../../compiler';
|
|
2
|
+
import { CompileError } from '../../types/errors';
|
|
3
|
+
import { BlockExpressionNode, ElementDeclarationNode, FunctionApplicationNode, ListExpressionNode } from '../../types/nodes';
|
|
4
|
+
import { default as Report } from '../../types/report';
|
|
5
|
+
import { Settings } from '../../utils/validate';
|
|
6
|
+
export default class DepValidator {
|
|
7
|
+
private declarationNode;
|
|
8
|
+
private compiler;
|
|
9
|
+
constructor(compiler: Compiler, declarationNode: ElementDeclarationNode);
|
|
10
|
+
validate(): CompileError[];
|
|
11
|
+
private validateSettings;
|
|
12
|
+
private validateContext;
|
|
13
|
+
private validateName;
|
|
14
|
+
private validateAlias;
|
|
15
|
+
validateBody(body?: FunctionApplicationNode | BlockExpressionNode): CompileError[];
|
|
16
|
+
validateFields(fields: FunctionApplicationNode[]): CompileError[];
|
|
17
|
+
private validateSubElements;
|
|
18
|
+
}
|
|
19
|
+
export declare function validateDepSettings(settings: ListExpressionNode): Report<Settings>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { CompileError, CompileErrorCode, MetadataTargetKind } from '../../types';
|
|
2
|
+
import { AttributeNode, ElementDeclarationNode } from '../../types/nodes';
|
|
3
|
+
export declare function getMetadataTargetKind(node: ElementDeclarationNode): MetadataTargetKind | undefined;
|
|
4
|
+
export declare function validateCustomInlineMetadata(name: string, attrs: AttributeNode[], errorCodes: {
|
|
5
|
+
duplicate: CompileErrorCode;
|
|
6
|
+
invalidValue: CompileErrorCode;
|
|
7
|
+
}): CompileError[];
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { default as Compiler } from '../../../compiler';
|
|
2
|
+
import { CompileError } from '../../types/errors';
|
|
3
|
+
import { ElementDeclarationNode } from '../../types/nodes';
|
|
4
|
+
export default class MetadataValidator {
|
|
5
|
+
private compiler;
|
|
6
|
+
private declarationNode;
|
|
7
|
+
constructor(compiler: Compiler, declarationNode: ElementDeclarationNode);
|
|
8
|
+
validate(): CompileError[];
|
|
9
|
+
private validateTargetKind;
|
|
10
|
+
private validateTargetName;
|
|
11
|
+
private validateBody;
|
|
12
|
+
private validateFields;
|
|
13
|
+
private validateSubElements;
|
|
14
|
+
}
|