@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.
- package/README.md +163 -0
- package/out/ast-augmentation.d.ts +6 -0
- package/out/ast-augmentation.js +2 -0
- package/out/ast-augmentation.js.map +1 -0
- package/out/domain-lang-module.d.ts +57 -0
- package/out/domain-lang-module.js +67 -0
- package/out/domain-lang-module.js.map +1 -0
- package/out/generated/ast.d.ts +759 -0
- package/out/generated/ast.js +556 -0
- package/out/generated/ast.js.map +1 -0
- package/out/generated/grammar.d.ts +6 -0
- package/out/generated/grammar.js +2407 -0
- package/out/generated/grammar.js.map +1 -0
- package/out/generated/module.d.ts +13 -0
- package/out/generated/module.js +21 -0
- package/out/generated/module.js.map +1 -0
- package/out/index.d.ts +16 -0
- package/out/index.js +22 -0
- package/out/index.js.map +1 -0
- package/out/lsp/domain-lang-code-actions.d.ts +55 -0
- package/out/lsp/domain-lang-code-actions.js +143 -0
- package/out/lsp/domain-lang-code-actions.js.map +1 -0
- package/out/lsp/domain-lang-completion.d.ts +37 -0
- package/out/lsp/domain-lang-completion.js +452 -0
- package/out/lsp/domain-lang-completion.js.map +1 -0
- package/out/lsp/domain-lang-formatter.d.ts +15 -0
- package/out/lsp/domain-lang-formatter.js +43 -0
- package/out/lsp/domain-lang-formatter.js.map +1 -0
- package/out/lsp/domain-lang-naming.d.ts +34 -0
- package/out/lsp/domain-lang-naming.js +49 -0
- package/out/lsp/domain-lang-naming.js.map +1 -0
- package/out/lsp/domain-lang-scope.d.ts +59 -0
- package/out/lsp/domain-lang-scope.js +102 -0
- package/out/lsp/domain-lang-scope.js.map +1 -0
- package/out/lsp/domain-lang-workspace-manager.d.ts +21 -0
- package/out/lsp/domain-lang-workspace-manager.js +93 -0
- package/out/lsp/domain-lang-workspace-manager.js.map +1 -0
- package/out/lsp/hover/ddd-pattern-explanations.d.ts +50 -0
- package/out/lsp/hover/ddd-pattern-explanations.js +196 -0
- package/out/lsp/hover/ddd-pattern-explanations.js.map +1 -0
- package/out/lsp/hover/domain-lang-hover.d.ts +19 -0
- package/out/lsp/hover/domain-lang-hover.js +302 -0
- package/out/lsp/hover/domain-lang-hover.js.map +1 -0
- package/out/lsp/hover/domain-lang-keywords.d.ts +13 -0
- package/out/lsp/hover/domain-lang-keywords.js +47 -0
- package/out/lsp/hover/domain-lang-keywords.js.map +1 -0
- package/out/lsp/manifest-diagnostics.d.ts +82 -0
- package/out/lsp/manifest-diagnostics.js +230 -0
- package/out/lsp/manifest-diagnostics.js.map +1 -0
- package/out/main-browser.d.ts +1 -0
- package/out/main-browser.js +11 -0
- package/out/main-browser.js.map +1 -0
- package/out/main.d.ts +1 -0
- package/out/main.js +74 -0
- package/out/main.js.map +1 -0
- package/out/sdk/ast-augmentation.d.ts +136 -0
- package/out/sdk/ast-augmentation.js +62 -0
- package/out/sdk/ast-augmentation.js.map +1 -0
- package/out/sdk/index.d.ts +94 -0
- package/out/sdk/index.js +97 -0
- package/out/sdk/index.js.map +1 -0
- package/out/sdk/indexes.d.ts +16 -0
- package/out/sdk/indexes.js +97 -0
- package/out/sdk/indexes.js.map +1 -0
- package/out/sdk/loader-node.d.ts +51 -0
- package/out/sdk/loader-node.js +119 -0
- package/out/sdk/loader-node.js.map +1 -0
- package/out/sdk/loader.d.ts +49 -0
- package/out/sdk/loader.js +85 -0
- package/out/sdk/loader.js.map +1 -0
- package/out/sdk/patterns.d.ts +93 -0
- package/out/sdk/patterns.js +123 -0
- package/out/sdk/patterns.js.map +1 -0
- package/out/sdk/query.d.ts +90 -0
- package/out/sdk/query.js +679 -0
- package/out/sdk/query.js.map +1 -0
- package/out/sdk/resolution.d.ts +52 -0
- package/out/sdk/resolution.js +68 -0
- package/out/sdk/resolution.js.map +1 -0
- package/out/sdk/types.d.ts +280 -0
- package/out/sdk/types.js +8 -0
- package/out/sdk/types.js.map +1 -0
- package/out/services/dependency-analyzer.d.ts +58 -0
- package/out/services/dependency-analyzer.js +254 -0
- package/out/services/dependency-analyzer.js.map +1 -0
- package/out/services/dependency-resolver.d.ts +146 -0
- package/out/services/dependency-resolver.js +452 -0
- package/out/services/dependency-resolver.js.map +1 -0
- package/out/services/git-url-resolver.browser.d.ts +10 -0
- package/out/services/git-url-resolver.browser.js +19 -0
- package/out/services/git-url-resolver.browser.js.map +1 -0
- package/out/services/git-url-resolver.d.ts +158 -0
- package/out/services/git-url-resolver.js +416 -0
- package/out/services/git-url-resolver.js.map +1 -0
- package/out/services/governance-validator.d.ts +44 -0
- package/out/services/governance-validator.js +153 -0
- package/out/services/governance-validator.js.map +1 -0
- package/out/services/import-resolver.d.ts +77 -0
- package/out/services/import-resolver.js +240 -0
- package/out/services/import-resolver.js.map +1 -0
- package/out/services/performance-optimizer.d.ts +60 -0
- package/out/services/performance-optimizer.js +140 -0
- package/out/services/performance-optimizer.js.map +1 -0
- package/out/services/relationship-inference.d.ts +11 -0
- package/out/services/relationship-inference.js +98 -0
- package/out/services/relationship-inference.js.map +1 -0
- package/out/services/semver.d.ts +98 -0
- package/out/services/semver.js +195 -0
- package/out/services/semver.js.map +1 -0
- package/out/services/types.d.ts +340 -0
- package/out/services/types.js +46 -0
- package/out/services/types.js.map +1 -0
- package/out/services/workspace-manager.d.ts +123 -0
- package/out/services/workspace-manager.js +489 -0
- package/out/services/workspace-manager.js.map +1 -0
- package/out/syntaxes/domain-lang.monarch.d.ts +76 -0
- package/out/syntaxes/domain-lang.monarch.js +29 -0
- package/out/syntaxes/domain-lang.monarch.js.map +1 -0
- package/out/utils/import-utils.d.ts +49 -0
- package/out/utils/import-utils.js +128 -0
- package/out/utils/import-utils.js.map +1 -0
- package/out/validation/bounded-context.d.ts +11 -0
- package/out/validation/bounded-context.js +79 -0
- package/out/validation/bounded-context.js.map +1 -0
- package/out/validation/classification.d.ts +3 -0
- package/out/validation/classification.js +3 -0
- package/out/validation/classification.js.map +1 -0
- package/out/validation/constants.d.ts +180 -0
- package/out/validation/constants.js +235 -0
- package/out/validation/constants.js.map +1 -0
- package/out/validation/domain-lang-validator.d.ts +2 -0
- package/out/validation/domain-lang-validator.js +27 -0
- package/out/validation/domain-lang-validator.js.map +1 -0
- package/out/validation/domain.d.ts +11 -0
- package/out/validation/domain.js +63 -0
- package/out/validation/domain.js.map +1 -0
- package/out/validation/import.d.ts +68 -0
- package/out/validation/import.js +237 -0
- package/out/validation/import.js.map +1 -0
- package/out/validation/manifest.d.ts +144 -0
- package/out/validation/manifest.js +327 -0
- package/out/validation/manifest.js.map +1 -0
- package/out/validation/maps.d.ts +21 -0
- package/out/validation/maps.js +60 -0
- package/out/validation/maps.js.map +1 -0
- package/out/validation/metadata.d.ts +7 -0
- package/out/validation/metadata.js +16 -0
- package/out/validation/metadata.js.map +1 -0
- package/out/validation/model.d.ts +12 -0
- package/out/validation/model.js +29 -0
- package/out/validation/model.js.map +1 -0
- package/out/validation/relationships.d.ts +12 -0
- package/out/validation/relationships.js +94 -0
- package/out/validation/relationships.js.map +1 -0
- package/out/validation/shared.d.ts +6 -0
- package/out/validation/shared.js +12 -0
- package/out/validation/shared.js.map +1 -0
- package/package.json +110 -0
- package/src/ast-augmentation.ts +5 -0
- package/src/domain-lang-module.ts +112 -0
- package/src/domain-lang.langium +351 -0
- package/src/generated/ast.ts +986 -0
- package/src/generated/grammar.ts +2409 -0
- package/src/generated/module.ts +25 -0
- package/src/index.ts +24 -0
- package/src/lsp/domain-lang-code-actions.ts +189 -0
- package/src/lsp/domain-lang-completion.ts +514 -0
- package/src/lsp/domain-lang-formatter.ts +51 -0
- package/src/lsp/domain-lang-naming.ts +56 -0
- package/src/lsp/domain-lang-scope.ts +137 -0
- package/src/lsp/domain-lang-workspace-manager.ts +104 -0
- package/src/lsp/hover/ddd-pattern-explanations.ts +237 -0
- package/src/lsp/hover/domain-lang-hover.ts +338 -0
- package/src/lsp/hover/domain-lang-keywords.ts +50 -0
- package/src/lsp/manifest-diagnostics.ts +290 -0
- package/src/main-browser.ts +15 -0
- package/src/main.ts +85 -0
- package/src/sdk/README.md +297 -0
- package/src/sdk/ast-augmentation.ts +157 -0
- package/src/sdk/index.ts +126 -0
- package/src/sdk/indexes.ts +155 -0
- package/src/sdk/loader-node.ts +146 -0
- package/src/sdk/loader.ts +99 -0
- package/src/sdk/patterns.ts +147 -0
- package/src/sdk/query.ts +802 -0
- package/src/sdk/resolution.ts +78 -0
- package/src/sdk/types.ts +323 -0
- package/src/services/dependency-analyzer.ts +321 -0
- package/src/services/dependency-resolver.ts +551 -0
- package/src/services/git-url-resolver.browser.ts +26 -0
- package/src/services/git-url-resolver.ts +517 -0
- package/src/services/governance-validator.ts +177 -0
- package/src/services/import-resolver.ts +292 -0
- package/src/services/performance-optimizer.ts +170 -0
- package/src/services/relationship-inference.ts +121 -0
- package/src/services/semver.ts +213 -0
- package/src/services/types.ts +415 -0
- package/src/services/workspace-manager.ts +607 -0
- package/src/syntaxes/domain-lang.monarch.ts +29 -0
- package/src/utils/import-utils.ts +152 -0
- package/src/validation/bounded-context.ts +99 -0
- package/src/validation/classification.ts +5 -0
- package/src/validation/constants.ts +304 -0
- package/src/validation/domain-lang-validator.ts +33 -0
- package/src/validation/domain.ts +77 -0
- package/src/validation/import.ts +295 -0
- package/src/validation/manifest.ts +439 -0
- package/src/validation/maps.ts +76 -0
- package/src/validation/metadata.ts +18 -0
- package/src/validation/model.ts +37 -0
- package/src/validation/relationships.ts +154 -0
- package/src/validation/shared.ts +14 -0
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import type { ValidationAcceptor } from 'langium';
|
|
2
|
+
import type { Relationship, BoundedContextRef } from '../generated/ast.js';
|
|
3
|
+
import { isThisRef } from '../generated/ast.js';
|
|
4
|
+
import { ValidationMessages, buildCodeDescription } from './constants.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Gets a display name for a BoundedContextRef (handles 'this' and regular refs).
|
|
8
|
+
*/
|
|
9
|
+
function getContextName(ref: BoundedContextRef): string {
|
|
10
|
+
if (isThisRef(ref)) {
|
|
11
|
+
return 'this';
|
|
12
|
+
}
|
|
13
|
+
return ref.link?.$refText ?? 'unknown';
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Validates that SharedKernel patterns use bidirectional relationships.
|
|
18
|
+
* SharedKernel implies mutual dependency and shared code ownership.
|
|
19
|
+
*
|
|
20
|
+
* @param relationship - The relationship to validate
|
|
21
|
+
* @param accept - The validation acceptor for reporting issues
|
|
22
|
+
*/
|
|
23
|
+
function validateSharedKernelBidirectional(
|
|
24
|
+
relationship: Relationship,
|
|
25
|
+
accept: ValidationAcceptor
|
|
26
|
+
): void {
|
|
27
|
+
// Check if SharedKernel pattern exists on either side
|
|
28
|
+
const hasSharedKernelLeft = relationship.leftPatterns?.some(
|
|
29
|
+
pattern => pattern === 'SK' || pattern === 'SharedKernel'
|
|
30
|
+
);
|
|
31
|
+
const hasSharedKernelRight = relationship.rightPatterns?.some(
|
|
32
|
+
pattern => pattern === 'SK' || pattern === 'SharedKernel'
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
if ((hasSharedKernelLeft || hasSharedKernelRight) && relationship.arrow !== '<->') {
|
|
36
|
+
const leftName = getContextName(relationship.left);
|
|
37
|
+
const rightName = getContextName(relationship.right);
|
|
38
|
+
|
|
39
|
+
accept('warning',
|
|
40
|
+
ValidationMessages.SHARED_KERNEL_MUST_BE_BIDIRECTIONAL(leftName, rightName, relationship.arrow),
|
|
41
|
+
{ node: relationship, property: 'arrow', codeDescription: buildCodeDescription('language.md', 'integration-patterns') }
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Validates that Anti-Corruption Layer (ACL) is on the consuming side.
|
|
48
|
+
* ACL protects downstream context from upstream changes.
|
|
49
|
+
*
|
|
50
|
+
* @param relationship - The relationship to validate
|
|
51
|
+
* @param accept - The validation acceptor for reporting issues
|
|
52
|
+
*/
|
|
53
|
+
function validateACLPlacement(
|
|
54
|
+
relationship: Relationship,
|
|
55
|
+
accept: ValidationAcceptor
|
|
56
|
+
): void {
|
|
57
|
+
const hasACLLeft = relationship.leftPatterns?.some(
|
|
58
|
+
pattern => pattern === 'ACL' || pattern === 'AntiCorruptionLayer'
|
|
59
|
+
);
|
|
60
|
+
const hasACLRight = relationship.rightPatterns?.some(
|
|
61
|
+
pattern => pattern === 'ACL' || pattern === 'AntiCorruptionLayer'
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
// ACL on left side with -> arrow means upstream has ACL (incorrect)
|
|
65
|
+
if (hasACLLeft && relationship.arrow === '->') {
|
|
66
|
+
const leftName = getContextName(relationship.left);
|
|
67
|
+
accept('warning',
|
|
68
|
+
ValidationMessages.ACL_ON_WRONG_SIDE(leftName, 'left'),
|
|
69
|
+
{ node: relationship, property: 'leftPatterns', codeDescription: buildCodeDescription('language.md', 'integration-patterns') }
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// ACL on right side with <- arrow means upstream has ACL (incorrect)
|
|
74
|
+
if (hasACLRight && relationship.arrow === '<-') {
|
|
75
|
+
const rightName = getContextName(relationship.right);
|
|
76
|
+
accept('warning',
|
|
77
|
+
ValidationMessages.ACL_ON_WRONG_SIDE(rightName, 'right'),
|
|
78
|
+
{ node: relationship, property: 'rightPatterns', codeDescription: buildCodeDescription('language.md', 'integration-patterns') }
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Validates that Conformist pattern is on the consuming side.
|
|
85
|
+
* Conformist means accepting upstream model without translation.
|
|
86
|
+
*
|
|
87
|
+
* @param relationship - The relationship to validate
|
|
88
|
+
* @param accept - The validation acceptor for reporting issues
|
|
89
|
+
*/
|
|
90
|
+
function validateConformistPlacement(
|
|
91
|
+
relationship: Relationship,
|
|
92
|
+
accept: ValidationAcceptor
|
|
93
|
+
): void {
|
|
94
|
+
const hasCFLeft = relationship.leftPatterns?.some(
|
|
95
|
+
pattern => pattern === 'CF' || pattern === 'Conformist'
|
|
96
|
+
);
|
|
97
|
+
const hasCFRight = relationship.rightPatterns?.some(
|
|
98
|
+
pattern => pattern === 'CF' || pattern === 'Conformist'
|
|
99
|
+
);
|
|
100
|
+
|
|
101
|
+
// CF on left side with -> arrow means upstream is conformist (incorrect)
|
|
102
|
+
if (hasCFLeft && relationship.arrow === '->') {
|
|
103
|
+
const leftName = getContextName(relationship.left);
|
|
104
|
+
accept('warning',
|
|
105
|
+
ValidationMessages.CONFORMIST_ON_WRONG_SIDE(leftName, 'left'),
|
|
106
|
+
{ node: relationship, property: 'leftPatterns', codeDescription: buildCodeDescription('language.md', 'integration-patterns') }
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// CF on right side with <- arrow means upstream is conformist (incorrect)
|
|
111
|
+
if (hasCFRight && relationship.arrow === '<-') {
|
|
112
|
+
const rightName = getContextName(relationship.right);
|
|
113
|
+
accept('warning',
|
|
114
|
+
ValidationMessages.CONFORMIST_ON_WRONG_SIDE(rightName, 'right'),
|
|
115
|
+
{ node: relationship, property: 'rightPatterns', codeDescription: buildCodeDescription('language.md', 'integration-patterns') }
|
|
116
|
+
);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Validates that relationships don't have too many integration patterns.
|
|
122
|
+
* More than 3 patterns on one side suggests syntax confusion.
|
|
123
|
+
*
|
|
124
|
+
* @param relationship - The relationship to validate
|
|
125
|
+
* @param accept - The validation acceptor for reporting issues
|
|
126
|
+
*/
|
|
127
|
+
function validatePatternCount(
|
|
128
|
+
relationship: Relationship,
|
|
129
|
+
accept: ValidationAcceptor
|
|
130
|
+
): void {
|
|
131
|
+
const leftCount = relationship.leftPatterns?.length ?? 0;
|
|
132
|
+
const rightCount = relationship.rightPatterns?.length ?? 0;
|
|
133
|
+
|
|
134
|
+
if (leftCount > 3) {
|
|
135
|
+
accept('info',
|
|
136
|
+
ValidationMessages.TOO_MANY_PATTERNS(leftCount, 'left'),
|
|
137
|
+
{ node: relationship, property: 'leftPatterns', codeDescription: buildCodeDescription('language.md', 'integration-patterns') }
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
if (rightCount > 3) {
|
|
142
|
+
accept('info',
|
|
143
|
+
ValidationMessages.TOO_MANY_PATTERNS(rightCount, 'right'),
|
|
144
|
+
{ node: relationship, property: 'rightPatterns', codeDescription: buildCodeDescription('language.md', 'integration-patterns') }
|
|
145
|
+
);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
export const relationshipChecks = [
|
|
150
|
+
validateSharedKernelBidirectional,
|
|
151
|
+
validateACLPlacement,
|
|
152
|
+
validateConformistPlacement,
|
|
153
|
+
validatePatternCount
|
|
154
|
+
];
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { AstNode } from 'langium';
|
|
2
|
+
import type { Container } from '../generated/ast.js';
|
|
3
|
+
import { isContainer } from '../generated/ast.js';
|
|
4
|
+
import { QualifiedNameProvider } from '../lsp/domain-lang-naming.js';
|
|
5
|
+
|
|
6
|
+
export function* extractNames(element: Container): Generator<{fqn: string, node: AstNode}> {
|
|
7
|
+
const fqnProvider = new QualifiedNameProvider();
|
|
8
|
+
for (const child of element.children) {
|
|
9
|
+
yield {fqn: fqnProvider.getQualifiedName(child.$container, child.name), node: child};
|
|
10
|
+
if (isContainer(child)) {
|
|
11
|
+
yield* extractNames(child);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
}
|