@dbml/parse 9.0.0-alpha.3 → 9.0.0-alpha.5

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.
Files changed (173) hide show
  1. package/LICENSE +0 -0
  2. package/dist/__benchmarks__/compiler.benchmark.d.ts +0 -0
  3. package/dist/__benchmarks__/compiler.profile.d.ts +0 -0
  4. package/dist/dbml-parse.js +15 -14
  5. package/dist/dbml-parse.mjs +2259 -2089
  6. package/dist/index.d.ts +0 -0
  7. package/dist/src/compiler/index.d.ts +1 -1
  8. package/dist/src/compiler/projectLayout/index.d.ts +0 -0
  9. package/dist/src/compiler/projectLayout/layout.d.ts +0 -0
  10. package/dist/src/compiler/queries/canonicalName.d.ts +0 -0
  11. package/dist/src/compiler/queries/container/element.d.ts +0 -0
  12. package/dist/src/compiler/queries/container/index.d.ts +0 -0
  13. package/dist/src/compiler/queries/container/scope.d.ts +0 -0
  14. package/dist/src/compiler/queries/container/scopeKind.d.ts +0 -0
  15. package/dist/src/compiler/queries/container/stack.d.ts +0 -0
  16. package/dist/src/compiler/queries/container/token.d.ts +0 -0
  17. package/dist/src/compiler/queries/files/fileDependencies.d.ts +0 -0
  18. package/dist/src/compiler/queries/files/reachableFiles.d.ts +0 -0
  19. package/dist/src/compiler/queries/files/usableMembers.d.ts +0 -0
  20. package/dist/src/compiler/queries/legacy/parse.d.ts +0 -0
  21. package/dist/src/compiler/queries/legacy/symbol.d.ts +0 -0
  22. package/dist/src/compiler/queries/legacy/token.d.ts +0 -0
  23. package/dist/src/compiler/queries/nodeAtPosition.d.ts +0 -0
  24. package/dist/src/compiler/queries/pipeline/bind.d.ts +0 -0
  25. package/dist/src/compiler/queries/pipeline/index.d.ts +0 -0
  26. package/dist/src/compiler/queries/pipeline/interpret.d.ts +0 -0
  27. package/dist/src/compiler/queries/pipeline/parse.d.ts +0 -0
  28. package/dist/src/compiler/queries/pipeline/validate.d.ts +0 -0
  29. package/dist/src/compiler/queries/resolutionIndex.d.ts +0 -0
  30. package/dist/src/compiler/queries/symbol/lookupMembers.d.ts +0 -0
  31. package/dist/src/compiler/queries/symbol/symbolAliases.d.ts +0 -0
  32. package/dist/src/compiler/queries/symbol/symbolUses.d.ts +0 -0
  33. package/dist/src/compiler/queries/transform/applyTextEdits.d.ts +0 -0
  34. package/dist/src/compiler/queries/transform/index.d.ts +0 -0
  35. package/dist/src/compiler/queries/transform/renameTable.d.ts +0 -0
  36. package/dist/src/compiler/queries/transform/syncDep.d.ts +11 -49
  37. package/dist/src/compiler/queries/transform/syncDiagramView.d.ts +0 -0
  38. package/dist/src/compiler/queries/transform/utils.d.ts +0 -0
  39. package/dist/src/compiler/queries/utils.d.ts +5 -0
  40. package/dist/src/compiler/types.d.ts +0 -0
  41. package/dist/src/constants.d.ts +0 -0
  42. package/dist/src/core/global_modules/checks/bind.d.ts +0 -0
  43. package/dist/src/core/global_modules/checks/index.d.ts +0 -0
  44. package/dist/src/core/global_modules/checks/interpret.d.ts +0 -0
  45. package/dist/src/core/global_modules/dep/bind.d.ts +0 -0
  46. package/dist/src/core/global_modules/dep/index.d.ts +0 -0
  47. package/dist/src/core/global_modules/dep/interpret.d.ts +2 -2
  48. package/dist/src/core/global_modules/diagramView/bind.d.ts +0 -0
  49. package/dist/src/core/global_modules/diagramView/index.d.ts +0 -0
  50. package/dist/src/core/global_modules/diagramView/interpret.d.ts +0 -0
  51. package/dist/src/core/global_modules/enum/bind.d.ts +0 -0
  52. package/dist/src/core/global_modules/enum/index.d.ts +0 -0
  53. package/dist/src/core/global_modules/enum/interpret.d.ts +0 -0
  54. package/dist/src/core/global_modules/index.d.ts +0 -0
  55. package/dist/src/core/global_modules/indexes/bind.d.ts +0 -0
  56. package/dist/src/core/global_modules/indexes/index.d.ts +0 -0
  57. package/dist/src/core/global_modules/indexes/interpret.d.ts +0 -0
  58. package/dist/src/core/global_modules/note/bind.d.ts +0 -0
  59. package/dist/src/core/global_modules/note/index.d.ts +0 -0
  60. package/dist/src/core/global_modules/note/interpret.d.ts +0 -0
  61. package/dist/src/core/global_modules/program/bind.d.ts +0 -0
  62. package/dist/src/core/global_modules/program/index.d.ts +0 -0
  63. package/dist/src/core/global_modules/program/interpret.d.ts +0 -0
  64. package/dist/src/core/global_modules/program/utils.d.ts +0 -0
  65. package/dist/src/core/global_modules/project/bind.d.ts +0 -0
  66. package/dist/src/core/global_modules/project/index.d.ts +0 -0
  67. package/dist/src/core/global_modules/project/interpret.d.ts +0 -0
  68. package/dist/src/core/global_modules/records/bind.d.ts +0 -0
  69. package/dist/src/core/global_modules/records/index.d.ts +0 -0
  70. package/dist/src/core/global_modules/records/interpret.d.ts +0 -0
  71. package/dist/src/core/global_modules/records/utils/constraints/fk.d.ts +0 -0
  72. package/dist/src/core/global_modules/records/utils/constraints/helper.d.ts +0 -0
  73. package/dist/src/core/global_modules/records/utils/constraints/index.d.ts +0 -0
  74. package/dist/src/core/global_modules/records/utils/constraints/pk.d.ts +0 -0
  75. package/dist/src/core/global_modules/records/utils/constraints/unique.d.ts +0 -0
  76. package/dist/src/core/global_modules/records/utils/data/index.d.ts +0 -0
  77. package/dist/src/core/global_modules/records/utils/data/sqlTypes.d.ts +0 -0
  78. package/dist/src/core/global_modules/records/utils/data/values.d.ts +0 -0
  79. package/dist/src/core/global_modules/records/utils/index.d.ts +0 -0
  80. package/dist/src/core/global_modules/ref/bind.d.ts +0 -0
  81. package/dist/src/core/global_modules/ref/index.d.ts +0 -0
  82. package/dist/src/core/global_modules/ref/interpret.d.ts +0 -0
  83. package/dist/src/core/global_modules/schema/index.d.ts +0 -0
  84. package/dist/src/core/global_modules/table/bind.d.ts +0 -0
  85. package/dist/src/core/global_modules/table/index.d.ts +0 -0
  86. package/dist/src/core/global_modules/table/interpret.d.ts +0 -0
  87. package/dist/src/core/global_modules/table/utils.d.ts +0 -0
  88. package/dist/src/core/global_modules/tableGroup/bind.d.ts +0 -0
  89. package/dist/src/core/global_modules/tableGroup/index.d.ts +0 -0
  90. package/dist/src/core/global_modules/tableGroup/interpret.d.ts +0 -0
  91. package/dist/src/core/global_modules/tablePartial/bind.d.ts +0 -0
  92. package/dist/src/core/global_modules/tablePartial/index.d.ts +0 -0
  93. package/dist/src/core/global_modules/tablePartial/interpret.d.ts +0 -0
  94. package/dist/src/core/global_modules/types.d.ts +0 -0
  95. package/dist/src/core/global_modules/use/index.d.ts +0 -0
  96. package/dist/src/core/global_modules/utils.d.ts +0 -0
  97. package/dist/src/core/lexer/lexer.d.ts +0 -0
  98. package/dist/src/core/lexer/utils.d.ts +0 -0
  99. package/dist/src/core/local_modules/checks/index.d.ts +0 -0
  100. package/dist/src/core/local_modules/checks/validate.d.ts +0 -0
  101. package/dist/src/core/local_modules/custom/index.d.ts +0 -0
  102. package/dist/src/core/local_modules/custom/validate.d.ts +0 -0
  103. package/dist/src/core/local_modules/dep/index.d.ts +0 -0
  104. package/dist/src/core/local_modules/dep/validate.d.ts +1 -0
  105. package/dist/src/core/local_modules/diagramView/index.d.ts +0 -0
  106. package/dist/src/core/local_modules/diagramView/validate.d.ts +0 -0
  107. package/dist/src/core/local_modules/enum/index.d.ts +0 -0
  108. package/dist/src/core/local_modules/enum/validate.d.ts +0 -0
  109. package/dist/src/core/local_modules/index.d.ts +0 -0
  110. package/dist/src/core/local_modules/indexes/index.d.ts +0 -0
  111. package/dist/src/core/local_modules/indexes/validate.d.ts +0 -0
  112. package/dist/src/core/local_modules/note/index.d.ts +0 -0
  113. package/dist/src/core/local_modules/note/validate.d.ts +0 -0
  114. package/dist/src/core/local_modules/program/index.d.ts +0 -0
  115. package/dist/src/core/local_modules/program/validate.d.ts +0 -0
  116. package/dist/src/core/local_modules/project/index.d.ts +0 -0
  117. package/dist/src/core/local_modules/project/validate.d.ts +0 -0
  118. package/dist/src/core/local_modules/records/index.d.ts +0 -0
  119. package/dist/src/core/local_modules/records/validate.d.ts +0 -0
  120. package/dist/src/core/local_modules/ref/index.d.ts +0 -0
  121. package/dist/src/core/local_modules/ref/validate.d.ts +0 -0
  122. package/dist/src/core/local_modules/table/index.d.ts +0 -0
  123. package/dist/src/core/local_modules/table/validate.d.ts +0 -0
  124. package/dist/src/core/local_modules/tableGroup/index.d.ts +0 -0
  125. package/dist/src/core/local_modules/tableGroup/validate.d.ts +0 -0
  126. package/dist/src/core/local_modules/tablePartial/index.d.ts +0 -0
  127. package/dist/src/core/local_modules/tablePartial/validate.d.ts +0 -0
  128. package/dist/src/core/local_modules/types.d.ts +0 -0
  129. package/dist/src/core/local_modules/use/index.d.ts +0 -0
  130. package/dist/src/core/local_modules/use/validate.d.ts +0 -0
  131. package/dist/src/core/parser/contextStack.d.ts +0 -0
  132. package/dist/src/core/parser/factory.d.ts +0 -0
  133. package/dist/src/core/parser/parser.d.ts +0 -0
  134. package/dist/src/core/parser/utils.d.ts +0 -0
  135. package/dist/src/core/types/errors.d.ts +0 -0
  136. package/dist/src/core/types/filepath.d.ts +0 -0
  137. package/dist/src/core/types/index.d.ts +0 -0
  138. package/dist/src/core/types/internable.d.ts +0 -0
  139. package/dist/src/core/types/keywords.d.ts +0 -0
  140. package/dist/src/core/types/module.d.ts +0 -0
  141. package/dist/src/core/types/nodes.d.ts +0 -0
  142. package/dist/src/core/types/position.d.ts +0 -0
  143. package/dist/src/core/types/report.d.ts +0 -0
  144. package/dist/src/core/types/schemaJson.d.ts +5 -2
  145. package/dist/src/core/types/symbol/factory.d.ts +0 -0
  146. package/dist/src/core/types/symbol/index.d.ts +0 -0
  147. package/dist/src/core/types/symbol/metadata.d.ts +0 -0
  148. package/dist/src/core/types/symbol/symbols.d.ts +0 -0
  149. package/dist/src/core/types/tokens.d.ts +0 -0
  150. package/dist/src/core/utils/chars.d.ts +0 -0
  151. package/dist/src/core/utils/expression.d.ts +0 -0
  152. package/dist/src/core/utils/interpret.d.ts +0 -0
  153. package/dist/src/core/utils/note.d.ts +18 -0
  154. package/dist/src/core/utils/numbers.d.ts +0 -0
  155. package/dist/src/core/utils/setting.d.ts +17 -0
  156. package/dist/src/core/utils/span.d.ts +0 -0
  157. package/dist/src/core/utils/tokens.d.ts +0 -0
  158. package/dist/src/core/utils/validate.d.ts +0 -0
  159. package/dist/src/index.d.ts +0 -0
  160. package/dist/src/services/definition/provider.d.ts +0 -0
  161. package/dist/src/services/diagnostics/provider.d.ts +0 -0
  162. package/dist/src/services/index.d.ts +0 -0
  163. package/dist/src/services/monarch.d.ts +0 -0
  164. package/dist/src/services/references/provider.d.ts +0 -0
  165. package/dist/src/services/suggestions/crossFile.d.ts +0 -0
  166. package/dist/src/services/suggestions/provider.d.ts +0 -0
  167. package/dist/src/services/suggestions/recordRowSnippet.d.ts +0 -0
  168. package/dist/src/services/suggestions/use.d.ts +0 -0
  169. package/dist/src/services/suggestions/utils/index.d.ts +0 -0
  170. package/dist/src/services/suggestions/utils/useMerger.d.ts +0 -0
  171. package/dist/src/services/types.d.ts +0 -0
  172. package/dist/src/services/utils.d.ts +0 -0
  173. package/package.json +2 -2
package/dist/index.d.ts CHANGED
File without changes
@@ -6,7 +6,7 @@ import { DbmlProjectLayout } from './projectLayout';
6
6
  import { DiagramViewBlock, DepBlock, findDiagramViewBlocks, findDepBlocks } from './queries/transform';
7
7
  import { addDoubleQuoteIfNeeded, escapeString, formatRecordValue, isValidIdentifier, splitQualifiedIdentifier, unescapeString } from './queries/utils';
8
8
  export { ScopeKind } from './types';
9
- export type { DiagramViewBlock, DepBlock, TableNameInput, TextEdit } from './queries/transform';
9
+ export type { DiagramViewBlock, DepBlock, TableNameInput, TextEdit, } from './queries/transform';
10
10
  export { addDoubleQuoteIfNeeded, escapeString, formatRecordValue, isValidIdentifier, splitQualifiedIdentifier, unescapeString, findDiagramViewBlocks, findDepBlocks, };
11
11
  export default class Compiler {
12
12
  layout: DbmlProjectLayout;
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -1,7 +1,7 @@
1
1
  import { Filepath } from '../../../core/types/filepath';
2
+ import { ElementDeclarationNode } from '../../../core/types/nodes';
2
3
  import { default as Compiler } from '../../index';
3
4
  import { TextEdit } from './applyTextEdits';
4
- /** One endpoint of a dep edge. `fieldNames` is empty for a table-level edge. */
5
5
  export interface DepEndpointRef {
6
6
  schemaName?: string | null;
7
7
  tableName: string;
@@ -15,53 +15,21 @@ export interface DepSyncOperation {
15
15
  operation: 'create' | 'update' | 'remove';
16
16
  /** The edge that identifies the target block (table-level: empty fieldNames). */
17
17
  edge: DepSyncEdge;
18
- color?: string;
19
- }
20
- /**
21
- * A `color` setting found on a block.
22
- *
23
- * `kind` says how to overwrite it:
24
- * - `attribute` -> replace just the `color: <hex>` attribute at `start..end`
25
- * (inside a `[...]` list that may hold other settings).
26
- * - `subDeclaration` -> replace the whole `color: <hex>` body line at
27
- * `start..end`.
28
- */
29
- interface ColorSetting {
30
- kind: 'attribute' | 'subDeclaration';
31
- start: number;
32
- end: number;
33
- /**
34
- * Range to delete when removing the color (revert to default). Wider than
35
- * `start..end`: for an attribute it swallows the whole enclosing `[...]` when
36
- * color is the sole setting, otherwise one adjacent comma; for a
37
- * sub-declaration it is the same as `start..end` (the whole body line).
38
- */
39
- stripStart: number;
40
- stripEnd: number;
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;
41
22
  }
42
23
  export interface DepBlock {
43
24
  startIndex: number;
44
25
  endIndex: number;
26
+ declaration: ElementDeclarationNode;
45
27
  edges: DepSyncEdge[];
46
- /**
47
- * An existing header `[...]` attribute list (without a color setting), so a
48
- * color can be inserted into it instead of adding a second `[...]`.
49
- * Records the offset just before the list's closing `]`.
50
- */
51
- attributeListInsertAt?: number;
52
- attributeListIsEmpty?: boolean;
53
- /**
54
- * Offset of the block body `{` - where to add a header `[color: ...]` for a
55
- * block-form Dep that has no attribute list.
56
- */
57
- bodyOpenAt?: number;
58
- /**
59
- * End offset of a short-form (`Dep: a -> b`) body that has no setting list -
60
- * where to append ` [color: ...]`.
61
- */
62
- shortFormEnd?: number;
63
- /** The existing color setting (header list, inline list, or sub-declaration), if any. */
64
- color?: ColorSetting;
28
+ }
29
+ export interface InlineDep {
30
+ edge: DepSyncEdge;
31
+ stripStart: number;
32
+ stripEnd: number;
65
33
  }
66
34
  /**
67
35
  * Returns every `Dep` block in `source`.
@@ -69,11 +37,6 @@ export interface DepBlock {
69
37
  * dep blocks from malformed DBML (mirrors findDiagramViewBlocks).
70
38
  */
71
39
  export declare function findDepBlocks(source: string): DepBlock[];
72
- export interface InlineDep {
73
- edge: DepSyncEdge;
74
- stripStart: number;
75
- stripEnd: number;
76
- }
77
40
  export declare function findInlineDeps(source: string): InlineDep[];
78
41
  /**
79
42
  * Emit a `Dep` block for one edge with a `[color]` setting:
@@ -95,4 +58,3 @@ export declare function syncDep(this: Compiler, filepath: Filepath, operations:
95
58
  newDbml: string;
96
59
  edits: TextEdit[];
97
60
  };
98
- export {};
File without changes
@@ -99,3 +99,8 @@ export declare function formatRecordValue(recordValue: {
99
99
  export declare function splitQualifiedIdentifier(identifier: string): string[];
100
100
  export declare function collectTransitiveDependencies(compiler: Compiler, entrypoints: Filepath[]): Filepath[];
101
101
  export declare function allVisibleMembers(compiler: Compiler): Report<NodeSymbol[]>;
102
+ /**
103
+ * Wraps a note value in the appropriate DBML quote style.
104
+ * Uses triple quotes for multiline content, single quotes otherwise.
105
+ */
106
+ export declare function quoteNoteValue(value: string): string;
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -13,7 +13,7 @@ export declare class DepInterpreter {
13
13
  private interpretName;
14
14
  private interpretEdges;
15
15
  /**
16
- * Read settings into `dep.note` and `dep.custom`.
16
+ * Read settings into `dep.note` and `dep.metadata`.
17
17
  *
18
18
  * Settings come from THREE sources, in this order:
19
19
  * 1. The top-level attribute list on the Dep header
@@ -23,7 +23,7 @@ export declare class DepInterpreter {
23
23
  * 3. Sub-element declarations inside the body
24
24
  * (e.g. `Dep { a -> b; note: 'x'; materialized: 'view' }`).
25
25
  *
26
- * All three sources write into the same `custom` object (with `note`
26
+ * All three sources write into the same `metadata` object (with `note`
27
27
  * routed to the typed slot instead). Precedence is last-write-wins by
28
28
  * virtue of plain object assignment — settings later in the source
29
29
  * file overwrite earlier ones with the same key.
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -8,6 +8,7 @@ export default class DepValidator {
8
8
  private compiler;
9
9
  constructor(compiler: Compiler, declarationNode: ElementDeclarationNode);
10
10
  validate(): CompileError[];
11
+ private validateSettings;
11
12
  private validateContext;
12
13
  private validateName;
13
14
  private validateAlias;
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -182,7 +182,7 @@ export interface Dep {
182
182
  value: string;
183
183
  token: TokenPosition;
184
184
  };
185
- custom?: Record<string, string | number | boolean | null>;
185
+ metadata?: Record<string, string | number | boolean | null>;
186
186
  token: TokenPosition;
187
187
  }
188
188
  export interface DepEdge {
@@ -196,11 +196,14 @@ export interface DepEndpoint {
196
196
  fieldNames: string[];
197
197
  token: TokenPosition;
198
198
  }
199
+ export declare const DEP_DOWNSTREAM: "->";
200
+ export declare const DEP_UPSTREAM: "<-";
201
+ export type DepDirection = typeof DEP_DOWNSTREAM | typeof DEP_UPSTREAM;
199
202
  export interface InlineDep {
200
203
  schemaName: string | null;
201
204
  tableName: string;
202
205
  fieldNames: string[];
203
- direction: '->' | '<-';
206
+ direction: DepDirection;
204
207
  token: TokenPosition;
205
208
  }
206
209
  export interface Enum {
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -0,0 +1,18 @@
1
+ import { SyntaxNode } from '../types/nodes';
2
+ import { TextEdit } from '../../compiler/queries/transform/applyTextEdits';
3
+ /**
4
+ * Produces a TextEdit that updates an existing note's value.
5
+ * Returns undefined if no note exists.
6
+ */
7
+ export declare function updateNoteEdit(declaration: SyntaxNode, newValue: string): TextEdit | undefined;
8
+ /**
9
+ * Produces a TextEdit that removes an existing note.
10
+ * Returns undefined if no note exists.
11
+ */
12
+ export declare function removeNoteEdit(declaration: SyntaxNode): TextEdit | undefined;
13
+ /**
14
+ * Produces a TextEdit that adds a note to an element.
15
+ * Prioritizes body note form for block elements, falls back to setting attribute.
16
+ * Returns undefined if a note already exists.
17
+ */
18
+ export declare function addNoteEdit(declaration: SyntaxNode, value: string): TextEdit | undefined;
File without changes
@@ -0,0 +1,17 @@
1
+ import { SyntaxNode } from '../types/nodes';
2
+ import { TextEdit } from '../../compiler/queries/transform/applyTextEdits';
3
+ /**
4
+ * Produces a TextEdit that adds a setting to a field/element declaration.
5
+ * If the declaration already has a settings block [...], inserts before the closing ].
6
+ * Otherwise, appends a new [setting] block.
7
+ */
8
+ export declare function addSettingEdit(declaration: SyntaxNode, setting: string): TextEdit | undefined;
9
+ /**
10
+ * Produces a TextEdit that updates an existing setting's value in a declaration.
11
+ */
12
+ export declare function updateSettingEdit(declaration: SyntaxNode, settingName: string, newValue: string, source: string): TextEdit | undefined;
13
+ /**
14
+ * Produces a TextEdit that removes a setting from a declaration.
15
+ * If it's the only setting, removes the entire settings block [...].
16
+ */
17
+ export declare function removeSettingEdit(declaration: SyntaxNode, settingName: string, source: string): TextEdit | undefined;
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes