@domainlang/language 0.1.81

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 (188) hide show
  1. package/README.md +32 -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 +55 -0
  6. package/out/domain-lang-module.js +59 -0
  7. package/out/domain-lang-module.js.map +1 -0
  8. package/out/generated/ast.d.ts +770 -0
  9. package/out/generated/ast.js +565 -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 +2502 -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 +13 -0
  18. package/out/index.js +17 -0
  19. package/out/index.js.map +1 -0
  20. package/out/lsp/domain-lang-completion.d.ts +37 -0
  21. package/out/lsp/domain-lang-completion.js +452 -0
  22. package/out/lsp/domain-lang-completion.js.map +1 -0
  23. package/out/lsp/domain-lang-formatter.d.ts +15 -0
  24. package/out/lsp/domain-lang-formatter.js +43 -0
  25. package/out/lsp/domain-lang-formatter.js.map +1 -0
  26. package/out/lsp/domain-lang-naming.d.ts +34 -0
  27. package/out/lsp/domain-lang-naming.js +49 -0
  28. package/out/lsp/domain-lang-naming.js.map +1 -0
  29. package/out/lsp/domain-lang-scope.d.ts +59 -0
  30. package/out/lsp/domain-lang-scope.js +102 -0
  31. package/out/lsp/domain-lang-scope.js.map +1 -0
  32. package/out/lsp/hover/ddd-pattern-explanations.d.ts +50 -0
  33. package/out/lsp/hover/ddd-pattern-explanations.js +196 -0
  34. package/out/lsp/hover/ddd-pattern-explanations.js.map +1 -0
  35. package/out/lsp/hover/domain-lang-hover.d.ts +19 -0
  36. package/out/lsp/hover/domain-lang-hover.js +306 -0
  37. package/out/lsp/hover/domain-lang-hover.js.map +1 -0
  38. package/out/lsp/hover/domain-lang-keywords.d.ts +13 -0
  39. package/out/lsp/hover/domain-lang-keywords.js +47 -0
  40. package/out/lsp/hover/domain-lang-keywords.js.map +1 -0
  41. package/out/main-browser.d.ts +1 -0
  42. package/out/main-browser.js +11 -0
  43. package/out/main-browser.js.map +1 -0
  44. package/out/main.d.ts +1 -0
  45. package/out/main.js +74 -0
  46. package/out/main.js.map +1 -0
  47. package/out/sdk/ast-augmentation.d.ts +136 -0
  48. package/out/sdk/ast-augmentation.js +62 -0
  49. package/out/sdk/ast-augmentation.js.map +1 -0
  50. package/out/sdk/index.d.ts +94 -0
  51. package/out/sdk/index.js +97 -0
  52. package/out/sdk/index.js.map +1 -0
  53. package/out/sdk/indexes.d.ts +16 -0
  54. package/out/sdk/indexes.js +97 -0
  55. package/out/sdk/indexes.js.map +1 -0
  56. package/out/sdk/loader-node.d.ts +47 -0
  57. package/out/sdk/loader-node.js +104 -0
  58. package/out/sdk/loader-node.js.map +1 -0
  59. package/out/sdk/loader.d.ts +49 -0
  60. package/out/sdk/loader.js +85 -0
  61. package/out/sdk/loader.js.map +1 -0
  62. package/out/sdk/patterns.d.ts +93 -0
  63. package/out/sdk/patterns.js +123 -0
  64. package/out/sdk/patterns.js.map +1 -0
  65. package/out/sdk/query.d.ts +90 -0
  66. package/out/sdk/query.js +679 -0
  67. package/out/sdk/query.js.map +1 -0
  68. package/out/sdk/resolution.d.ts +52 -0
  69. package/out/sdk/resolution.js +68 -0
  70. package/out/sdk/resolution.js.map +1 -0
  71. package/out/sdk/types.d.ts +301 -0
  72. package/out/sdk/types.js +8 -0
  73. package/out/sdk/types.js.map +1 -0
  74. package/out/services/dependency-analyzer.d.ts +94 -0
  75. package/out/services/dependency-analyzer.js +279 -0
  76. package/out/services/dependency-analyzer.js.map +1 -0
  77. package/out/services/dependency-resolver.d.ts +123 -0
  78. package/out/services/dependency-resolver.js +252 -0
  79. package/out/services/dependency-resolver.js.map +1 -0
  80. package/out/services/git-url-resolver.browser.d.ts +18 -0
  81. package/out/services/git-url-resolver.browser.js +15 -0
  82. package/out/services/git-url-resolver.browser.js.map +1 -0
  83. package/out/services/git-url-resolver.d.ts +192 -0
  84. package/out/services/git-url-resolver.js +382 -0
  85. package/out/services/git-url-resolver.js.map +1 -0
  86. package/out/services/governance-validator.d.ts +80 -0
  87. package/out/services/governance-validator.js +159 -0
  88. package/out/services/governance-validator.js.map +1 -0
  89. package/out/services/import-resolver.d.ts +18 -0
  90. package/out/services/import-resolver.js +22 -0
  91. package/out/services/import-resolver.js.map +1 -0
  92. package/out/services/performance-optimizer.d.ts +60 -0
  93. package/out/services/performance-optimizer.js +140 -0
  94. package/out/services/performance-optimizer.js.map +1 -0
  95. package/out/services/relationship-inference.d.ts +11 -0
  96. package/out/services/relationship-inference.js +98 -0
  97. package/out/services/relationship-inference.js.map +1 -0
  98. package/out/services/workspace-manager.d.ts +76 -0
  99. package/out/services/workspace-manager.js +323 -0
  100. package/out/services/workspace-manager.js.map +1 -0
  101. package/out/syntaxes/domain-lang.monarch.d.ts +76 -0
  102. package/out/syntaxes/domain-lang.monarch.js +29 -0
  103. package/out/syntaxes/domain-lang.monarch.js.map +1 -0
  104. package/out/utils/import-utils.d.ts +57 -0
  105. package/out/utils/import-utils.js +228 -0
  106. package/out/utils/import-utils.js.map +1 -0
  107. package/out/validation/bounded-context.d.ts +11 -0
  108. package/out/validation/bounded-context.js +79 -0
  109. package/out/validation/bounded-context.js.map +1 -0
  110. package/out/validation/classification.d.ts +3 -0
  111. package/out/validation/classification.js +3 -0
  112. package/out/validation/classification.js.map +1 -0
  113. package/out/validation/constants.d.ts +77 -0
  114. package/out/validation/constants.js +96 -0
  115. package/out/validation/constants.js.map +1 -0
  116. package/out/validation/domain-lang-validator.d.ts +2 -0
  117. package/out/validation/domain-lang-validator.js +27 -0
  118. package/out/validation/domain-lang-validator.js.map +1 -0
  119. package/out/validation/domain.d.ts +11 -0
  120. package/out/validation/domain.js +18 -0
  121. package/out/validation/domain.js.map +1 -0
  122. package/out/validation/import.d.ts +44 -0
  123. package/out/validation/import.js +135 -0
  124. package/out/validation/import.js.map +1 -0
  125. package/out/validation/maps.d.ts +21 -0
  126. package/out/validation/maps.js +56 -0
  127. package/out/validation/maps.js.map +1 -0
  128. package/out/validation/metadata.d.ts +7 -0
  129. package/out/validation/metadata.js +12 -0
  130. package/out/validation/metadata.js.map +1 -0
  131. package/out/validation/model.d.ts +12 -0
  132. package/out/validation/model.js +29 -0
  133. package/out/validation/model.js.map +1 -0
  134. package/out/validation/relationships.d.ts +12 -0
  135. package/out/validation/relationships.js +94 -0
  136. package/out/validation/relationships.js.map +1 -0
  137. package/out/validation/shared.d.ts +6 -0
  138. package/out/validation/shared.js +12 -0
  139. package/out/validation/shared.js.map +1 -0
  140. package/package.json +97 -0
  141. package/src/ast-augmentation.ts +5 -0
  142. package/src/domain-lang-module.ts +100 -0
  143. package/src/domain-lang.langium +356 -0
  144. package/src/generated/ast.ts +999 -0
  145. package/src/generated/grammar.ts +2504 -0
  146. package/src/generated/module.ts +25 -0
  147. package/src/index.ts +17 -0
  148. package/src/lsp/domain-lang-completion.ts +514 -0
  149. package/src/lsp/domain-lang-formatter.ts +51 -0
  150. package/src/lsp/domain-lang-naming.ts +56 -0
  151. package/src/lsp/domain-lang-scope.ts +137 -0
  152. package/src/lsp/hover/ddd-pattern-explanations.ts +237 -0
  153. package/src/lsp/hover/domain-lang-hover.ts +340 -0
  154. package/src/lsp/hover/domain-lang-keywords.ts +50 -0
  155. package/src/main-browser.ts +15 -0
  156. package/src/main.ts +85 -0
  157. package/src/sdk/README.md +297 -0
  158. package/src/sdk/ast-augmentation.ts +157 -0
  159. package/src/sdk/index.ts +128 -0
  160. package/src/sdk/indexes.ts +155 -0
  161. package/src/sdk/loader-node.ts +126 -0
  162. package/src/sdk/loader.ts +99 -0
  163. package/src/sdk/patterns.ts +147 -0
  164. package/src/sdk/query.ts +802 -0
  165. package/src/sdk/resolution.ts +78 -0
  166. package/src/sdk/types.ts +346 -0
  167. package/src/services/dependency-analyzer.ts +381 -0
  168. package/src/services/dependency-resolver.ts +334 -0
  169. package/src/services/git-url-resolver.browser.ts +31 -0
  170. package/src/services/git-url-resolver.ts +524 -0
  171. package/src/services/governance-validator.ts +219 -0
  172. package/src/services/import-resolver.ts +30 -0
  173. package/src/services/performance-optimizer.ts +170 -0
  174. package/src/services/relationship-inference.ts +121 -0
  175. package/src/services/workspace-manager.ts +416 -0
  176. package/src/syntaxes/domain-lang.monarch.ts +29 -0
  177. package/src/utils/import-utils.ts +274 -0
  178. package/src/validation/bounded-context.ts +99 -0
  179. package/src/validation/classification.ts +5 -0
  180. package/src/validation/constants.ts +124 -0
  181. package/src/validation/domain-lang-validator.ts +33 -0
  182. package/src/validation/domain.ts +24 -0
  183. package/src/validation/import.ts +171 -0
  184. package/src/validation/maps.ts +72 -0
  185. package/src/validation/metadata.ts +14 -0
  186. package/src/validation/model.ts +37 -0
  187. package/src/validation/relationships.ts +154 -0
  188. package/src/validation/shared.ts +14 -0
@@ -0,0 +1,135 @@
1
+ import { resolveImportPath } from '../utils/import-utils.js';
2
+ /**
3
+ * Validates import statements in DomainLang.
4
+ *
5
+ * Checks:
6
+ * - Import paths are resolvable
7
+ * - Named imports exist in target document
8
+ * - Import aliases don't conflict with local names
9
+ */
10
+ export class ImportValidator {
11
+ constructor(services) {
12
+ this.documents = services.shared.workspace.LangiumDocuments;
13
+ }
14
+ /**
15
+ * Validates that an import path is resolvable.
16
+ */
17
+ async checkImportPath(imp, accept, document) {
18
+ if (!imp.uri) {
19
+ accept('error', 'Import statement must have a URI', {
20
+ node: imp,
21
+ keyword: 'import'
22
+ });
23
+ return;
24
+ }
25
+ try {
26
+ await resolveImportPath(document, imp.uri);
27
+ }
28
+ catch (error) {
29
+ const message = error instanceof Error ? error.message : String(error);
30
+ accept('error', `Cannot resolve import: ${message}`, {
31
+ node: imp,
32
+ property: 'uri'
33
+ });
34
+ }
35
+ }
36
+ /**
37
+ * Validates that named imports exist in the target document.
38
+ */
39
+ async checkNamedImports(imp, accept, document) {
40
+ // Only check if we have named imports
41
+ if (!imp.symbols || imp.symbols.length === 0) {
42
+ return;
43
+ }
44
+ if (!imp.uri) {
45
+ return; // Already reported by checkImportPath
46
+ }
47
+ try {
48
+ // Resolve the target document
49
+ const targetUri = await resolveImportPath(document, imp.uri);
50
+ const targetDoc = await this.documents.getOrCreateDocument(targetUri);
51
+ if (!targetDoc.parseResult?.value) {
52
+ accept('error', `Cannot load imported document: ${imp.uri}`, {
53
+ node: imp,
54
+ property: 'uri'
55
+ });
56
+ return;
57
+ }
58
+ // Get all exported symbols from target document
59
+ const targetModel = targetDoc.parseResult.value;
60
+ const exportedSymbols = this.getExportedSymbols(targetModel);
61
+ // Check each imported symbol
62
+ for (const symbol of imp.symbols) {
63
+ if (!exportedSymbols.has(symbol)) {
64
+ accept('error', `Symbol '${symbol}' not found in ${imp.uri}`, {
65
+ node: imp,
66
+ property: 'symbols'
67
+ });
68
+ }
69
+ }
70
+ }
71
+ catch {
72
+ // Import path error already reported by checkImportPath
73
+ return;
74
+ }
75
+ }
76
+ /**
77
+ * Gets all exportable symbols from a model.
78
+ *
79
+ * In DomainLang, top-level declarations are implicitly exported:
80
+ * - Domains
81
+ * - BoundedContexts
82
+ * - Classifications
83
+ * - Groups
84
+ */
85
+ getExportedSymbols(model) {
86
+ const symbols = new Set();
87
+ // Iterate through all structure elements
88
+ for (const element of model.children ?? []) {
89
+ // Check if element has a name and add it
90
+ if ('name' in element && typeof element.name === 'string') {
91
+ symbols.add(element.name);
92
+ }
93
+ }
94
+ return symbols;
95
+ }
96
+ /**
97
+ * Checks for unused imports.
98
+ *
99
+ * This is a warning, not an error, to avoid being too strict.
100
+ */
101
+ checkUnusedImports(imp, _accept, _model) {
102
+ // Skip check for wildcard imports (no named imports)
103
+ if (!imp.symbols || imp.symbols.length === 0) {
104
+ return;
105
+ }
106
+ // For now, just a placeholder - would require tracking symbol usage
107
+ // across the entire document, which is complex
108
+ // TODO: Implement symbol usage tracking
109
+ }
110
+ }
111
+ /**
112
+ * Creates validation checks for import statements.
113
+ */
114
+ export function createImportChecks(_services) {
115
+ return {
116
+ ImportStatement: (imp, accept) => {
117
+ const document = imp.$document;
118
+ if (!document)
119
+ return;
120
+ // Note: Langium's validation is synchronous, so async checks won't
121
+ // execute during document validation. These checks will run during
122
+ // the build phase when documents are fully loaded.
123
+ // For now, just do basic syntax validation
124
+ if (!imp.uri) {
125
+ accept('error', 'Import statement must have a URI', {
126
+ node: imp,
127
+ keyword: 'import'
128
+ });
129
+ }
130
+ // TODO: Implement async validation in a separate build phase
131
+ // This would require using DocumentBuilder.onBuildPhase() or similar
132
+ }
133
+ };
134
+ }
135
+ //# sourceMappingURL=import.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"import.js","sourceRoot":"","sources":["../../src/validation/import.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAI7D;;;;;;;GAOG;AACH,MAAM,OAAO,eAAe;IAGxB,YAAY,QAA4B;QACpC,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC,MAAM,CAAC,SAAS,CAAC,gBAAgB,CAAC;IAChE,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,eAAe,CACjB,GAAoB,EACpB,MAA0B,EAC1B,QAAyB;QAEzB,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC;YACX,MAAM,CAAC,OAAO,EAAE,kCAAkC,EAAE;gBAChD,IAAI,EAAE,GAAG;gBACT,OAAO,EAAE,QAAQ;aACpB,CAAC,CAAC;YACH,OAAO;QACX,CAAC;QAED,IAAI,CAAC;YACD,MAAM,iBAAiB,CAAC,QAAQ,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC;QAC/C,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACb,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OA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OAAO,EAAE,kCAAkC,EAAE;oBAChD,IAAI,EAAE,GAAG;oBACT,OAAO,EAAE,QAAQ;iBACpB,CAAC,CAAC;YACP,CAAC;YAED,6DAA6D;YAC7D,qEAAqE;QACzE,CAAC;KACJ,CAAC;AACN,CAAC"}
@@ -0,0 +1,21 @@
1
+ import type { ValidationAcceptor } from 'langium';
2
+ import type { ContextMap, DomainMap } from '../generated/ast.js';
3
+ /**
4
+ * Validates that a context map contains at least one bounded context.
5
+ * Empty context maps are not useful for documentation purposes.
6
+ *
7
+ * @param map - The context map to validate
8
+ * @param accept - The validation acceptor for reporting issues
9
+ */
10
+ declare function validateContextMapHasContexts(map: ContextMap, accept: ValidationAcceptor): void;
11
+ /**
12
+ * Validates that a domain map contains at least one domain.
13
+ * Empty domain maps are not useful for documentation purposes.
14
+ *
15
+ * @param map - The domain map to validate
16
+ * @param accept - The validation acceptor for reporting issues
17
+ */
18
+ declare function validateDomainMapHasDomains(map: DomainMap, accept: ValidationAcceptor): void;
19
+ export declare const contextMapChecks: (typeof validateContextMapHasContexts)[];
20
+ export declare const domainMapChecks: (typeof validateDomainMapHasDomains)[];
21
+ export {};
@@ -0,0 +1,56 @@
1
+ /**
2
+ * Validates that a context map contains at least one bounded context.
3
+ * Empty context maps are not useful for documentation purposes.
4
+ *
5
+ * @param map - The context map to validate
6
+ * @param accept - The validation acceptor for reporting issues
7
+ */
8
+ function validateContextMapHasContexts(map, accept) {
9
+ if (!map.boundedContexts || map.boundedContexts.length === 0) {
10
+ accept('warning', `Context Map '${map.name}' contains no bounded contexts`, {
11
+ node: map,
12
+ keyword: 'contains'
13
+ });
14
+ }
15
+ }
16
+ /**
17
+ * Validates that a context map has at least one relationship if it contains multiple contexts.
18
+ * Multiple unrelated contexts should have documented relationships.
19
+ *
20
+ * @param map - The context map to validate
21
+ * @param accept - The validation acceptor for reporting issues
22
+ */
23
+ function validateContextMapHasRelationships(map, accept) {
24
+ const contextCount = map.boundedContexts?.length ?? 0;
25
+ const relationshipCount = map.relationships?.length ?? 0;
26
+ // Only warn if multiple contexts exist without relationships
27
+ if (contextCount > 1 && relationshipCount === 0) {
28
+ accept('info', `Context Map '${map.name}' contains ${contextCount} contexts but no documented relationships`, {
29
+ node: map,
30
+ keyword: 'ContextMap'
31
+ });
32
+ }
33
+ }
34
+ /**
35
+ * Validates that a domain map contains at least one domain.
36
+ * Empty domain maps are not useful for documentation purposes.
37
+ *
38
+ * @param map - The domain map to validate
39
+ * @param accept - The validation acceptor for reporting issues
40
+ */
41
+ function validateDomainMapHasDomains(map, accept) {
42
+ if (!map.domains || map.domains.length === 0) {
43
+ accept('warning', `Domain Map '${map.name}' contains no domains`, {
44
+ node: map,
45
+ keyword: 'contains'
46
+ });
47
+ }
48
+ }
49
+ export const contextMapChecks = [
50
+ validateContextMapHasContexts,
51
+ validateContextMapHasRelationships
52
+ ];
53
+ export const domainMapChecks = [
54
+ validateDomainMapHasDomains
55
+ ];
56
+ //# sourceMappingURL=maps.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"maps.js","sourceRoot":"","sources":["../../src/validation/maps.ts"],"names":[],"mappings":"AAGA;;;;;;GAMG;AACH,SAAS,6BAA6B,CAClC,GAAe,EACf,MAA0B;IAE1B,IAAI,CAAC,GAAG,CAAC,eAAe,IAAI,GAAG,CAAC,eAAe,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC3D,MAAM,CAAC,SAAS,EAAE,gBAAgB,GAAG,CAAC,IAAI,gCAAgC,EAAE;YACxE,IAAI,EAAE,GAAG;YACT,OAAO,EAAE,UAAU;SACtB,CAAC,CAAC;IACP,CAAC;AACL,CAAC;AAED;;;;;;GAMG;AACH,SAAS,kCAAkC,CACvC,GAAe,EACf,MAA0B;IAE1B,MAAM,YAAY,GAAG,GAAG,CAAC,eAAe,EAAE,MAAM,IAAI,CAAC,CAAC;IACtD,MAAM,iBAAiB,GAAG,GAAG,CAAC,aAAa,EAAE,MAAM,IAAI,CAAC,CAAC;IAEzD,6DAA6D;IAC7D,IAAI,YAAY,GAAG,CAAC,IAAI,iBAAiB,KAAK,CAAC,EAAE,CAAC;QAC9C,MAAM,CAAC,MAAM,EAAE,gBAAgB,GAAG,CAAC,IAAI,cAAc,YAAY,2CAA2C,EAAE;YAC1G,IAAI,EAAE,GAAG;YACT,OAAO,EAAE,YAAY;SACxB,CAAC,CAAC;IACP,CAAC;AACL,CAAC;AAED;;;;;;GAMG;AACH,SAAS,2BAA2B,CAChC,GAAc,EACd,MAA0B;IAE1B,IAAI,CAAC,GAAG,CAAC,OAAO,IAAI,GAAG,CAAC,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC3C,MAAM,CAAC,SAAS,EAAE,eAAe,GAAG,CAAC,IAAI,uBAAuB,EAAE;YAC9D,IAAI,EAAE,GAAG;YACT,OAAO,EAAE,UAAU;SACtB,CAAC,CAAC;IACP,CAAC;AACL,CAAC;AAED,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC5B,6BAA6B;IAC7B,kCAAkC;CACrC,CAAC;AAEF,MAAM,CAAC,MAAM,eAAe,GAAG;IAC3B,2BAA2B;CAC9B,CAAC"}
@@ -0,0 +1,7 @@
1
+ import type { ValidationChecks } from 'langium';
2
+ import type { DomainLangAstType } from '../generated/ast.js';
3
+ /**
4
+ * Validation checks for Metadata elements.
5
+ * - Ensures metadata keys are defined before use
6
+ */
7
+ export declare const metadataChecks: ValidationChecks<DomainLangAstType>;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Validation checks for Metadata elements.
3
+ * - Ensures metadata keys are defined before use
4
+ */
5
+ export const metadataChecks = {
6
+ Metadata(metadata, accept) {
7
+ if (!metadata.name) {
8
+ accept('error', 'Metadata must have a name', { node: metadata });
9
+ }
10
+ },
11
+ };
12
+ //# sourceMappingURL=metadata.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"metadata.js","sourceRoot":"","sources":["../../src/validation/metadata.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAwC;IAC/D,QAAQ,CAAC,QAAkB,EAAE,MAAM;QAC/B,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;YACjB,MAAM,CAAC,OAAO,EAAE,2BAA2B,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC;QACrE,CAAC;IACL,CAAC;CACJ,CAAC"}
@@ -0,0 +1,12 @@
1
+ import type { ValidationAcceptor } from 'langium';
2
+ import type { Model } from '../generated/ast.js';
3
+ /**
4
+ * Validates that all elements in the model have unique fully qualified names.
5
+ * Also triggers relationship type inference.
6
+ *
7
+ * @param model - The model to validate
8
+ * @param accept - The validation acceptor for reporting issues
9
+ */
10
+ declare function validateModelUniqueNames(model: Model, accept: ValidationAcceptor): void;
11
+ export declare const modelChecks: (typeof validateModelUniqueNames)[];
12
+ export {};
@@ -0,0 +1,29 @@
1
+ import { setInferredRelationshipTypes } from '../services/relationship-inference.js';
2
+ import { extractNames } from './shared.js';
3
+ import { ValidationMessages, buildCodeDescription } from './constants.js';
4
+ /**
5
+ * Validates that all elements in the model have unique fully qualified names.
6
+ * Also triggers relationship type inference.
7
+ *
8
+ * @param model - The model to validate
9
+ * @param accept - The validation acceptor for reporting issues
10
+ */
11
+ function validateModelUniqueNames(model, accept) {
12
+ const uniqueNames = new Set();
13
+ const names = extractNames(model);
14
+ for (const { fqn, node } of names) {
15
+ const oldSize = uniqueNames.size;
16
+ uniqueNames.add(fqn);
17
+ if (uniqueNames.size === oldSize) {
18
+ accept('error', ValidationMessages.DUPLICATE_ELEMENT(fqn), {
19
+ node: node,
20
+ property: 'name',
21
+ codeDescription: buildCodeDescription('language.md', 'naming')
22
+ });
23
+ }
24
+ }
25
+ // Enrich relationships with inferred types
26
+ setInferredRelationshipTypes(model);
27
+ }
28
+ export const modelChecks = [validateModelUniqueNames];
29
+ //# sourceMappingURL=model.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model.js","sourceRoot":"","sources":["../../src/validation/model.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,4BAA4B,EAAE,MAAM,uCAAuC,CAAC;AACrF,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAG3C,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAE1E;;;;;;GAMG;AACH,SAAS,wBAAwB,CAC7B,KAAY,EACZ,MAA0B;IAE1B,MAAM,WAAW,GAAG,IAAI,GAAG,EAAU,CAAC;IACtC,MAAM,KAAK,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC;IAElC,KAAK,MAAM,EAAC,GAAG,EAAE,IAAI,EAAC,IAAI,KAAK,EAAE,CAAC;QAC9B,MAAM,OAAO,GAAG,WAAW,CAAC,IAAI,CAAC;QACjC,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACrB,IAAI,WAAW,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;YAC/B,MAAM,CAAC,OAAO,EAAE,kBAAkB,CAAC,iBAAiB,CAAC,GAAG,CAAC,EAAE;gBACvD,IAAI,EAAE,IAAI;gBACV,QAAQ,EAAE,MAAM;gBAChB,eAAe,EAAE,oBAAoB,CAAC,aAAa,EAAE,QAAQ,CAAC;aACjE,CAAC,CAAC;QACP,CAAC;IACL,CAAC;IAED,2CAA2C;IAC3C,4BAA4B,CAAC,KAAK,CAAC,CAAC;AACxC,CAAC;AAED,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,wBAAwB,CAAC,CAAC"}
@@ -0,0 +1,12 @@
1
+ import type { ValidationAcceptor } from 'langium';
2
+ import type { Relationship } from '../generated/ast.js';
3
+ /**
4
+ * Validates that SharedKernel patterns use bidirectional relationships.
5
+ * SharedKernel implies mutual dependency and shared code ownership.
6
+ *
7
+ * @param relationship - The relationship to validate
8
+ * @param accept - The validation acceptor for reporting issues
9
+ */
10
+ declare function validateSharedKernelBidirectional(relationship: Relationship, accept: ValidationAcceptor): void;
11
+ export declare const relationshipChecks: (typeof validateSharedKernelBidirectional)[];
12
+ export {};
@@ -0,0 +1,94 @@
1
+ import { isThisRef } from '../generated/ast.js';
2
+ import { ValidationMessages, buildCodeDescription } from './constants.js';
3
+ /**
4
+ * Gets a display name for a BoundedContextRef (handles 'this' and regular refs).
5
+ */
6
+ function getContextName(ref) {
7
+ if (isThisRef(ref)) {
8
+ return 'this';
9
+ }
10
+ return ref.link?.$refText ?? 'unknown';
11
+ }
12
+ /**
13
+ * Validates that SharedKernel patterns use bidirectional relationships.
14
+ * SharedKernel implies mutual dependency and shared code ownership.
15
+ *
16
+ * @param relationship - The relationship to validate
17
+ * @param accept - The validation acceptor for reporting issues
18
+ */
19
+ function validateSharedKernelBidirectional(relationship, accept) {
20
+ // Check if SharedKernel pattern exists on either side
21
+ const hasSharedKernelLeft = relationship.leftPatterns?.some(pattern => pattern === 'SK' || pattern === 'SharedKernel');
22
+ const hasSharedKernelRight = relationship.rightPatterns?.some(pattern => pattern === 'SK' || pattern === 'SharedKernel');
23
+ if ((hasSharedKernelLeft || hasSharedKernelRight) && relationship.arrow !== '<->') {
24
+ const leftName = getContextName(relationship.left);
25
+ const rightName = getContextName(relationship.right);
26
+ accept('warning', ValidationMessages.SHARED_KERNEL_MUST_BE_BIDIRECTIONAL(leftName, rightName, relationship.arrow), { node: relationship, property: 'arrow', codeDescription: buildCodeDescription('language.md', 'integration-patterns') });
27
+ }
28
+ }
29
+ /**
30
+ * Validates that Anti-Corruption Layer (ACL) is on the consuming side.
31
+ * ACL protects downstream context from upstream changes.
32
+ *
33
+ * @param relationship - The relationship to validate
34
+ * @param accept - The validation acceptor for reporting issues
35
+ */
36
+ function validateACLPlacement(relationship, accept) {
37
+ const hasACLLeft = relationship.leftPatterns?.some(pattern => pattern === 'ACL' || pattern === 'AntiCorruptionLayer');
38
+ const hasACLRight = relationship.rightPatterns?.some(pattern => pattern === 'ACL' || pattern === 'AntiCorruptionLayer');
39
+ // ACL on left side with -> arrow means upstream has ACL (incorrect)
40
+ if (hasACLLeft && relationship.arrow === '->') {
41
+ const leftName = getContextName(relationship.left);
42
+ accept('warning', ValidationMessages.ACL_ON_WRONG_SIDE(leftName, 'left'), { node: relationship, property: 'leftPatterns', codeDescription: buildCodeDescription('language.md', 'integration-patterns') });
43
+ }
44
+ // ACL on right side with <- arrow means upstream has ACL (incorrect)
45
+ if (hasACLRight && relationship.arrow === '<-') {
46
+ const rightName = getContextName(relationship.right);
47
+ accept('warning', ValidationMessages.ACL_ON_WRONG_SIDE(rightName, 'right'), { node: relationship, property: 'rightPatterns', codeDescription: buildCodeDescription('language.md', 'integration-patterns') });
48
+ }
49
+ }
50
+ /**
51
+ * Validates that Conformist pattern is on the consuming side.
52
+ * Conformist means accepting upstream model without translation.
53
+ *
54
+ * @param relationship - The relationship to validate
55
+ * @param accept - The validation acceptor for reporting issues
56
+ */
57
+ function validateConformistPlacement(relationship, accept) {
58
+ const hasCFLeft = relationship.leftPatterns?.some(pattern => pattern === 'CF' || pattern === 'Conformist');
59
+ const hasCFRight = relationship.rightPatterns?.some(pattern => pattern === 'CF' || pattern === 'Conformist');
60
+ // CF on left side with -> arrow means upstream is conformist (incorrect)
61
+ if (hasCFLeft && relationship.arrow === '->') {
62
+ const leftName = getContextName(relationship.left);
63
+ accept('warning', ValidationMessages.CONFORMIST_ON_WRONG_SIDE(leftName, 'left'), { node: relationship, property: 'leftPatterns', codeDescription: buildCodeDescription('language.md', 'integration-patterns') });
64
+ }
65
+ // CF on right side with <- arrow means upstream is conformist (incorrect)
66
+ if (hasCFRight && relationship.arrow === '<-') {
67
+ const rightName = getContextName(relationship.right);
68
+ accept('warning', ValidationMessages.CONFORMIST_ON_WRONG_SIDE(rightName, 'right'), { node: relationship, property: 'rightPatterns', codeDescription: buildCodeDescription('language.md', 'integration-patterns') });
69
+ }
70
+ }
71
+ /**
72
+ * Validates that relationships don't have too many integration patterns.
73
+ * More than 3 patterns on one side suggests syntax confusion.
74
+ *
75
+ * @param relationship - The relationship to validate
76
+ * @param accept - The validation acceptor for reporting issues
77
+ */
78
+ function validatePatternCount(relationship, accept) {
79
+ const leftCount = relationship.leftPatterns?.length ?? 0;
80
+ const rightCount = relationship.rightPatterns?.length ?? 0;
81
+ if (leftCount > 3) {
82
+ accept('info', ValidationMessages.TOO_MANY_PATTERNS(leftCount, 'left'), { node: relationship, property: 'leftPatterns', codeDescription: buildCodeDescription('language.md', 'integration-patterns') });
83
+ }
84
+ if (rightCount > 3) {
85
+ accept('info', ValidationMessages.TOO_MANY_PATTERNS(rightCount, 'right'), { node: relationship, property: 'rightPatterns', codeDescription: buildCodeDescription('language.md', 'integration-patterns') });
86
+ }
87
+ }
88
+ export const relationshipChecks = [
89
+ validateSharedKernelBidirectional,
90
+ validateACLPlacement,
91
+ validateConformistPlacement,
92
+ validatePatternCount
93
+ ];
94
+ //# sourceMappingURL=relationships.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"relationships.js","sourceRoot":"","sources":["../../src/validation/relationships.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAE1E;;GAEG;AACH,SAAS,cAAc,CAAC,GAAsB;IAC1C,IAAI,SAAS,CAAC,GAAG,CAAC,EAAE,CAAC;QACjB,OAAO,MAAM,CAAC;IAClB,CAAC;IACD,OAAO,GAAG,CAAC,IAAI,EAAE,QAAQ,IAAI,SAAS,CAAC;AAC3C,CAAC;AAED;;;;;;GAMG;AACH,SAAS,iCAAiC,CACtC,YAA0B,EAC1B,MAA0B;IAE1B,sDAAsD;IACtD,MAAM,mBAAmB,GAAG,YAAY,CAAC,YAAY,EAAE,IAAI,CACvD,OAAO,CAAC,EAAE,CAAC,OAAO,KAAK,IAAI,IAAI,OAAO,KAAK,cAAc,CAC5D,CAAC;IACF,MAAM,oBAAoB,GAAG,YAAY,CAAC,aAAa,EAAE,IAAI,CACzD,OAAO,CAAC,EAA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../generated/ast.js';
3
+ export declare function extractNames(element: Container): Generator<{
4
+ fqn: string;
5
+ node: AstNode;
6
+ }>;
@@ -0,0 +1,12 @@
1
+ import { isContainer } from '../generated/ast.js';
2
+ import { QualifiedNameProvider } from '../lsp/domain-lang-naming.js';
3
+ export function* extractNames(element) {
4
+ const fqnProvider = new QualifiedNameProvider();
5
+ for (const child of element.children) {
6
+ yield { fqn: fqnProvider.getQualifiedName(child.$container, child.name), node: child };
7
+ if (isContainer(child)) {
8
+ yield* extractNames(child);
9
+ }
10
+ }
11
+ }
12
+ //# sourceMappingURL=shared.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shared.js","sourceRoot":"","sources":["../../src/validation/shared.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAErE,MAAM,SAAS,CAAC,CAAC,YAAY,CAAC,OAAkB;IAC5C,MAAM,WAAW,GAAG,IAAI,qBAAqB,EAAE,CAAC;IAChD,KAAK,MAAM,KAAK,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;QACnC,MAAM,EAAC,GAAG,EAAE,WAAW,CAAC,gBAAgB,CAAC,KAAK,CAAC,UAAU,EAAE,KAAK,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,KAAK,EAAC,CAAC;QACrF,IAAI,WAAW,CAAC,KAAK,CAAC,EAAE,CAAC;YACrB,KAAK,CAAC,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;QAC/B,CAAC;IACL,CAAC;AACL,CAAC"}
package/package.json ADDED
@@ -0,0 +1,97 @@
1
+ {
2
+ "name": "@domainlang/language",
3
+ "version": "0.1.81",
4
+ "displayName": "DomainLang",
5
+ "description": "A DSL for Domain-Driven Design",
6
+ "publisher": "thinkability",
7
+ "author": "larsbaunwall",
8
+ "license": "Apache License 2.0",
9
+ "icon": "images/icon.png",
10
+ "keywords": [
11
+ "ddd",
12
+ "domain-driven design",
13
+ "langium",
14
+ "dlang",
15
+ "domainlang"
16
+ ],
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "https://github.com/larsbaunwall/DomainLang"
20
+ },
21
+ "bugs": {
22
+ "url": "https://github.com/larsbaunwall/DomainLang/issues"
23
+ },
24
+ "type": "module",
25
+ "engines": {
26
+ "node": ">=20.10.0",
27
+ "npm": ">=10.2.3"
28
+ },
29
+ "files": [
30
+ "out",
31
+ "src"
32
+ ],
33
+ "main": "./out/index.js",
34
+ "module": "./out/index.js",
35
+ "exports": {
36
+ ".": {
37
+ "types": "./out/index.d.ts",
38
+ "default": "./out/index.js"
39
+ },
40
+ "./sdk": {
41
+ "types": "./out/sdk/index.d.ts",
42
+ "default": "./out/sdk/index.js"
43
+ },
44
+ "./main-browser": {
45
+ "types": "./out/main-browser.d.ts",
46
+ "default": "./out/main-browser.js"
47
+ },
48
+ "./syntaxes/domain-lang.monarch.js": {
49
+ "types": "./out/syntaxes/domain-lang.monarch.d.ts",
50
+ "default": "./out/syntaxes/domain-lang.monarch.js"
51
+ },
52
+ "./syntaxes/domain-lang.monarch": {
53
+ "types": "./out/syntaxes/domain-lang.monarch.d.ts",
54
+ "default": "./out/syntaxes/domain-lang.monarch.js"
55
+ },
56
+ "./src/services/git-url-resolver.js": {
57
+ "browser": "./src/services/git-url-resolver.browser.js",
58
+ "default": "./src/services/git-url-resolver.js"
59
+ }
60
+ },
61
+ "typesVersions": {
62
+ "*": {
63
+ ".": [
64
+ "out/index"
65
+ ]
66
+ }
67
+ },
68
+ "scripts": {
69
+ "clean": "shx rm -fr *.tsbuildinfo out",
70
+ "build": "tsc -b tsconfig.src.json",
71
+ "build:clean": "npm run clean && npm run build",
72
+ "langium:generate": "langium generate",
73
+ "langium:watch": "langium generate --watch",
74
+ "test": "vitest run",
75
+ "test:coverage": "vitest run --coverage"
76
+ },
77
+ "dependencies": {
78
+ "langium": "~4.1.0",
79
+ "yaml": "^2.5.0"
80
+ },
81
+ "devDependencies": {
82
+ "@types/node": "~20.17.48",
83
+ "@vitest/coverage-v8": "^3.1.4",
84
+ "langium-cli": "~4.1.0",
85
+ "shx": "~0.4.0",
86
+ "typescript": "~5.8.3",
87
+ "vitest": "~3.1.3"
88
+ },
89
+ "volta": {
90
+ "node": "20.19.2",
91
+ "npm": "10.8.2"
92
+ },
93
+ "publishConfig": {
94
+ "access": "public",
95
+ "registry": "https://registry.npmjs.org/"
96
+ }
97
+ }
@@ -0,0 +1,5 @@
1
+ declare module './generated/ast.js' {
2
+ interface Relationship {
3
+ inferredType?: string;
4
+ }
5
+ }
@@ -0,0 +1,100 @@
1
+ import { type Module, inject } from 'langium';
2
+ import type {
3
+ DefaultSharedModuleContext,
4
+ LangiumServices,
5
+ LangiumSharedServices,
6
+ PartialLangiumServices
7
+ } from 'langium/lsp';
8
+ import { createDefaultModule, createDefaultSharedModule } from 'langium/lsp';
9
+ import { DomainLangGeneratedModule, DomainLangGeneratedSharedModule } from './generated/module.js';
10
+ import { registerValidationChecks } from './validation/domain-lang-validator.js';
11
+ import { QualifiedNameProvider } from './lsp/domain-lang-naming.js';
12
+ import { DomainLangScopeComputation } from './lsp/domain-lang-scope.js';
13
+ import { DomainLangFormatter } from './lsp/domain-lang-formatter.js';
14
+ import { DomainLangHoverProvider } from './lsp/hover/domain-lang-hover.js';
15
+ import { DomainLangCompletionProvider } from './lsp/domain-lang-completion.js';
16
+ import { ImportResolver } from './services/import-resolver.js';
17
+ import { WorkspaceManager } from './services/workspace-manager.js';
18
+
19
+ /**
20
+ * Declaration of custom services - add your own service classes here.
21
+ */
22
+ export type DomainLangAddedServices = {
23
+ imports: {
24
+ ImportResolver: ImportResolver,
25
+ WorkspaceManager: WorkspaceManager
26
+ },
27
+ references: {
28
+ QualifiedNameProvider: QualifiedNameProvider
29
+ },
30
+ lsp: {
31
+ Formatter: DomainLangFormatter,
32
+ HoverProvider: DomainLangHoverProvider,
33
+ CompletionProvider: DomainLangCompletionProvider
34
+ }
35
+ }
36
+
37
+ /**
38
+ * Union of Langium default services and your custom services - use this as constructor parameter
39
+ * of custom service classes.
40
+ */
41
+ export type DomainLangServices = LangiumServices & DomainLangAddedServices
42
+
43
+ /**
44
+ * Dependency injection module that overrides Langium default services and contributes the
45
+ * declared custom services. The Langium defaults can be partially specified to override only
46
+ * selected services, while the custom services must be fully specified.
47
+ */
48
+ export const DomainLangModule: Module<DomainLangServices, PartialLangiumServices & DomainLangAddedServices> = {
49
+ imports: {
50
+ ImportResolver: (services) => new ImportResolver(services),
51
+ WorkspaceManager: () => new WorkspaceManager()
52
+ },
53
+ references: {
54
+ ScopeComputation: (services) => new DomainLangScopeComputation(services),
55
+ QualifiedNameProvider: () => new QualifiedNameProvider()
56
+ },
57
+ lsp: {
58
+ Formatter: () => new DomainLangFormatter(),
59
+ HoverProvider: (services) => new DomainLangHoverProvider(services),
60
+ CompletionProvider: (services) => new DomainLangCompletionProvider(services)
61
+ },
62
+ };
63
+
64
+ /**
65
+ * Create the full set of services required by Langium.
66
+ *
67
+ * First inject the shared services by merging two modules:
68
+ * - Langium default shared services
69
+ * - Services generated by langium-cli
70
+ *
71
+ * Then inject the language-specific services by merging three modules:
72
+ * - Langium default language-specific services
73
+ * - Services generated by langium-cli
74
+ * - Services specified in this file
75
+ *
76
+ * @param context Optional module context with the LSP connection
77
+ * @returns An object wrapping the shared services and the language-specific services
78
+ */
79
+ export function createDomainLangServices(context: DefaultSharedModuleContext): {
80
+ shared: LangiumSharedServices,
81
+ DomainLang: DomainLangServices
82
+ } {
83
+ const shared = inject(
84
+ createDefaultSharedModule(context),
85
+ DomainLangGeneratedSharedModule
86
+ );
87
+ const DomainLang = inject(
88
+ createDefaultModule({ shared }),
89
+ DomainLangGeneratedModule,
90
+ DomainLangModule
91
+ );
92
+ shared.ServiceRegistry.register(DomainLang);
93
+ registerValidationChecks(DomainLang);
94
+ if (!context.connection) {
95
+ // We don't run inside a language server
96
+ // Therefore, initialize the configuration provider instantly
97
+ shared.workspace.ConfigurationProvider.initialized({});
98
+ }
99
+ return { shared, DomainLang };
100
+ }