@dbml/parse 11.0.0 → 11.0.1-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.
@@ -3,10 +3,11 @@ 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 { addDoubleQuoteIfNeeded, escapeString, formatRecordValue, isValidIdentifier, normalizeQualifiedName, splitQualifiedIdentifier, unescapeString } from './queries/utils';
6
+ import { addDoubleQuoteIfNeeded, escapeString, formatTypedValue, isValidIdentifier, normalizeQualifiedName, splitQualifiedIdentifier, unescapeString, TypedValue } from './queries/utils';
7
7
  export { ScopeKind } from './types';
8
8
  export type { TextEdit } from './queries/transform';
9
- export { addDoubleQuoteIfNeeded, escapeString, formatRecordValue, isValidIdentifier, normalizeQualifiedName, splitQualifiedIdentifier, unescapeString, };
9
+ export { addDoubleQuoteIfNeeded, escapeString, formatTypedValue, isValidIdentifier, normalizeQualifiedName, splitQualifiedIdentifier, unescapeString, };
10
+ export type { TypedValue };
10
11
  export default class Compiler {
11
12
  layout: DbmlProjectLayout;
12
13
  readonly nodeIdGenerator: SyntaxNodeIdGenerator;
@@ -74,6 +75,9 @@ export default class Compiler {
74
75
  renameTable: (filepath: Filepath, oldName: string | import('..').TableIdentifier, newName: string | import('..').TableIdentifier) => Map<string, string>;
75
76
  updateElementSetting: (filepath: Filepath, target: import('..').ElementIdentifier, settingName: string, value: string | null | undefined) => string;
76
77
  updateElementSettingEdit: (filepath: Filepath, target: import('..').ElementIdentifier, settingName: string, value: string | null | undefined) => import('.').TextEdit[];
78
+ findMetadataBlock: (filepath: Filepath, target: import('..').ElementIdentifier) => import('../core/types/nodes').ElementDeclarationNode | undefined;
79
+ updateElementMetadata: (filepath: Filepath, target: import('..').ElementIdentifier, key: string, value: TypedValue) => string;
80
+ updateElementMetadataEdit: (filepath: Filepath, target: import('..').ElementIdentifier, key: string, value: TypedValue) => import('.').TextEdit[];
77
81
  syncDiagramView: (filepath: Filepath, operations: import('..').DiagramViewSyncOperation[], blocks?: import('..').DiagramViewBlock[] | undefined) => {
78
82
  newDbml: string;
79
83
  edits: import('.').TextEdit[];
@@ -1,5 +1,6 @@
1
1
  export { renameTable } from './renameTable';
2
2
  export { updateElementSetting, updateElementSettingEdit } from './updateElementSetting';
3
+ export { findMetadataBlock, updateElementMetadata, updateElementMetadataEdit, syncElementMetadata, } from './updateElementMetadata';
3
4
  export { syncDiagramView, findDiagramViewBlocks, type DiagramViewSyncOperation, type DiagramViewBlock, } from './syncDiagramView';
4
5
  export { syncDep, generateDepBlock, type DepSyncOperation, type DepSyncEdge, type DepEndpointRef, } from './syncDep';
5
6
  export { applyTextEdits, type TextEdit } from './applyTextEdits';
@@ -0,0 +1,13 @@
1
+ import { Filepath } from '../../../core/types/filepath';
2
+ import { ElementDeclarationNode } from '../../../core/types/nodes';
3
+ import { default as Compiler } from '../../index';
4
+ import { TextEdit } from './applyTextEdits';
5
+ import { ElementIdentifier } from './types';
6
+ import { TypedValue } from '../utils';
7
+ export declare function findMetadataBlock(this: Compiler, filepath: Filepath, target: ElementIdentifier): ElementDeclarationNode | undefined;
8
+ export declare function updateElementMetadataEdit(this: Compiler, filepath: Filepath, target: ElementIdentifier, key: string, value: TypedValue | null): TextEdit[];
9
+ export declare function updateElementMetadata(this: Compiler, filepath: Filepath, target: ElementIdentifier, key: string, value: TypedValue | null): string;
10
+ export declare function syncElementMetadata(source: string, compiler: Compiler, filepath: Filepath, target: ElementIdentifier, key: string, value: TypedValue | null): {
11
+ newDbml: string;
12
+ edits: TextEdit[];
13
+ };
@@ -70,20 +70,22 @@ export declare function escapeString(str: string): string;
70
70
  * @returns The formatted string representation for DBML
71
71
  *
72
72
  * @example
73
- * formatRecordValue({ value: 1, type: 'integer' }) => '1'
74
- * formatRecordValue({ value: 'Alice', type: 'string' }) => "'Alice'"
75
- * formatRecordValue({ value: true, type: 'bool' }) => 'true'
76
- * formatRecordValue({ value: null, type: 'string' }) => 'null'
77
- * formatRecordValue(undefined) => 'null'
78
- * formatRecordValue(null) => 'null'
79
- * formatRecordValue('Alice') => "'Alice'"
80
- * formatRecordValue(42) => '42'
81
- * formatRecordValue(true) => 'true'
73
+ * formatTypedValue({ value: 1, type: 'integer' }) => '1'
74
+ * formatTypedValue({ value: 'Alice', type: 'string' }) => "'Alice'"
75
+ * formatTypedValue({ value: true, type: 'bool' }) => 'true'
76
+ * formatTypedValue({ value: null, type: 'string' }) => 'null'
77
+ * formatTypedValue({ value: '#ff0000', type: 'color' }) => '#ff0000'
78
+ * formatTypedValue(undefined) => 'null'
79
+ * formatTypedValue(null) => 'null'
80
+ * formatTypedValue('Alice') => "'Alice'"
81
+ * formatTypedValue(42) => '42'
82
+ * formatTypedValue(true) => 'true'
82
83
  */
83
- export declare function formatRecordValue(recordValue: {
84
+ export type TypedValue = {
84
85
  value: any;
85
86
  type: string;
86
- } | string | number | boolean | null | undefined): string;
87
+ } | string | number | boolean | null | undefined;
88
+ export declare function formatTypedValue(recordValue: TypedValue): string;
87
89
  /**
88
90
  * Splits a qualified identifier string into its components, handling quoted segments.
89
91
  *
@@ -130,7 +130,8 @@ export declare enum CompileErrorCode {
130
130
  TABLE_REAPPEAR_IN_TABLEGROUP = 5009,
131
131
  INVALID_METADATA_TARGET_KIND = 5010,
132
132
  INVALID_METADATA_FIELD = 5011,
133
- DUPLICATE_METADATA_FIELD = 5012
133
+ DUPLICATE_METADATA_FIELD = 5012,
134
+ IMPORTED_FILE_HAS_ERRORS = 5013
134
135
  }
135
136
  export interface RelatedLocation {
136
137
  nodeOrToken: SyntaxNode | SyntaxToken;
@@ -11,11 +11,11 @@ export { SyntaxToken, SyntaxTokenKind, isTriviaToken, isOp, isOpToken, } from '.
11
11
  export { CompileError, CompileErrorCode, CompileWarning, CompileInfo, } from './core/types/errors';
12
12
  export type { Diagnostic, DiagnosticQuickFix } from './services/diagnostics/provider';
13
13
  export type { Position, } from './core/types';
14
- export { ScopeKind, splitQualifiedIdentifier, unescapeString, escapeString, formatRecordValue, isValidIdentifier, addDoubleQuoteIfNeeded, normalizeQualifiedName, } from './compiler/index';
14
+ export { ScopeKind, splitQualifiedIdentifier, unescapeString, escapeString, formatTypedValue, type TypedValue, isValidIdentifier, addDoubleQuoteIfNeeded, normalizeQualifiedName, } from './compiler/index';
15
15
  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, type CustomMetadataValue, type CustomMetadataValueType, } from './core/types/schemaJson';
16
16
  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';
17
17
  export type { DiagramViewSyncOperation, DiagramViewBlock, TextEdit, } from './compiler/queries/transform';
18
- export { findDiagramViewBlocks } from './compiler/queries/transform';
18
+ export { findDiagramViewBlocks, syncElementMetadata, applyTextEdits } from './compiler/queries/transform';
19
19
  export type { DepSyncOperation, DepSyncEdge, DepEndpointRef } from './compiler/queries/transform';
20
20
  export type { ElementIdentifier, SchemaIdentifier, TableIdentifier, ColumnIdentifier, EnumIdentifier, EndpointRef, RefIdentifier, DepIdentifier, NoteIdentifier, TableGroupIdentifier, } from './compiler/queries/transform';
21
21
  export { dbmlLanguageConfig, dbmlMonarchTokensProvider, } from './services/monarch';
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": "11.0.0",
4
+ "version": "11.0.1-alpha.0",
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": "4b89ec80f0a469407953b7c670f8c5fda4638b28"
54
+ "gitHead": "af62dc01c834b6183e9557f98b4d807313c4565a"
55
55
  }