@dbml/parse 9.0.0-alpha.3 → 9.0.0-optional-ref.2

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 (176) 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 +19 -22
  5. package/dist/dbml-parse.mjs +8564 -8807
  6. package/dist/index.d.ts +0 -0
  7. package/dist/src/compiler/index.d.ts +9 -10
  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/addSetting.d.ts +14 -0
  34. package/dist/src/compiler/queries/transform/applyTextEdits.d.ts +0 -0
  35. package/dist/src/compiler/queries/transform/index.d.ts +2 -1
  36. package/dist/src/compiler/queries/transform/renameTable.d.ts +0 -0
  37. package/dist/src/compiler/queries/transform/syncDiagramView.d.ts +0 -0
  38. package/dist/src/compiler/queries/transform/updateSetting.d.ts +8 -0
  39. package/dist/src/compiler/queries/transform/utils.d.ts +0 -0
  40. package/dist/src/compiler/queries/utils.d.ts +0 -0
  41. package/dist/src/compiler/types.d.ts +7 -8
  42. package/dist/src/constants.d.ts +0 -0
  43. package/dist/src/core/global_modules/checks/bind.d.ts +0 -0
  44. package/dist/src/core/global_modules/checks/index.d.ts +0 -0
  45. package/dist/src/core/global_modules/checks/interpret.d.ts +0 -0
  46. package/dist/src/core/global_modules/diagramView/bind.d.ts +0 -0
  47. package/dist/src/core/global_modules/diagramView/index.d.ts +0 -0
  48. package/dist/src/core/global_modules/diagramView/interpret.d.ts +0 -0
  49. package/dist/src/core/global_modules/enum/bind.d.ts +0 -0
  50. package/dist/src/core/global_modules/enum/index.d.ts +0 -0
  51. package/dist/src/core/global_modules/enum/interpret.d.ts +0 -0
  52. package/dist/src/core/global_modules/index.d.ts +0 -0
  53. package/dist/src/core/global_modules/indexes/bind.d.ts +0 -0
  54. package/dist/src/core/global_modules/indexes/index.d.ts +0 -0
  55. package/dist/src/core/global_modules/indexes/interpret.d.ts +0 -0
  56. package/dist/src/core/global_modules/note/bind.d.ts +0 -0
  57. package/dist/src/core/global_modules/note/index.d.ts +0 -0
  58. package/dist/src/core/global_modules/note/interpret.d.ts +0 -0
  59. package/dist/src/core/global_modules/program/bind.d.ts +0 -0
  60. package/dist/src/core/global_modules/program/index.d.ts +0 -0
  61. package/dist/src/core/global_modules/program/interpret.d.ts +2 -0
  62. package/dist/src/core/global_modules/program/utils.d.ts +0 -0
  63. package/dist/src/core/global_modules/project/bind.d.ts +0 -0
  64. package/dist/src/core/global_modules/project/index.d.ts +0 -0
  65. package/dist/src/core/global_modules/project/interpret.d.ts +0 -0
  66. package/dist/src/core/global_modules/records/bind.d.ts +0 -0
  67. package/dist/src/core/global_modules/records/index.d.ts +0 -0
  68. package/dist/src/core/global_modules/records/interpret.d.ts +0 -0
  69. package/dist/src/core/global_modules/records/utils/constraints/fk.d.ts +0 -0
  70. package/dist/src/core/global_modules/records/utils/constraints/helper.d.ts +4 -17
  71. package/dist/src/core/global_modules/records/utils/constraints/index.d.ts +0 -0
  72. package/dist/src/core/global_modules/records/utils/constraints/pk.d.ts +0 -0
  73. package/dist/src/core/global_modules/records/utils/constraints/unique.d.ts +0 -0
  74. package/dist/src/core/global_modules/records/utils/data/index.d.ts +0 -0
  75. package/dist/src/core/global_modules/records/utils/data/sqlTypes.d.ts +0 -0
  76. package/dist/src/core/global_modules/records/utils/data/values.d.ts +0 -0
  77. package/dist/src/core/global_modules/records/utils/index.d.ts +0 -0
  78. package/dist/src/core/global_modules/ref/bind.d.ts +0 -0
  79. package/dist/src/core/global_modules/ref/constraint_fixes.d.ts +8 -0
  80. package/dist/src/core/global_modules/ref/index.d.ts +0 -1
  81. package/dist/src/core/global_modules/ref/interpret.d.ts +1 -0
  82. package/dist/src/core/global_modules/schema/index.d.ts +0 -0
  83. package/dist/src/core/global_modules/table/bind.d.ts +0 -2
  84. package/dist/src/core/global_modules/table/index.d.ts +0 -0
  85. package/dist/src/core/global_modules/table/interpret.d.ts +0 -0
  86. package/dist/src/core/global_modules/table/utils.d.ts +0 -0
  87. package/dist/src/core/global_modules/tableGroup/bind.d.ts +0 -0
  88. package/dist/src/core/global_modules/tableGroup/index.d.ts +0 -0
  89. package/dist/src/core/global_modules/tableGroup/interpret.d.ts +0 -0
  90. package/dist/src/core/global_modules/tablePartial/bind.d.ts +0 -0
  91. package/dist/src/core/global_modules/tablePartial/index.d.ts +0 -0
  92. package/dist/src/core/global_modules/tablePartial/interpret.d.ts +0 -0
  93. package/dist/src/core/global_modules/types.d.ts +0 -0
  94. package/dist/src/core/global_modules/use/index.d.ts +0 -0
  95. package/dist/src/core/global_modules/utils.d.ts +0 -2
  96. package/dist/src/core/lexer/lexer.d.ts +0 -0
  97. package/dist/src/core/lexer/utils.d.ts +0 -0
  98. package/dist/src/core/local_modules/checks/index.d.ts +0 -0
  99. package/dist/src/core/local_modules/checks/validate.d.ts +0 -0
  100. package/dist/src/core/local_modules/custom/index.d.ts +0 -0
  101. package/dist/src/core/local_modules/custom/validate.d.ts +0 -0
  102. package/dist/src/core/local_modules/diagramView/index.d.ts +0 -0
  103. package/dist/src/core/local_modules/diagramView/validate.d.ts +0 -0
  104. package/dist/src/core/local_modules/enum/index.d.ts +0 -0
  105. package/dist/src/core/local_modules/enum/validate.d.ts +0 -0
  106. package/dist/src/core/local_modules/index.d.ts +0 -0
  107. package/dist/src/core/local_modules/indexes/index.d.ts +0 -0
  108. package/dist/src/core/local_modules/indexes/validate.d.ts +0 -0
  109. package/dist/src/core/local_modules/note/index.d.ts +0 -0
  110. package/dist/src/core/local_modules/note/validate.d.ts +0 -0
  111. package/dist/src/core/local_modules/program/index.d.ts +0 -0
  112. package/dist/src/core/local_modules/program/validate.d.ts +0 -0
  113. package/dist/src/core/local_modules/project/index.d.ts +0 -0
  114. package/dist/src/core/local_modules/project/validate.d.ts +0 -0
  115. package/dist/src/core/local_modules/records/index.d.ts +0 -0
  116. package/dist/src/core/local_modules/records/validate.d.ts +0 -0
  117. package/dist/src/core/local_modules/ref/index.d.ts +0 -0
  118. package/dist/src/core/local_modules/ref/validate.d.ts +0 -0
  119. package/dist/src/core/local_modules/table/index.d.ts +0 -0
  120. package/dist/src/core/local_modules/table/validate.d.ts +0 -0
  121. package/dist/src/core/local_modules/tableGroup/index.d.ts +0 -0
  122. package/dist/src/core/local_modules/tableGroup/validate.d.ts +0 -0
  123. package/dist/src/core/local_modules/tablePartial/index.d.ts +0 -0
  124. package/dist/src/core/local_modules/tablePartial/validate.d.ts +0 -0
  125. package/dist/src/core/local_modules/types.d.ts +0 -0
  126. package/dist/src/core/local_modules/use/index.d.ts +0 -0
  127. package/dist/src/core/local_modules/use/validate.d.ts +0 -0
  128. package/dist/src/core/parser/contextStack.d.ts +0 -0
  129. package/dist/src/core/parser/factory.d.ts +0 -0
  130. package/dist/src/core/parser/parser.d.ts +0 -0
  131. package/dist/src/core/parser/utils.d.ts +0 -0
  132. package/dist/src/core/types/errors.d.ts +75 -52
  133. package/dist/src/core/types/filepath.d.ts +0 -0
  134. package/dist/src/core/types/index.d.ts +0 -0
  135. package/dist/src/core/types/internable.d.ts +0 -0
  136. package/dist/src/core/types/keywords.d.ts +0 -2
  137. package/dist/src/core/types/module.d.ts +0 -0
  138. package/dist/src/core/types/nodes.d.ts +0 -0
  139. package/dist/src/core/types/position.d.ts +0 -0
  140. package/dist/src/core/types/relation.d.ts +19 -0
  141. package/dist/src/core/types/report.d.ts +5 -3
  142. package/dist/src/core/types/schemaJson.d.ts +3 -35
  143. package/dist/src/core/types/symbol/factory.d.ts +0 -0
  144. package/dist/src/core/types/symbol/index.d.ts +0 -0
  145. package/dist/src/core/types/symbol/metadata.d.ts +25 -17
  146. package/dist/src/core/types/symbol/symbols.d.ts +4 -1
  147. package/dist/src/core/types/tokens.d.ts +0 -0
  148. package/dist/src/core/utils/chars.d.ts +0 -0
  149. package/dist/src/core/utils/expression.d.ts +0 -0
  150. package/dist/src/core/utils/interpret.d.ts +0 -0
  151. package/dist/src/core/utils/numbers.d.ts +0 -0
  152. package/dist/src/core/utils/span.d.ts +0 -0
  153. package/dist/src/core/utils/tokens.d.ts +0 -0
  154. package/dist/src/core/utils/validate.d.ts +0 -0
  155. package/dist/src/index.d.ts +2 -2
  156. package/dist/src/services/code_actions/provider.d.ts +8 -0
  157. package/dist/src/services/definition/provider.d.ts +0 -0
  158. package/dist/src/services/diagnostics/provider.d.ts +7 -1
  159. package/dist/src/services/index.d.ts +2 -1
  160. package/dist/src/services/monarch.d.ts +0 -0
  161. package/dist/src/services/references/provider.d.ts +0 -0
  162. package/dist/src/services/suggestions/crossFile.d.ts +0 -0
  163. package/dist/src/services/suggestions/provider.d.ts +0 -0
  164. package/dist/src/services/suggestions/recordRowSnippet.d.ts +0 -0
  165. package/dist/src/services/suggestions/use.d.ts +0 -0
  166. package/dist/src/services/suggestions/utils/index.d.ts +0 -0
  167. package/dist/src/services/suggestions/utils/useMerger.d.ts +0 -0
  168. package/dist/src/services/types.d.ts +5 -1
  169. package/dist/src/services/utils.d.ts +0 -0
  170. package/package.json +2 -2
  171. package/dist/src/compiler/queries/transform/syncDep.d.ts +0 -98
  172. package/dist/src/core/global_modules/dep/bind.d.ts +0 -15
  173. package/dist/src/core/global_modules/dep/index.d.ts +0 -2
  174. package/dist/src/core/global_modules/dep/interpret.d.ts +0 -34
  175. package/dist/src/core/local_modules/dep/index.d.ts +0 -2
  176. package/dist/src/core/local_modules/dep/validate.d.ts +0 -18
@@ -56,58 +56,56 @@ export declare enum CompileErrorCode {
56
56
  INVALID_REF_FIELD = 3039,
57
57
  EMPTY_REF = 3040,
58
58
  REF_REDEFINED = 3041,
59
- INVALID_DEP_CONTEXT = 3042,
60
- INVALID_DEP_FIELD = 3043,
61
- INVALID_NOTE_CONTEXT = 3044,
62
- INVALID_NOTE = 3045,
63
- NOTE_REDEFINED = 3046,
64
- NOTE_CONTENT_REDEFINED = 3047,
65
- EMPTY_NOTE = 3048,
66
- UNKNOWN_NOTE_SETTING = 3049,
67
- DUPLICATE_NOTE_SETTING = 3050,
68
- INVALID_NOTE_SETTING_VALUE = 3051,
69
- INVALID_INDEXES_CONTEXT = 3052,
70
- INVALID_INDEXES_FIELD = 3053,
71
- INVALID_INDEX = 3054,
72
- UNKNOWN_INDEX_SETTING = 3055,
73
- DUPLICATE_INDEX_SETTING = 3056,
74
- UNEXPECTED_INDEX_SETTING_VALUE = 3057,
75
- INVALID_INDEX_SETTING_VALUE = 3058,
76
- INVALID_PROJECT_CONTEXT = 3059,
77
- PROJECT_REDEFINED = 3060,
78
- INVALID_PROJECT_FIELD = 3061,
79
- INVALID_CUSTOM_CONTEXT = 3062,
80
- INVALID_CUSTOM_ELEMENT_VALUE = 3063,
81
- INVALID_ELEMENT_IN_SIMPLE_BODY = 3064,
82
- INVALID_TABLE_PARTIAL_CONTEXT = 3065,
83
- INVALID_TABLE_PARTIAL_ELEMENT_NAME = 3066,
84
- INVALID_TABLE_PARTIAL_SETTING_VALUE = 3067,
85
- DUPLICATE_TABLE_PARTIAL_ELEMENT_NAME = 3068,
86
- DUPLICATE_TABLE_PARTIAL_SETTING = 3069,
87
- INVALID_TABLE_PARTIAL_INJECTION = 3070,
88
- INVALID_TABLE_PARTIAL_INJECTION_OP = 3071,
89
- INVALID_TABLE_PARTIAL_INJECTION_NAME = 3072,
90
- DUPLICATE_TABLE_PARTIAL_INJECTION_NAME = 3073,
91
- UNKNOWN_TABLE_PARTIAL_SETTING = 3074,
92
- INVALID_TABLE_SETTING_VALUE = 3075,
93
- INVALID_CHECKS_CONTEXT = 3076,
94
- INVALID_CHECKS_FIELD = 3077,
95
- INVALID_CHECK = 3078,
96
- UNKNOWN_CHECK_SETTING = 3079,
97
- DUPLICATE_CHECK_SETTING = 3080,
98
- INVALID_CHECK_SETTING_VALUE = 3081,
99
- INVALID_RECORDS_CONTEXT = 3082,
100
- INVALID_RECORDS_NAME = 3083,
101
- INVALID_RECORDS_FIELD = 3084,
102
- DUPLICATE_COLUMN_REFERENCES_IN_RECORDS = 3085,
103
- DUPLICATE_RECORDS_FOR_TABLE = 3086,
104
- INVALID_USE_CONTEXT = 3087,
105
- INVALID_USE_SPECIFIER_KIND = 3088,
106
- INVALID_USE_SPECIFIER_NAME = 3089,
107
- INVALID_DIAGRAMVIEW_CONTEXT = 3090,
108
- DUPLICATE_DIAGRAMVIEW_NAME = 3091,
109
- INVALID_DIAGRAMVIEW_FIELD = 3092,
110
- DUPLICATE_DIAGRAMVIEW_FIELD = 3093,
59
+ INVALID_NOTE_CONTEXT = 3042,
60
+ INVALID_NOTE = 3043,
61
+ NOTE_REDEFINED = 3044,
62
+ NOTE_CONTENT_REDEFINED = 3045,
63
+ EMPTY_NOTE = 3046,
64
+ UNKNOWN_NOTE_SETTING = 3047,
65
+ DUPLICATE_NOTE_SETTING = 3048,
66
+ INVALID_NOTE_SETTING_VALUE = 3049,
67
+ INVALID_INDEXES_CONTEXT = 3050,
68
+ INVALID_INDEXES_FIELD = 3051,
69
+ INVALID_INDEX = 3052,
70
+ UNKNOWN_INDEX_SETTING = 3053,
71
+ DUPLICATE_INDEX_SETTING = 3054,
72
+ UNEXPECTED_INDEX_SETTING_VALUE = 3055,
73
+ INVALID_INDEX_SETTING_VALUE = 3056,
74
+ INVALID_PROJECT_CONTEXT = 3057,
75
+ PROJECT_REDEFINED = 3058,
76
+ INVALID_PROJECT_FIELD = 3059,
77
+ INVALID_CUSTOM_CONTEXT = 3060,
78
+ INVALID_CUSTOM_ELEMENT_VALUE = 3061,
79
+ INVALID_ELEMENT_IN_SIMPLE_BODY = 3062,
80
+ INVALID_TABLE_PARTIAL_CONTEXT = 3063,
81
+ INVALID_TABLE_PARTIAL_ELEMENT_NAME = 3064,
82
+ INVALID_TABLE_PARTIAL_SETTING_VALUE = 3065,
83
+ DUPLICATE_TABLE_PARTIAL_ELEMENT_NAME = 3066,
84
+ DUPLICATE_TABLE_PARTIAL_SETTING = 3067,
85
+ INVALID_TABLE_PARTIAL_INJECTION = 3068,
86
+ INVALID_TABLE_PARTIAL_INJECTION_OP = 3069,
87
+ INVALID_TABLE_PARTIAL_INJECTION_NAME = 3070,
88
+ DUPLICATE_TABLE_PARTIAL_INJECTION_NAME = 3071,
89
+ UNKNOWN_TABLE_PARTIAL_SETTING = 3072,
90
+ INVALID_TABLE_SETTING_VALUE = 3073,
91
+ INVALID_CHECKS_CONTEXT = 3074,
92
+ INVALID_CHECKS_FIELD = 3075,
93
+ INVALID_CHECK = 3076,
94
+ UNKNOWN_CHECK_SETTING = 3077,
95
+ DUPLICATE_CHECK_SETTING = 3078,
96
+ INVALID_CHECK_SETTING_VALUE = 3079,
97
+ INVALID_RECORDS_CONTEXT = 3080,
98
+ INVALID_RECORDS_NAME = 3081,
99
+ INVALID_RECORDS_FIELD = 3082,
100
+ DUPLICATE_COLUMN_REFERENCES_IN_RECORDS = 3083,
101
+ DUPLICATE_RECORDS_FOR_TABLE = 3084,
102
+ INVALID_USE_CONTEXT = 3085,
103
+ INVALID_USE_SPECIFIER_KIND = 3086,
104
+ INVALID_USE_SPECIFIER_NAME = 3087,
105
+ INVALID_DIAGRAMVIEW_CONTEXT = 3088,
106
+ DUPLICATE_DIAGRAMVIEW_NAME = 3089,
107
+ INVALID_DIAGRAMVIEW_FIELD = 3090,
108
+ DUPLICATE_DIAGRAMVIEW_FIELD = 3091,
111
109
  BINDING_ERROR = 4000,
112
110
  NONEXISTENT_MODULE = 4001,
113
111
  UNSUPPORTED = 5000,
@@ -117,12 +115,17 @@ export declare enum CompileErrorCode {
117
115
  CONFLICTING_SETTING = 5004,
118
116
  TABLE_REAPPEAR_IN_TABLEGROUP = 5005
119
117
  }
118
+ export interface RelatedLocation {
119
+ nodeOrToken: SyntaxNode | SyntaxToken;
120
+ message: string;
121
+ }
120
122
  export declare class CompileError extends Error {
121
123
  code: Readonly<CompileErrorCode>;
122
124
  diagnostic: Readonly<string>;
123
125
  nodeOrToken: Readonly<SyntaxNode | SyntaxToken>;
124
126
  start: Readonly<number>;
125
127
  end: Readonly<number>;
128
+ relatedLocations?: RelatedLocation[];
126
129
  constructor(code: number, message: string, nodeOrToken: SyntaxNode | SyntaxToken);
127
130
  toWarning(): CompileWarning;
128
131
  get filepath(): Filepath;
@@ -133,6 +136,26 @@ export declare class CompileWarning extends Error {
133
136
  nodeOrToken: Readonly<SyntaxNode | SyntaxToken>;
134
137
  start: Readonly<number>;
135
138
  end: Readonly<number>;
139
+ relatedLocations?: RelatedLocation[];
136
140
  constructor(code: number, message: string, nodeOrToken: SyntaxNode | SyntaxToken);
137
141
  get filepath(): Filepath;
138
142
  }
143
+ export interface QuickFix {
144
+ title: string;
145
+ filepath: Filepath;
146
+ edits: import('../../compiler/queries/transform/applyTextEdits').TextEdit[];
147
+ }
148
+ export declare class CompileInfo extends Error {
149
+ code: Readonly<CompileErrorCode>;
150
+ diagnostic: Readonly<string>;
151
+ nodeOrToken: Readonly<SyntaxNode | SyntaxToken>;
152
+ start: Readonly<number>;
153
+ end: Readonly<number>;
154
+ quickFixes?: QuickFix[];
155
+ relatedLocations?: RelatedLocation[];
156
+ constructor(code: number, message: string, nodeOrToken: SyntaxNode | SyntaxToken, options?: {
157
+ quickFixes?: QuickFix[];
158
+ relatedLocations?: RelatedLocation[];
159
+ });
160
+ get filepath(): Filepath;
161
+ }
File without changes
File without changes
File without changes
@@ -2,7 +2,6 @@ export declare enum ElementKind {
2
2
  Table = "table",
3
3
  Enum = "enum",
4
4
  Ref = "ref",
5
- Dep = "dep",
6
5
  Note = "note",
7
6
  Project = "project",
8
7
  Indexes = "indexes",
@@ -24,7 +23,6 @@ export declare enum SettingName {
24
23
  PrimaryKey = "primary key",
25
24
  Unique = "unique",
26
25
  Ref = "ref",
27
- Dep = "dep",
28
26
  NotNull = "not null",
29
27
  Null = "null",
30
28
  Increment = "increment",
File without changes
File without changes
File without changes
@@ -0,0 +1,19 @@
1
+ type BaseRelationshipOp = '>' | '<' | '-' | '<>';
2
+ export type RelationshipOp = `${'?' | ''}${BaseRelationshipOp}${'?' | ''}`;
3
+ export type RelationCardinality = `${number}` | '*' | `${number}..${number | '*'}`;
4
+ export declare function normalizeCardinality(c: RelationCardinality): RelationCardinality;
5
+ export declare function parseCardinality(c: RelationCardinality): {
6
+ min: number;
7
+ max: number | '*';
8
+ };
9
+ export declare const RELATIONSHIP_OPS: ReadonlySet<RelationshipOp>;
10
+ export declare const CARDINALITY_ONE: RelationCardinality;
11
+ export declare const CARDINALITY_MAYBE: RelationCardinality;
12
+ export declare const CARDINALITY_SOME: RelationCardinality;
13
+ export declare const CARDINALITY_MANY: RelationCardinality;
14
+ export declare function getMultiplicities(op: string): [RelationCardinality, RelationCardinality] | undefined;
15
+ export declare function getRelationshipOp(left: RelationCardinality, right: RelationCardinality): RelationshipOp;
16
+ export declare function makeCardinalityOptional(rel: RelationCardinality): RelationCardinality;
17
+ export declare function makeCardinalityRequired(rel: RelationCardinality): RelationCardinality;
18
+ export declare function makeCardinalityMany(rel: RelationCardinality): RelationCardinality;
19
+ export {};
@@ -1,16 +1,18 @@
1
- import { CompileError, CompileWarning } from './errors';
1
+ import { CompileError, CompileWarning, CompileInfo } from './errors';
2
2
  export default class Report<T> {
3
3
  private value;
4
4
  private errors;
5
5
  private warnings?;
6
- static create<T>(value: T, errors?: CompileError[], warnings?: CompileWarning[]): Report<T>;
7
- constructor(value: T, errors?: CompileError[], warnings?: CompileWarning[]);
6
+ private hints?;
7
+ static create<T>(value: T, errors?: CompileError[], warnings?: CompileWarning[], hints?: CompileInfo[]): Report<T>;
8
+ constructor(value: T, errors?: CompileError[], warnings?: CompileWarning[], hints?: CompileInfo[]);
8
9
  filter<S extends symbol>(filteredValue: S): Report<undefined | Exclude<T, S>>;
9
10
  hasValue<S>(value: S): this is Report<S>;
10
11
  getFiltered<S extends symbol | undefined | null>(filteredValue: S): Exclude<T, S> | undefined;
11
12
  getValue(): T;
12
13
  getErrors(): CompileError[];
13
14
  getWarnings(): CompileWarning[];
15
+ getHints(): CompileInfo[];
14
16
  chainFiltered<S extends symbol | undefined | null, U>(fn: (_: Exclude<T, S>) => Report<U>, filteredValue: S): Report<U | undefined>;
15
17
  chain<U>(fn: (_: T) => Report<U>): Report<U>;
16
18
  mapFiltered<S extends symbol | undefined | null, U>(fn: (_: Exclude<T, S>) => U, filteredValue: S): Report<U | undefined>;
@@ -1,6 +1,7 @@
1
1
  import { NONE_COLOR } from '../../constants';
2
2
  import { Filepath } from './filepath';
3
3
  import { Position } from './position';
4
+ import { RelationshipOp, RelationCardinality } from './relation';
4
5
  export type Color = `#${string}` | typeof NONE_COLOR;
5
6
  export declare enum AliasKind {
6
7
  Table = "table"
@@ -58,7 +59,6 @@ export interface Database {
58
59
  tables: Table[];
59
60
  notes: Note[];
60
61
  refs: Ref[];
61
- deps: Dep[];
62
62
  enums: Enum[];
63
63
  tableGroups: TableGroup[];
64
64
  aliases: Alias[];
@@ -111,7 +111,6 @@ export interface Column {
111
111
  type: ColumnType;
112
112
  token: TokenPosition;
113
113
  inline_refs: InlineRef[];
114
- inline_deps: InlineDep[];
115
114
  checks: Check[];
116
115
  pk?: boolean;
117
116
  dbdefault?: {
@@ -151,7 +150,7 @@ export interface InlineRef {
151
150
  schemaName: string | null;
152
151
  tableName: string;
153
152
  fieldNames: string[];
154
- relation: '>' | '<' | '-' | '<>';
153
+ relation: RelationshipOp;
155
154
  token: TokenPosition;
156
155
  }
157
156
  export interface Ref {
@@ -172,37 +171,6 @@ export interface RefEndpoint {
172
171
  relation: RelationCardinality;
173
172
  token: TokenPosition;
174
173
  }
175
- export type RelationCardinality = '1' | '*';
176
- export interface Dep {
177
- schemaName: string | null;
178
- name: string | null;
179
- edges: DepEdge[];
180
- color?: Color;
181
- note?: {
182
- value: string;
183
- token: TokenPosition;
184
- };
185
- custom?: Record<string, string | number | boolean | null>;
186
- token: TokenPosition;
187
- }
188
- export interface DepEdge {
189
- upstream: DepEndpoint;
190
- downstream: DepEndpoint;
191
- token: TokenPosition;
192
- }
193
- export interface DepEndpoint {
194
- schemaName: string | null;
195
- tableName: string;
196
- fieldNames: string[];
197
- token: TokenPosition;
198
- }
199
- export interface InlineDep {
200
- schemaName: string | null;
201
- tableName: string;
202
- fieldNames: string[];
203
- direction: '->' | '<-';
204
- token: TokenPosition;
205
- }
206
174
  export interface Enum {
207
175
  name: string;
208
176
  schemaName: string | null;
@@ -284,4 +252,4 @@ export type Project = Record<string, never> | {
284
252
  token: TokenPosition;
285
253
  [index: string & Omit<any, 'name' | 'tables' | 'refs' | 'enums' | 'tableGroups' | 'note' | 'tablePartials' | 'records'>]: string;
286
254
  };
287
- export type SchemaElement = Database | Project | Table | Note | Column | ColumnType | Index | Check | InlineRef | InlineDep | Ref | RefEndpoint | Dep | DepEdge | DepEndpoint | Enum | EnumField | TableGroup | TableGroupField | Alias | TablePartial | TablePartialInjection | TableRecord | RecordValue;
255
+ export type SchemaElement = Database | Project | Table | Note | Column | ColumnType | Index | Check | InlineRef | Ref | RefEndpoint | Enum | EnumField | TableGroup | TableGroupField | Alias | TablePartial | TablePartialInjection | TableRecord | RecordValue;
File without changes
File without changes
@@ -1,10 +1,11 @@
1
1
  import { default as Compiler } from '../../../compiler';
2
- import { AttributeNode, ElementDeclarationNode, InfixExpressionNode, SyntaxNode } from '../nodes';
2
+ import { AttributeNode, ElementDeclarationNode, SyntaxNode } from '../nodes';
3
+ import { SyntaxToken } from '../tokens';
3
4
  import { ColumnSymbol, NodeSymbol, TablePartialSymbol, TableSymbol } from '../symbol';
4
5
  import { Internable } from '../internable';
6
+ import { RelationshipOp, RelationCardinality } from '../relation';
5
7
  export declare enum MetadataKind {
6
8
  Ref = "ref",
7
- Dep = "dep",
8
9
  PartialRef = "partial ref",
9
10
  TableChecks = "table checks",
10
11
  Indexes = "indexes",
@@ -37,25 +38,22 @@ export declare class RefMetadata extends NodeMetadata {
37
38
  rightColumns(compiler: Compiler): ColumnSymbol[];
38
39
  leftTable(compiler: Compiler): TableSymbol | undefined;
39
40
  rightTable(compiler: Compiler): TableSymbol | undefined;
40
- op(_compiler: Compiler): '>' | '<' | '-' | '<>' | undefined;
41
+ op(_compiler: Compiler): RelationshipOp | undefined;
42
+ opToken(): SyntaxToken | undefined;
43
+ cardinalities(compiler: Compiler): [RelationCardinality, RelationCardinality] | undefined;
44
+ leftCardinality(compiler: Compiler): {
45
+ min: number;
46
+ max: number | '*';
47
+ } | undefined;
48
+ rightCardinality(compiler: Compiler): {
49
+ min: number;
50
+ max: number | '*';
51
+ } | undefined;
41
52
  active(compiler: Compiler): boolean;
42
53
  leftToken(): SyntaxNode;
43
54
  rightToken(): SyntaxNode;
44
55
  owners(compiler: Compiler): NodeSymbol[];
45
56
  }
46
- export declare class DepMetadata extends NodeMetadata {
47
- declaration: ElementDeclarationNode | AttributeNode;
48
- readonly kind = MetadataKind.Dep;
49
- constructor(declaration: ElementDeclarationNode | AttributeNode);
50
- container(compiler: Compiler): TableSymbol | undefined;
51
- edgeExpressions(): InfixExpressionNode[];
52
- upstreamColumns(compiler: Compiler): ColumnSymbol[][];
53
- downstreamColumns(compiler: Compiler): ColumnSymbol[][];
54
- upstreamTables(compiler: Compiler): (TableSymbol | undefined)[];
55
- downstreamTables(compiler: Compiler): (TableSymbol | undefined)[];
56
- private hostColumn;
57
- owners(compiler: Compiler): NodeSymbol[];
58
- }
59
57
  export declare class PartialRefMetadata extends NodeMetadata {
60
58
  readonly kind = MetadataKind.PartialRef;
61
59
  constructor(declaration: SyntaxNode);
@@ -64,7 +62,17 @@ export declare class PartialRefMetadata extends NodeMetadata {
64
62
  rightColumns(compiler: Compiler): ColumnSymbol[];
65
63
  leftTablePartial(compiler: Compiler): TablePartialSymbol | undefined;
66
64
  rightTable(compiler: Compiler): TableSymbol | TablePartialSymbol | undefined;
67
- op(_compiler: Compiler): '>' | '<' | '-' | '<>' | undefined;
65
+ op(_compiler: Compiler): RelationshipOp | undefined;
66
+ opToken(): SyntaxToken | undefined;
67
+ cardinalities(compiler: Compiler): [RelationCardinality, RelationCardinality] | undefined;
68
+ leftCardinality(compiler: Compiler): {
69
+ min: number;
70
+ max: number | '*';
71
+ } | undefined;
72
+ rightCardinality(compiler: Compiler): {
73
+ min: number;
74
+ max: number | '*';
75
+ } | undefined;
68
76
  leftToken(): SyntaxNode;
69
77
  rightToken(): SyntaxNode;
70
78
  owners(compiler: Compiler): NodeSymbol[];
@@ -147,9 +147,12 @@ export declare class ColumnSymbol extends NodeSymbol {
147
147
  }, id: NodeSymbolId, filepath: Filepath);
148
148
  get canBeImported(): boolean;
149
149
  get originalSymbol(): NodeSymbol;
150
+ qualifiedName(compiler: Compiler): string;
150
151
  pk(compiler: Compiler): boolean;
151
152
  unique(compiler: Compiler): boolean;
152
- nullable(compiler: Compiler): boolean | undefined;
153
+ nullable(compiler: Compiler): boolean;
154
+ isNotNullSet(compiler: Compiler): boolean | undefined;
155
+ isIncrementSet(compiler: Compiler): boolean;
153
156
  increment(compiler: Compiler): boolean;
154
157
  default(compiler: Compiler): {
155
158
  type: 'number' | 'string' | 'boolean' | 'expression';
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -10,9 +10,9 @@ export { SyntaxToken, SyntaxTokenKind, isTriviaToken, isOp, isOpToken, } from '.
10
10
  export { CompileError, CompileErrorCode, } from './core/types/errors';
11
11
  export type { Position, } from './core/types';
12
12
  export { ScopeKind, splitQualifiedIdentifier, unescapeString, escapeString, formatRecordValue, isValidIdentifier, addDoubleQuoteIfNeeded, } from './compiler/index';
13
- 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';
13
+ 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, } from './core/types/schemaJson';
14
+ export { type RelationCardinality, type RelationshipOp, getRelationshipOp, getMultiplicities, parseCardinality, CARDINALITY_ONE, CARDINALITY_MAYBE, CARDINALITY_SOME, CARDINALITY_MANY, } from './core/types/relation';
14
15
  export type { DiagramViewSyncOperation, DiagramViewBlock, TextEdit, } from './compiler/queries/transform';
15
- export type { DepSyncOperation, DepSyncEdge, DepEndpointRef, DepBlock, } from './compiler/queries/transform';
16
16
  export { dbmlLanguageConfig, dbmlMonarchTokensProvider, } from './services/monarch';
17
17
  export * from './compiler/projectLayout/layout';
18
18
  export { Compiler };
@@ -0,0 +1,8 @@
1
+ import { default as Compiler } from '../../compiler';
2
+ import { CodeActionProvider, CodeActionList, CodeActionContext, TextModel, Range, CancellationToken } from '../types';
3
+ export default class DBMLCodeActionProvider implements CodeActionProvider {
4
+ private compiler;
5
+ constructor(compiler: Compiler);
6
+ provideCodeActions(model: TextModel, _range: Range, context: CodeActionContext, _token: CancellationToken): CodeActionList | undefined;
7
+ private quickFixToCodeAction;
8
+ }
File without changes
@@ -1,8 +1,9 @@
1
1
  import { default as Compiler } from '../../compiler';
2
2
  import { Filepath } from '../../core/types/filepath';
3
+ import { RelatedLocation } from '../../core/types/errors';
3
4
  import { MarkerData } from '../types';
4
5
  export interface Diagnostic {
5
- type: 'error' | 'warning';
6
+ type: 'error' | 'warning' | 'hint';
6
7
  text: string;
7
8
  startRow: number;
8
9
  startColumn: number;
@@ -10,6 +11,7 @@ export interface Diagnostic {
10
11
  endColumn: number;
11
12
  code?: string | number;
12
13
  filepath: Filepath;
14
+ relatedLocations?: RelatedLocation[];
13
15
  }
14
16
  export default class DBMLDiagnosticsProvider {
15
17
  private compiler;
@@ -26,6 +28,10 @@ export default class DBMLDiagnosticsProvider {
26
28
  * Get only warnings from the current compilation
27
29
  */
28
30
  provideWarnings(filepath?: Filepath): Diagnostic[];
31
+ /**
32
+ * Get only hints from the current compilation
33
+ */
34
+ provideHints(filepath?: Filepath): Diagnostic[];
29
35
  /**
30
36
  * Convert Monaco markers format (for editor integration)
31
37
  */
@@ -1,8 +1,9 @@
1
+ import { default as DBMLCodeActionProvider } from './code_actions/provider';
1
2
  import { default as DBMLDefinitionProvider } from './definition/provider';
2
3
  import { default as DBMLDiagnosticsProvider } from './diagnostics/provider';
3
4
  import { default as DBMLReferencesProvider } from './references/provider';
4
5
  import { default as DBMLCompletionItemProvider } from './suggestions/provider';
5
6
  export type { Diagnostic } from './diagnostics/provider';
6
7
  export * from './types';
7
- export { DBMLCompletionItemProvider, DBMLDefinitionProvider, DBMLReferencesProvider, DBMLDiagnosticsProvider, };
8
+ export { DBMLCodeActionProvider, DBMLCompletionItemProvider, DBMLDefinitionProvider, DBMLReferencesProvider, DBMLDiagnosticsProvider, };
8
9
  export { dbmlMonarchTokensProvider } from './monarch';
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -62,8 +62,12 @@ export type ColorPresentation = languages.IColorPresentation;
62
62
  export type Color = languages.IColor;
63
63
  export type DefinitionProvider = languages.DefinitionProvider;
64
64
  export type Definition = languages.Definition;
65
- export type CodeActionList = languages.CodeActionList;
66
65
  export type SignatureHelpResult = languages.SignatureHelpResult;
66
+ export type CodeActionProvider = languages.CodeActionProvider;
67
+ export type CodeActionList = languages.CodeActionList;
68
+ export type CodeAction = languages.CodeAction;
69
+ export type CodeActionContext = languages.CodeActionContext;
70
+ export type WorkspaceEdit = languages.WorkspaceEdit;
67
71
  export type ReferenceProvider = languages.ReferenceProvider;
68
72
  export declare enum MarkerSeverity {
69
73
  Hint = 1,
File without changes
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.3",
4
+ "version": "9.0.0-optional-ref.2",
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": "c25a2e99a38fdfabf87161919e6ba50e93a9bcf1"
53
+ "gitHead": "3fc818b8e6033e2de577d012722d86a7509e4af3"
54
54
  }
@@ -1,98 +0,0 @@
1
- import { Filepath } from '../../../core/types/filepath';
2
- import { default as Compiler } from '../../index';
3
- import { TextEdit } from './applyTextEdits';
4
- /** One endpoint of a dep edge. `fieldNames` is empty for a table-level edge. */
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 fieldNames). */
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;
41
- }
42
- export interface DepBlock {
43
- startIndex: number;
44
- endIndex: number;
45
- 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;
65
- }
66
- /**
67
- * Returns every `Dep` block in `source`.
68
- * On any lex or parse error, returns [] - there is no reliable way to read
69
- * dep blocks from malformed DBML (mirrors findDiagramViewBlocks).
70
- */
71
- export declare function findDepBlocks(source: string): DepBlock[];
72
- export interface InlineDep {
73
- edge: DepSyncEdge;
74
- stripStart: number;
75
- stripEnd: number;
76
- }
77
- export declare function findInlineDeps(source: string): InlineDep[];
78
- /**
79
- * Emit a `Dep` block for one edge with a `[color]` setting:
80
- *
81
- * Dep [color: <hex>] {
82
- * <upstream> -> <downstream>
83
- * }
84
- */
85
- export declare function generateDepBlock(edge: DepSyncEdge, color: string): string;
86
- /**
87
- * Synchronizes `Dep` blocks in the DBML source at `filepath`.
88
- *
89
- * @param filepath The file whose source should be rewritten.
90
- * @param operations Array of create/update operations to apply.
91
- * @param blocks Optional pre-parsed blocks from findDepBlocks.
92
- * @returns The new DBML source and the text edits applied.
93
- */
94
- export declare function syncDep(this: Compiler, filepath: Filepath, operations: DepSyncOperation[], blocks?: DepBlock[]): {
95
- newDbml: string;
96
- edits: TextEdit[];
97
- };
98
- export {};
@@ -1,15 +0,0 @@
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 bindSubElements;
15
- }