@domainlang/language 0.1.20

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 (212) hide show
  1. package/README.md +163 -0
  2. package/out/ast-augmentation.d.ts +6 -0
  3. package/out/ast-augmentation.js +2 -0
  4. package/out/ast-augmentation.js.map +1 -0
  5. package/out/domain-lang-module.d.ts +57 -0
  6. package/out/domain-lang-module.js +67 -0
  7. package/out/domain-lang-module.js.map +1 -0
  8. package/out/generated/ast.d.ts +759 -0
  9. package/out/generated/ast.js +556 -0
  10. package/out/generated/ast.js.map +1 -0
  11. package/out/generated/grammar.d.ts +6 -0
  12. package/out/generated/grammar.js +2407 -0
  13. package/out/generated/grammar.js.map +1 -0
  14. package/out/generated/module.d.ts +13 -0
  15. package/out/generated/module.js +21 -0
  16. package/out/generated/module.js.map +1 -0
  17. package/out/index.d.ts +16 -0
  18. package/out/index.js +22 -0
  19. package/out/index.js.map +1 -0
  20. package/out/lsp/domain-lang-code-actions.d.ts +55 -0
  21. package/out/lsp/domain-lang-code-actions.js +143 -0
  22. package/out/lsp/domain-lang-code-actions.js.map +1 -0
  23. package/out/lsp/domain-lang-completion.d.ts +37 -0
  24. package/out/lsp/domain-lang-completion.js +452 -0
  25. package/out/lsp/domain-lang-completion.js.map +1 -0
  26. package/out/lsp/domain-lang-formatter.d.ts +15 -0
  27. package/out/lsp/domain-lang-formatter.js +43 -0
  28. package/out/lsp/domain-lang-formatter.js.map +1 -0
  29. package/out/lsp/domain-lang-naming.d.ts +34 -0
  30. package/out/lsp/domain-lang-naming.js +49 -0
  31. package/out/lsp/domain-lang-naming.js.map +1 -0
  32. package/out/lsp/domain-lang-scope.d.ts +59 -0
  33. package/out/lsp/domain-lang-scope.js +102 -0
  34. package/out/lsp/domain-lang-scope.js.map +1 -0
  35. package/out/lsp/domain-lang-workspace-manager.d.ts +21 -0
  36. package/out/lsp/domain-lang-workspace-manager.js +93 -0
  37. package/out/lsp/domain-lang-workspace-manager.js.map +1 -0
  38. package/out/lsp/hover/ddd-pattern-explanations.d.ts +50 -0
  39. package/out/lsp/hover/ddd-pattern-explanations.js +196 -0
  40. package/out/lsp/hover/ddd-pattern-explanations.js.map +1 -0
  41. package/out/lsp/hover/domain-lang-hover.d.ts +19 -0
  42. package/out/lsp/hover/domain-lang-hover.js +302 -0
  43. package/out/lsp/hover/domain-lang-hover.js.map +1 -0
  44. package/out/lsp/hover/domain-lang-keywords.d.ts +13 -0
  45. package/out/lsp/hover/domain-lang-keywords.js +47 -0
  46. package/out/lsp/hover/domain-lang-keywords.js.map +1 -0
  47. package/out/lsp/manifest-diagnostics.d.ts +82 -0
  48. package/out/lsp/manifest-diagnostics.js +230 -0
  49. package/out/lsp/manifest-diagnostics.js.map +1 -0
  50. package/out/main-browser.d.ts +1 -0
  51. package/out/main-browser.js +11 -0
  52. package/out/main-browser.js.map +1 -0
  53. package/out/main.d.ts +1 -0
  54. package/out/main.js +74 -0
  55. package/out/main.js.map +1 -0
  56. package/out/sdk/ast-augmentation.d.ts +136 -0
  57. package/out/sdk/ast-augmentation.js +62 -0
  58. package/out/sdk/ast-augmentation.js.map +1 -0
  59. package/out/sdk/index.d.ts +94 -0
  60. package/out/sdk/index.js +97 -0
  61. package/out/sdk/index.js.map +1 -0
  62. package/out/sdk/indexes.d.ts +16 -0
  63. package/out/sdk/indexes.js +97 -0
  64. package/out/sdk/indexes.js.map +1 -0
  65. package/out/sdk/loader-node.d.ts +51 -0
  66. package/out/sdk/loader-node.js +119 -0
  67. package/out/sdk/loader-node.js.map +1 -0
  68. package/out/sdk/loader.d.ts +49 -0
  69. package/out/sdk/loader.js +85 -0
  70. package/out/sdk/loader.js.map +1 -0
  71. package/out/sdk/patterns.d.ts +93 -0
  72. package/out/sdk/patterns.js +123 -0
  73. package/out/sdk/patterns.js.map +1 -0
  74. package/out/sdk/query.d.ts +90 -0
  75. package/out/sdk/query.js +679 -0
  76. package/out/sdk/query.js.map +1 -0
  77. package/out/sdk/resolution.d.ts +52 -0
  78. package/out/sdk/resolution.js +68 -0
  79. package/out/sdk/resolution.js.map +1 -0
  80. package/out/sdk/types.d.ts +280 -0
  81. package/out/sdk/types.js +8 -0
  82. package/out/sdk/types.js.map +1 -0
  83. package/out/services/dependency-analyzer.d.ts +58 -0
  84. package/out/services/dependency-analyzer.js +254 -0
  85. package/out/services/dependency-analyzer.js.map +1 -0
  86. package/out/services/dependency-resolver.d.ts +146 -0
  87. package/out/services/dependency-resolver.js +452 -0
  88. package/out/services/dependency-resolver.js.map +1 -0
  89. package/out/services/git-url-resolver.browser.d.ts +10 -0
  90. package/out/services/git-url-resolver.browser.js +19 -0
  91. package/out/services/git-url-resolver.browser.js.map +1 -0
  92. package/out/services/git-url-resolver.d.ts +158 -0
  93. package/out/services/git-url-resolver.js +416 -0
  94. package/out/services/git-url-resolver.js.map +1 -0
  95. package/out/services/governance-validator.d.ts +44 -0
  96. package/out/services/governance-validator.js +153 -0
  97. package/out/services/governance-validator.js.map +1 -0
  98. package/out/services/import-resolver.d.ts +77 -0
  99. package/out/services/import-resolver.js +240 -0
  100. package/out/services/import-resolver.js.map +1 -0
  101. package/out/services/performance-optimizer.d.ts +60 -0
  102. package/out/services/performance-optimizer.js +140 -0
  103. package/out/services/performance-optimizer.js.map +1 -0
  104. package/out/services/relationship-inference.d.ts +11 -0
  105. package/out/services/relationship-inference.js +98 -0
  106. package/out/services/relationship-inference.js.map +1 -0
  107. package/out/services/semver.d.ts +98 -0
  108. package/out/services/semver.js +195 -0
  109. package/out/services/semver.js.map +1 -0
  110. package/out/services/types.d.ts +340 -0
  111. package/out/services/types.js +46 -0
  112. package/out/services/types.js.map +1 -0
  113. package/out/services/workspace-manager.d.ts +123 -0
  114. package/out/services/workspace-manager.js +489 -0
  115. package/out/services/workspace-manager.js.map +1 -0
  116. package/out/syntaxes/domain-lang.monarch.d.ts +76 -0
  117. package/out/syntaxes/domain-lang.monarch.js +29 -0
  118. package/out/syntaxes/domain-lang.monarch.js.map +1 -0
  119. package/out/utils/import-utils.d.ts +49 -0
  120. package/out/utils/import-utils.js +128 -0
  121. package/out/utils/import-utils.js.map +1 -0
  122. package/out/validation/bounded-context.d.ts +11 -0
  123. package/out/validation/bounded-context.js +79 -0
  124. package/out/validation/bounded-context.js.map +1 -0
  125. package/out/validation/classification.d.ts +3 -0
  126. package/out/validation/classification.js +3 -0
  127. package/out/validation/classification.js.map +1 -0
  128. package/out/validation/constants.d.ts +180 -0
  129. package/out/validation/constants.js +235 -0
  130. package/out/validation/constants.js.map +1 -0
  131. package/out/validation/domain-lang-validator.d.ts +2 -0
  132. package/out/validation/domain-lang-validator.js +27 -0
  133. package/out/validation/domain-lang-validator.js.map +1 -0
  134. package/out/validation/domain.d.ts +11 -0
  135. package/out/validation/domain.js +63 -0
  136. package/out/validation/domain.js.map +1 -0
  137. package/out/validation/import.d.ts +68 -0
  138. package/out/validation/import.js +237 -0
  139. package/out/validation/import.js.map +1 -0
  140. package/out/validation/manifest.d.ts +144 -0
  141. package/out/validation/manifest.js +327 -0
  142. package/out/validation/manifest.js.map +1 -0
  143. package/out/validation/maps.d.ts +21 -0
  144. package/out/validation/maps.js +60 -0
  145. package/out/validation/maps.js.map +1 -0
  146. package/out/validation/metadata.d.ts +7 -0
  147. package/out/validation/metadata.js +16 -0
  148. package/out/validation/metadata.js.map +1 -0
  149. package/out/validation/model.d.ts +12 -0
  150. package/out/validation/model.js +29 -0
  151. package/out/validation/model.js.map +1 -0
  152. package/out/validation/relationships.d.ts +12 -0
  153. package/out/validation/relationships.js +94 -0
  154. package/out/validation/relationships.js.map +1 -0
  155. package/out/validation/shared.d.ts +6 -0
  156. package/out/validation/shared.js +12 -0
  157. package/out/validation/shared.js.map +1 -0
  158. package/package.json +110 -0
  159. package/src/ast-augmentation.ts +5 -0
  160. package/src/domain-lang-module.ts +112 -0
  161. package/src/domain-lang.langium +351 -0
  162. package/src/generated/ast.ts +986 -0
  163. package/src/generated/grammar.ts +2409 -0
  164. package/src/generated/module.ts +25 -0
  165. package/src/index.ts +24 -0
  166. package/src/lsp/domain-lang-code-actions.ts +189 -0
  167. package/src/lsp/domain-lang-completion.ts +514 -0
  168. package/src/lsp/domain-lang-formatter.ts +51 -0
  169. package/src/lsp/domain-lang-naming.ts +56 -0
  170. package/src/lsp/domain-lang-scope.ts +137 -0
  171. package/src/lsp/domain-lang-workspace-manager.ts +104 -0
  172. package/src/lsp/hover/ddd-pattern-explanations.ts +237 -0
  173. package/src/lsp/hover/domain-lang-hover.ts +338 -0
  174. package/src/lsp/hover/domain-lang-keywords.ts +50 -0
  175. package/src/lsp/manifest-diagnostics.ts +290 -0
  176. package/src/main-browser.ts +15 -0
  177. package/src/main.ts +85 -0
  178. package/src/sdk/README.md +297 -0
  179. package/src/sdk/ast-augmentation.ts +157 -0
  180. package/src/sdk/index.ts +126 -0
  181. package/src/sdk/indexes.ts +155 -0
  182. package/src/sdk/loader-node.ts +146 -0
  183. package/src/sdk/loader.ts +99 -0
  184. package/src/sdk/patterns.ts +147 -0
  185. package/src/sdk/query.ts +802 -0
  186. package/src/sdk/resolution.ts +78 -0
  187. package/src/sdk/types.ts +323 -0
  188. package/src/services/dependency-analyzer.ts +321 -0
  189. package/src/services/dependency-resolver.ts +551 -0
  190. package/src/services/git-url-resolver.browser.ts +26 -0
  191. package/src/services/git-url-resolver.ts +517 -0
  192. package/src/services/governance-validator.ts +177 -0
  193. package/src/services/import-resolver.ts +292 -0
  194. package/src/services/performance-optimizer.ts +170 -0
  195. package/src/services/relationship-inference.ts +121 -0
  196. package/src/services/semver.ts +213 -0
  197. package/src/services/types.ts +415 -0
  198. package/src/services/workspace-manager.ts +607 -0
  199. package/src/syntaxes/domain-lang.monarch.ts +29 -0
  200. package/src/utils/import-utils.ts +152 -0
  201. package/src/validation/bounded-context.ts +99 -0
  202. package/src/validation/classification.ts +5 -0
  203. package/src/validation/constants.ts +304 -0
  204. package/src/validation/domain-lang-validator.ts +33 -0
  205. package/src/validation/domain.ts +77 -0
  206. package/src/validation/import.ts +295 -0
  207. package/src/validation/manifest.ts +439 -0
  208. package/src/validation/maps.ts +76 -0
  209. package/src/validation/metadata.ts +18 -0
  210. package/src/validation/model.ts +37 -0
  211. package/src/validation/relationships.ts +154 -0
  212. package/src/validation/shared.ts +14 -0
@@ -0,0 +1,230 @@
1
+ /**
2
+ * Manifest Diagnostics Service for DomainLang.
3
+ *
4
+ * Provides LSP diagnostics for model.yaml files by integrating the ManifestValidator
5
+ * with the VS Code language server protocol.
6
+ *
7
+ * This service:
8
+ * - Validates model.yaml files using ManifestValidator
9
+ * - Converts ManifestDiagnostic to LSP Diagnostic format
10
+ * - Sends diagnostics to the LSP connection
11
+ *
12
+ * @module
13
+ */
14
+ import { DiagnosticSeverity, Position, Range } from 'vscode-languageserver-types';
15
+ import YAML, { isMap, isPair, isScalar } from 'yaml';
16
+ import { ManifestValidator } from '../validation/manifest.js';
17
+ /**
18
+ * Service for validating model.yaml and sending diagnostics via LSP.
19
+ */
20
+ export class ManifestDiagnosticsService {
21
+ constructor() {
22
+ this.validator = new ManifestValidator();
23
+ }
24
+ /**
25
+ * Sets the LSP connection for sending diagnostics.
26
+ * Must be called before validateAndSendDiagnostics.
27
+ */
28
+ setConnection(connection) {
29
+ this.connection = connection;
30
+ }
31
+ /**
32
+ * Validates a model.yaml file and sends diagnostics to the LSP connection.
33
+ *
34
+ * @param manifestUri - URI of the model.yaml file
35
+ * @param content - Raw YAML content of the file
36
+ * @param options - Validation options
37
+ */
38
+ async validateAndSendDiagnostics(manifestUri, content, options) {
39
+ if (!this.connection) {
40
+ return; // No connection, skip diagnostics
41
+ }
42
+ const diagnostics = this.validate(content, options);
43
+ await this.connection.sendDiagnostics({
44
+ uri: manifestUri,
45
+ diagnostics
46
+ });
47
+ }
48
+ /**
49
+ * Validates manifest content and returns LSP diagnostics.
50
+ *
51
+ * @param content - Raw YAML content
52
+ * @param options - Validation options
53
+ * @returns Array of LSP diagnostics
54
+ */
55
+ validate(content, options) {
56
+ // Parse YAML to get both the manifest object and source map
57
+ let yamlDoc;
58
+ let manifest;
59
+ try {
60
+ yamlDoc = YAML.parseDocument(content);
61
+ // Check for YAML parse errors (they're in the errors array, not thrown)
62
+ if (yamlDoc.errors && yamlDoc.errors.length > 0) {
63
+ return yamlDoc.errors.map(err => ({
64
+ severity: DiagnosticSeverity.Error,
65
+ range: this.yamlErrorToRange(err, content),
66
+ message: `YAML parse error: ${err.message}`,
67
+ source: 'domainlang'
68
+ }));
69
+ }
70
+ manifest = (yamlDoc.toJSON() ?? {});
71
+ }
72
+ catch (error) {
73
+ // Fallback for unexpected errors
74
+ const message = error instanceof Error ? error.message : 'Invalid YAML syntax';
75
+ return [{
76
+ severity: DiagnosticSeverity.Error,
77
+ range: Range.create(Position.create(0, 0), Position.create(0, 1)),
78
+ message: `YAML parse error: ${message}`,
79
+ source: 'domainlang'
80
+ }];
81
+ }
82
+ // Run manifest validation
83
+ const result = this.validator.validate(manifest, options);
84
+ // Convert to LSP diagnostics with source locations
85
+ return result.diagnostics.map(diag => this.toVSCodeDiagnostic(diag, yamlDoc));
86
+ }
87
+ /**
88
+ * Converts a YAML error to an LSP Range.
89
+ */
90
+ yamlErrorToRange(err, _content) {
91
+ if (err.linePos && err.linePos.length >= 1) {
92
+ const startPos = err.linePos[0];
93
+ const startLine = startPos.line - 1; // YAML uses 1-based lines
94
+ const startCol = startPos.col - 1; // YAML uses 1-based columns
95
+ const endPos = err.linePos.length >= 2 ? err.linePos[1] : undefined;
96
+ const endLine = endPos ? endPos.line - 1 : startLine;
97
+ const endCol = endPos ? endPos.col - 1 : startCol + 1;
98
+ return Range.create(Position.create(startLine, startCol), Position.create(endLine, endCol));
99
+ }
100
+ return Range.create(Position.create(0, 0), Position.create(0, 1));
101
+ }
102
+ /**
103
+ * Clears diagnostics for a manifest file.
104
+ * Call this when the file is closed or deleted.
105
+ */
106
+ async clearDiagnostics(manifestUri) {
107
+ if (!this.connection) {
108
+ return;
109
+ }
110
+ await this.connection.sendDiagnostics({
111
+ uri: manifestUri,
112
+ diagnostics: []
113
+ });
114
+ }
115
+ /**
116
+ * Converts a ManifestDiagnostic to an LSP Diagnostic.
117
+ */
118
+ toVSCodeDiagnostic(diag, yamlDoc) {
119
+ const range = this.findRangeForPath(diag.path, yamlDoc);
120
+ let message = diag.message;
121
+ if (diag.hint) {
122
+ message += `\nHint: ${diag.hint}`;
123
+ }
124
+ return {
125
+ severity: this.toVSCodeSeverity(diag.severity),
126
+ range,
127
+ message,
128
+ source: 'domainlang',
129
+ code: diag.code
130
+ };
131
+ }
132
+ /**
133
+ * Converts ManifestSeverity to LSP DiagnosticSeverity.
134
+ */
135
+ toVSCodeSeverity(severity) {
136
+ switch (severity) {
137
+ case 'error':
138
+ return DiagnosticSeverity.Error;
139
+ case 'warning':
140
+ return DiagnosticSeverity.Warning;
141
+ case 'info':
142
+ return DiagnosticSeverity.Information;
143
+ default:
144
+ return DiagnosticSeverity.Warning;
145
+ }
146
+ }
147
+ /**
148
+ * Finds the source range for a YAML path like "dependencies.core.version".
149
+ * Returns a fallback range at start of file if path not found.
150
+ */
151
+ findRangeForPath(path, yamlDoc) {
152
+ const fallback = Range.create(Position.create(0, 0), Position.create(0, 1));
153
+ if (!yamlDoc.contents || !isMap(yamlDoc.contents)) {
154
+ return fallback;
155
+ }
156
+ const parts = path.split('.');
157
+ let currentNode = yamlDoc.contents;
158
+ for (const part of parts) {
159
+ if (!isMap(currentNode)) {
160
+ return fallback;
161
+ }
162
+ const mapNode = currentNode;
163
+ const item = mapNode.items.find((pair) => isPair(pair) && isScalar(pair.key) && String(pair.key.value) === part);
164
+ if (!item) {
165
+ return fallback;
166
+ }
167
+ // If this is the last part, return the range of the key
168
+ if (part === parts[parts.length - 1]) {
169
+ const keyNode = item.key;
170
+ if (isScalar(keyNode) && keyNode.range) {
171
+ const [start, end] = keyNode.range;
172
+ return this.offsetsToRange(start, end, yamlDoc.toString());
173
+ }
174
+ }
175
+ currentNode = item.value;
176
+ }
177
+ return fallback;
178
+ }
179
+ /**
180
+ * Converts byte offsets to a VS Code Range using line/column calculation.
181
+ */
182
+ offsetsToRange(startOffset, endOffset, content) {
183
+ const lines = content.split('\n');
184
+ let currentOffset = 0;
185
+ let startLine = 0;
186
+ let startCol = 0;
187
+ let endLine = 0;
188
+ let endCol = 0;
189
+ let foundStart = false;
190
+ let foundEnd = false;
191
+ for (let lineNum = 0; lineNum < lines.length && !foundEnd; lineNum++) {
192
+ const lineLength = lines[lineNum].length + 1; // +1 for newline
193
+ if (!foundStart && currentOffset + lineLength > startOffset) {
194
+ startLine = lineNum;
195
+ startCol = startOffset - currentOffset;
196
+ foundStart = true;
197
+ }
198
+ if (!foundEnd && currentOffset + lineLength >= endOffset) {
199
+ endLine = lineNum;
200
+ endCol = endOffset - currentOffset;
201
+ foundEnd = true;
202
+ }
203
+ currentOffset += lineLength;
204
+ }
205
+ return Range.create(Position.create(startLine, startCol), Position.create(endLine, endCol));
206
+ }
207
+ }
208
+ /**
209
+ * Singleton instance for use across the language server.
210
+ */
211
+ let manifestDiagnosticsService;
212
+ /**
213
+ * Gets or creates the manifest diagnostics service singleton.
214
+ */
215
+ export function getManifestDiagnosticsService() {
216
+ if (!manifestDiagnosticsService) {
217
+ manifestDiagnosticsService = new ManifestDiagnosticsService();
218
+ }
219
+ return manifestDiagnosticsService;
220
+ }
221
+ /**
222
+ * Helper to validate a manifest URI with the given content.
223
+ * Convenience function for use in file watchers.
224
+ */
225
+ export async function validateManifestFile(connection, manifestUri, content) {
226
+ const service = getManifestDiagnosticsService();
227
+ service.setConnection(connection);
228
+ await service.validateAndSendDiagnostics(manifestUri, content);
229
+ }
230
+ //# sourceMappingURL=manifest-diagnostics.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"manifest-diagnostics.js","sourceRoot":"","sources":["../../src/lsp/manifest-diagnostics.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,EAAc,kBAAkB,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,6BAA6B,C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}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,11 @@
1
+ import { EmptyFileSystem } from 'langium';
2
+ import { startLanguageServer } from 'langium/lsp';
3
+ import { BrowserMessageReader, BrowserMessageWriter, createConnection } from 'vscode-languageserver/browser.js';
4
+ import { createDomainLangServices } from './domain-lang-module.js';
5
+ // declare const self: DedicatedWorkerGlobalScope;
6
+ const messageReader = new BrowserMessageReader(self);
7
+ const messageWriter = new BrowserMessageWriter(self);
8
+ const connection = createConnection(messageReader, messageWriter);
9
+ const { shared } = createDomainLangServices({ connection, ...EmptyFileSystem });
10
+ startLanguageServer(shared);
11
+ //# sourceMappingURL=main-browser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"main-browser.js","sourceRoot":"","sources":["../src/main-browser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAC1C,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AAChH,OAAO,EAAE,wBAAwB,EAAE,MAAM,yBAAyB,CAAC;AAEnE,kDAAkD;AAElD,MAAM,aAAa,GAAG,IAAI,oBAAoB,CAAC,IAAI,CAAC,CAAC;AACrD,MAAM,aAAa,GAAG,IAAI,oBAAoB,CAAC,IAAI,CAAC,CAAC;AAErD,MAAM,UAAU,GAAG,gBAAgB,CAAC,aAAa,EAAE,aAAa,CAAC,CAAC;AAElE,MAAM,EAAE,MAAM,EAAE,GAAG,wBAAwB,CAAC,EAAE,UAAU,EAAE,GAAG,eAAe,EAAE,CAAC,CAAC;AAEhF,mBAAmB,CAAC,MAAM,CAAC,CAAC"}
package/out/main.d.ts ADDED
@@ -0,0 +1 @@
1
+ export {};
package/out/main.js ADDED
@@ -0,0 +1,74 @@
1
+ import { startLanguageServer } from 'langium/lsp';
2
+ import { NodeFileSystem } from 'langium/node';
3
+ import { createConnection, ProposedFeatures } from 'vscode-languageserver/node.js';
4
+ import { createDomainLangServices } from './domain-lang-module.js';
5
+ import { ensureImportGraphFromEntryFile } from './utils/import-utils.js';
6
+ import { URI } from 'langium';
7
+ // Create a connection to the client
8
+ const connection = createConnection(ProposedFeatures.all);
9
+ // Inject the shared services and language-specific services
10
+ const { shared, DomainLang } = createDomainLangServices({ connection, ...NodeFileSystem });
11
+ // Initialize workspace on connection
12
+ connection.onInitialize(async (params) => {
13
+ const workspaceRoot = params.rootUri ? URI.parse(params.rootUri).fsPath : undefined;
14
+ if (workspaceRoot) {
15
+ try {
16
+ // Initialize workspace manager
17
+ const workspaceManager = DomainLang.imports.WorkspaceManager;
18
+ await workspaceManager.initialize(workspaceRoot);
19
+ console.warn(`DomainLang workspace initialized: ${workspaceRoot}`);
20
+ }
21
+ catch (error) {
22
+ const message = error instanceof Error ? error.message : String(error);
23
+ console.warn(`Failed to initialize workspace: ${message}`);
24
+ // Continue without workspace - local imports will still work
25
+ }
26
+ }
27
+ return {
28
+ capabilities: {
29
+ // Language server capabilities are configured by Langium
30
+ }
31
+ };
32
+ });
33
+ // Optionally start from a single entry file and follow imports.
34
+ // Configure via env DOMAINLANG_ENTRY (absolute or workspace-relative path)
35
+ const entryFile = process.env.DOMAINLANG_ENTRY;
36
+ if (entryFile) {
37
+ let currentGraph = new Set();
38
+ /**
39
+ * Reloads the import graph from the entry file.
40
+ * Handles errors gracefully and notifies the LSP client.
41
+ */
42
+ const reloadFromEntry = async () => {
43
+ try {
44
+ currentGraph = await ensureImportGraphFromEntryFile(entryFile, shared.workspace.LangiumDocuments);
45
+ console.warn(`Successfully loaded import graph from ${entryFile}`);
46
+ }
47
+ catch (error) {
48
+ const message = error instanceof Error ? error.message : String(error);
49
+ console.error(`Failed to preload import graph from ${entryFile}: ${message}`);
50
+ // Notify LSP client of the error
51
+ connection.console.error(`DomainLang: Could not load entry file ${entryFile}. Error: ${message}`);
52
+ }
53
+ };
54
+ // Initial load from entry file, then start the server
55
+ reloadFromEntry().finally(() => startLanguageServer(shared));
56
+ // Any change within the loaded graph should trigger a reload from the entry
57
+ shared.workspace.TextDocuments.onDidChangeContent(async (event) => {
58
+ const changed = event.document.uri;
59
+ if (currentGraph.has(changed)) {
60
+ await reloadFromEntry();
61
+ }
62
+ });
63
+ // If the entry file itself is opened/changed, also reload
64
+ shared.workspace.TextDocuments.onDidOpen(async (event) => {
65
+ if (URI.parse(event.document.uri).fsPath === URI.file(entryFile).fsPath) {
66
+ await reloadFromEntry();
67
+ }
68
+ });
69
+ }
70
+ else {
71
+ // No entry file configured: start normally
72
+ startLanguageServer(shared);
73
+ }
74
+ //# sourceMappingURL=main.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"main.js","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACnF,OAAO,EAAE,wBAAwB,EAAE,MAAM,yBAAyB,CAAC;AACnE,OAAO,EAAE,8BAA8B,EAAE,MAAM,yBAAyB,CAAC;AACzE,OAAO,EAAE,GAAG,EAAE,MAAM,SAAS,CAAC;AAE9B,oCAAoC;AACpC,MAAM,UAAU,GAAG,gBAAgB,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC;AAE1D,4DAA4D;AAC5D,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,GAAG,wBAAwB,CAAC,EAAE,UAAU,EAAE,GAAG,cAAc,EAAE,CAAC,CAAC;AAE3F,qCAAqC;AACrC,UAAU,CAAC,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE;IACrC,MAAM,aAAa,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,MAAM,CAA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uC,SAAS,KAAK,OAAO,EAAE,CAAC,CAAC;YAC9E,iCAAiC;YACjC,UAAU,CAAC,OAAO,CAAC,KAAK,CACpB,yCAAyC,SAAS,YAAY,OAAO,EAAE,CAC1E,CAAC;QACN,CAAC;IACL,CAAC,CAAC;IAEF,sDAAsD;IACtD,eAAe,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,mBAAmB,CAAC,MAAM,CAAC,CAAC,CAAC;IAE7D,4EAA4E;IAC5E,MAAM,CAAC,SAAS,CAAC,aAAa,CAAC,kBAAkB,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE;QAC9D,MAAM,OAAO,GAAG,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC;QACnC,IAAI,YAAY,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC;YAC5B,MAAM,eAAe,EAAE,CAAC;QAC5B,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,0DAA0D;IAC1D,MAAM,CAAC,SAAS,CAAC,aAAa,CAAC,SAAS,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE;QACrD,IAAI,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,MAAM,KAAK,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,MAAM,EAAE,CAAC;YACtE,MAAM,eAAe,EAAE,CAAC;QAC5B,CAAC;IACL,CAAC,CAAC,CAAC;AACP,CAAC;KAAM,CAAC;IACJ,2CAA2C;IAC3C,mBAAmB,CAAC,MAAM,CAAC,CAAC;AAChC,CAAC"}
@@ -0,0 +1,136 @@
1
+ /**
2
+ * SDK AST Augmentation - Module augmentation for native SDK properties.
3
+ *
4
+ * This file uses TypeScript's declaration merging to add computed helpers
5
+ * directly to the AST types. After importing this module, BoundedContext,
6
+ * Domain, and Relationship instances expose convenience getters.
7
+ *
8
+ * **Only properties that add value beyond direct AST access are augmented:**
9
+ * - Precedence resolution: `effectiveClassification`, `effectiveTeam` (for array-based properties)
10
+ * - Data transformation: `metadataMap` (array to Map)
11
+ * - Computed values: `fqn` (fully qualified name)
12
+ * - Helper methods: `hasClassification()`, `hasTeam()`, `hasMetadata()`, `hasType()`
13
+ *
14
+ * **Direct AST access (no augmentation needed):**
15
+ * - `bc.description` - Direct string property
16
+ * - `bc.businessModel?.ref` - Direct reference
17
+ * - `bc.evolution?.ref` - Direct reference
18
+ * - `bc.archetype?.ref` - Direct reference
19
+ * - `domain.description` - Direct string property
20
+ * - `domain.vision` - Direct string property
21
+ * - `domain.type?.ref` - Direct reference
22
+ *
23
+ * **Usage:**
24
+ * ```typescript
25
+ * import '../sdk/ast-augmentation.js'; // Enable augmented properties
26
+ * import { fromDocument } from '../sdk/index.js';
27
+ *
28
+ * fromDocument(document); // Ensures augmentation
29
+ * const bc: BoundedContext = ...;
30
+ * console.log(bc.effectiveClassification?.name);
31
+ * console.log(bc.metadataMap.get('Language'));
32
+ * // Direct access for simple properties:
33
+ * console.log(bc.businessModel?.ref?.name);
34
+ * ```
35
+ *
36
+ * **Properties added to BoundedContext:**
37
+ * - `effectiveClassification` - Inline `as` header → body `classification:`
38
+ * - `effectiveTeam` - Inline `team` header → body `team:`
39
+ * - `metadataMap` - Metadata entries exposed as a ReadonlyMap
40
+ * - `fqn` - Computed fully qualified name
41
+ * - `hasClassification(name)` - Check if classification matches
42
+ * - `hasTeam(name)` - Check if team matches
43
+ * - `hasMetadata(key, value?)` - Check metadata
44
+ *
45
+ * **Properties added to Domain:**
46
+ * - `fqn` - Computed fully qualified name
47
+ * - `hasType(name)` - Check type matches
48
+ *
49
+ * **Properties added to Relationship:**
50
+ * - `hasPattern(pattern)` - Check if pattern exists on either side
51
+ * - `hasLeftPattern(pattern)` - Check left patterns
52
+ * - `hasRightPattern(pattern)` - Check right patterns
53
+ * - `isUpstream(side)` - Check if side is upstream
54
+ * - `isDownstream(side)` - Check if side is downstream
55
+ * - `isBidirectional` - Check if relationship is bidirectional
56
+ * - `leftContextName` - Resolved name of left context
57
+ * - `rightContextName` - Resolved name of right context
58
+ *
59
+ * @module sdk/ast-augmentation
60
+ */
61
+ /**
62
+ * Module augmentation for native SDK properties on AST types.
63
+ */
64
+ declare module '../generated/ast.js' {
65
+ /**
66
+ * Augmented BoundedContext with SDK-computed properties.
67
+ *
68
+ * Note: description, businessModel, evolution, archetype, metadata, relationships,
69
+ * terminology, and decisions are direct AST properties - use them directly.
70
+ */
71
+ interface BoundedContext {
72
+ /** Effective classification with inline precedence (header `as` > body `classification:`) */
73
+ readonly effectiveClassification: import('../generated/ast.js').Classification | undefined;
74
+ /** Effective team with inline precedence (header `by` > body `team:`) */
75
+ readonly effectiveTeam: import('../generated/ast.js').Team | undefined;
76
+ /** Metadata entries exposed as a map for O(1) lookups */
77
+ readonly metadataMap: ReadonlyMap<string, string>;
78
+ /** SDK-computed fully qualified name */
79
+ readonly fqn: string;
80
+ /** Checks if this bounded context has the specified classification. */
81
+ hasClassification(name: string | import('../generated/ast.js').Classification): boolean;
82
+ /** Checks if this bounded context is owned by the specified team. */
83
+ hasTeam(name: string | import('../generated/ast.js').Team): boolean;
84
+ /** Checks if this bounded context has metadata with the given key (and optionally value). */
85
+ hasMetadata(key: string, value?: string): boolean;
86
+ }
87
+ /**
88
+ * Augmented Domain with SDK-computed properties.
89
+ *
90
+ * Note: description, vision, and type are direct AST properties - use them directly.
91
+ */
92
+ interface Domain {
93
+ /** SDK-computed fully qualified name */
94
+ readonly fqn: string;
95
+ /** Checks if this domain has the specified type. */
96
+ hasType(name: string | import('../generated/ast.js').Classification): boolean;
97
+ }
98
+ /**
99
+ * Augmented Relationship with SDK helper methods.
100
+ */
101
+ interface Relationship {
102
+ /** Resolved name of left context (handles 'this') */
103
+ readonly leftContextName: string;
104
+ /** Resolved name of right context (handles 'this') */
105
+ readonly rightContextName: string;
106
+ /** Whether this is a bidirectional relationship (<->) */
107
+ readonly isBidirectional: boolean;
108
+ /**
109
+ * Checks if the relationship has a specific integration pattern on either side.
110
+ * Accepts both abbreviations (SK, ACL) and full names (SharedKernel, AntiCorruptionLayer).
111
+ * @param pattern - Pattern abbreviation or full name
112
+ */
113
+ hasPattern(pattern: import('./patterns.js').IntegrationPattern | string): boolean;
114
+ /**
115
+ * Checks if the left side has a specific integration pattern.
116
+ * @param pattern - Pattern abbreviation or full name
117
+ */
118
+ hasLeftPattern(pattern: import('./patterns.js').IntegrationPattern | string): boolean;
119
+ /**
120
+ * Checks if the right side has a specific integration pattern.
121
+ * @param pattern - Pattern abbreviation or full name
122
+ */
123
+ hasRightPattern(pattern: import('./patterns.js').IntegrationPattern | string): boolean;
124
+ /**
125
+ * Checks if the specified side is upstream (provider) in this relationship.
126
+ * @param side - 'left' or 'right'
127
+ */
128
+ isUpstream(side: 'left' | 'right'): boolean;
129
+ /**
130
+ * Checks if the specified side is downstream (consumer) in this relationship.
131
+ * @param side - 'left' or 'right'
132
+ */
133
+ isDownstream(side: 'left' | 'right'): boolean;
134
+ }
135
+ }
136
+ export {};
@@ -0,0 +1,62 @@
1
+ /**
2
+ * SDK AST Augmentation - Module augmentation for native SDK properties.
3
+ *
4
+ * This file uses TypeScript's declaration merging to add computed helpers
5
+ * directly to the AST types. After importing this module, BoundedContext,
6
+ * Domain, and Relationship instances expose convenience getters.
7
+ *
8
+ * **Only properties that add value beyond direct AST access are augmented:**
9
+ * - Precedence resolution: `effectiveClassification`, `effectiveTeam` (for array-based properties)
10
+ * - Data transformation: `metadataMap` (array to Map)
11
+ * - Computed values: `fqn` (fully qualified name)
12
+ * - Helper methods: `hasClassification()`, `hasTeam()`, `hasMetadata()`, `hasType()`
13
+ *
14
+ * **Direct AST access (no augmentation needed):**
15
+ * - `bc.description` - Direct string property
16
+ * - `bc.businessModel?.ref` - Direct reference
17
+ * - `bc.evolution?.ref` - Direct reference
18
+ * - `bc.archetype?.ref` - Direct reference
19
+ * - `domain.description` - Direct string property
20
+ * - `domain.vision` - Direct string property
21
+ * - `domain.type?.ref` - Direct reference
22
+ *
23
+ * **Usage:**
24
+ * ```typescript
25
+ * import '../sdk/ast-augmentation.js'; // Enable augmented properties
26
+ * import { fromDocument } from '../sdk/index.js';
27
+ *
28
+ * fromDocument(document); // Ensures augmentation
29
+ * const bc: BoundedContext = ...;
30
+ * console.log(bc.effectiveClassification?.name);
31
+ * console.log(bc.metadataMap.get('Language'));
32
+ * // Direct access for simple properties:
33
+ * console.log(bc.businessModel?.ref?.name);
34
+ * ```
35
+ *
36
+ * **Properties added to BoundedContext:**
37
+ * - `effectiveClassification` - Inline `as` header → body `classification:`
38
+ * - `effectiveTeam` - Inline `team` header → body `team:`
39
+ * - `metadataMap` - Metadata entries exposed as a ReadonlyMap
40
+ * - `fqn` - Computed fully qualified name
41
+ * - `hasClassification(name)` - Check if classification matches
42
+ * - `hasTeam(name)` - Check if team matches
43
+ * - `hasMetadata(key, value?)` - Check metadata
44
+ *
45
+ * **Properties added to Domain:**
46
+ * - `fqn` - Computed fully qualified name
47
+ * - `hasType(name)` - Check type matches
48
+ *
49
+ * **Properties added to Relationship:**
50
+ * - `hasPattern(pattern)` - Check if pattern exists on either side
51
+ * - `hasLeftPattern(pattern)` - Check left patterns
52
+ * - `hasRightPattern(pattern)` - Check right patterns
53
+ * - `isUpstream(side)` - Check if side is upstream
54
+ * - `isDownstream(side)` - Check if side is downstream
55
+ * - `isBidirectional` - Check if relationship is bidirectional
56
+ * - `leftContextName` - Resolved name of left context
57
+ * - `rightContextName` - Resolved name of right context
58
+ *
59
+ * @module sdk/ast-augmentation
60
+ */
61
+ export {};
62
+ //# sourceMappingURL=ast-augmentation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ast-augmentation.js","sourceRoot":"","sources":["../../src/sdk/ast-augmentation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2DG"}
@@ -0,0 +1,94 @@
1
+ /**
2
+ * Model Query SDK - Public API
3
+ *
4
+ * Provides fluent, type-safe query operations on DomainLang models.
5
+ *
6
+ * ## Architecture: SDK vs LSP Responsibilities
7
+ *
8
+ * The SDK is **read-only and query-focused**. It does NOT manage:
9
+ * - Workspace lifecycle (LSP/WorkspaceManager handles this)
10
+ * - File watching or change detection (LSP/TextDocuments handles this)
11
+ * - Cross-file import resolution (LSP/DocumentBuilder handles this)
12
+ * - Document validation scheduling (LSP handles this)
13
+ *
14
+ * **SDK responsibilities:**
15
+ * - Augmented AST properties (transparent property access with precedence rules)
16
+ * - Fluent query chains with lazy iteration
17
+ * - O(1) indexed lookups by FQN/name
18
+ * - Resolution rules (which block wins for 0..1 properties)
19
+ *
20
+ * **Entry points for different deployment targets:**
21
+ *
22
+ * | Target | Entry Point | Browser-Safe | Notes |
23
+ * |--------|-------------|--------------|-------|
24
+ * | VS Code Extension | `fromDocument()` | ✅ | Zero-copy LSP integration |
25
+ * | Web Editor | `fromDocument()`, `loadModelFromText()` | ✅ | Browser-compatible |
26
+ * | CLI (Node.js) | `loadModel()` from `sdk/loader-node` | ❌ | File system access |
27
+ * | Hosted LSP | `fromDocument()`, `fromServices()` | ✅ | Server-side only |
28
+ * | Testing | `loadModelFromText()` | ✅ | In-memory parsing |
29
+ *
30
+ * ## Browser vs Node.js
31
+ *
32
+ * This module (`sdk/index`) is **browser-safe** and exports only:
33
+ * - `loadModelFromText()` - uses EmptyFileSystem
34
+ * - `fromModel()`, `fromDocument()`, `fromServices()` - zero-copy wrappers
35
+ *
36
+ * For file-based loading in Node.js CLI tools:
37
+ * ```typescript
38
+ * import { loadModel } from 'domain-lang-language/sdk/loader-node';
39
+ * ```
40
+ *
41
+ * @packageDocumentation
42
+ *
43
+ * @example
44
+ * ```typescript
45
+ * // Node.js CLI: Load from file (requires sdk/loader-node)
46
+ * import { loadModel } from 'domain-lang-language/sdk/loader-node';
47
+ *
48
+ * const { query } = await loadModel('./domains.dlang', {
49
+ * workspaceDir: process.cwd()
50
+ * });
51
+ *
52
+ * const coreContexts = query.boundedContexts()
53
+ * .withClassification('Core')
54
+ * .withTeam('PaymentTeam');
55
+ *
56
+ * for (const bc of coreContexts) {
57
+ * console.log(`${bc.name}: ${bc.description ?? 'n/a'}`);
58
+ * }
59
+ * ```
60
+ *
61
+ * @example
62
+ * ```typescript
63
+ * // Browser/Testing: Load from text (browser-safe)
64
+ * import { loadModelFromText } from '@domainlang/language/sdk';
65
+ *
66
+ * const { query } = await loadModelFromText(`
67
+ * Domain Sales { vision: "Handle sales" }
68
+ * bc OrderContext for Sales
69
+ * `);
70
+ *
71
+ * const sales = query.domain('Sales');
72
+ * console.log(sales?.vision);
73
+ * ```
74
+ *
75
+ * @example
76
+ * ```typescript
77
+ * // LSP Integration: Zero-copy access to existing AST (browser-safe)
78
+ * import { fromDocument } from '@domainlang/language/sdk';
79
+ *
80
+ * export class HoverProvider {
81
+ * getHover(document: LangiumDocument<Model>) {
82
+ * // SDK wraps existing AST - no reloading, no file I/O
83
+ * const query = fromDocument(document);
84
+ * const bc = query.boundedContext('OrderContext');
85
+ * return bc?.description;
86
+ * }
87
+ * }
88
+ * ```
89
+ */
90
+ export { loadModelFromText } from './loader.js';
91
+ export { fromModel, fromDocument, fromServices, augmentModel } from './query.js';
92
+ export { Pattern, PatternFullName, PatternAliases, matchesPattern, isUpstreamPattern, isDownstreamPattern, isMutualPattern, UpstreamPatterns, DownstreamPatterns, MutualPatterns, } from './patterns.js';
93
+ export type { IntegrationPattern } from './patterns.js';
94
+ export type { Query, QueryBuilder, QueryContext, LoadOptions, BcQueryBuilder, RelationshipView, } from './types.js';