@domainlang/language 0.5.2 → 0.7.0
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 +1 -1
- package/out/domain-lang-module.js +5 -1
- package/out/domain-lang-module.js.map +1 -1
- package/out/generated/ast.d.ts +24 -0
- package/out/generated/ast.js.map +1 -1
- package/out/generated/grammar.js +22 -32
- package/out/generated/grammar.js.map +1 -1
- package/out/index.d.ts +2 -5
- package/out/index.js +10 -6
- package/out/index.js.map +1 -1
- package/out/lsp/domain-lang-code-actions.js +14 -8
- package/out/lsp/domain-lang-code-actions.js.map +1 -1
- package/out/lsp/domain-lang-completion.d.ts +3 -0
- package/out/lsp/domain-lang-completion.js +41 -13
- package/out/lsp/domain-lang-completion.js.map +1 -1
- package/out/lsp/domain-lang-formatter.js +24 -18
- package/out/lsp/domain-lang-formatter.js.map +1 -1
- package/out/lsp/domain-lang-index-manager.d.ts +170 -0
- package/out/lsp/domain-lang-index-manager.js +389 -0
- package/out/lsp/domain-lang-index-manager.js.map +1 -0
- package/out/lsp/domain-lang-scope-provider.d.ts +67 -0
- package/out/lsp/domain-lang-scope-provider.js +95 -0
- package/out/lsp/domain-lang-scope-provider.js.map +1 -0
- package/out/lsp/domain-lang-scope.js +31 -17
- package/out/lsp/domain-lang-scope.js.map +1 -1
- package/out/lsp/domain-lang-workspace-manager.d.ts +76 -9
- package/out/lsp/domain-lang-workspace-manager.js +176 -54
- package/out/lsp/domain-lang-workspace-manager.js.map +1 -1
- package/out/lsp/hover/domain-lang-hover.d.ts +45 -1
- package/out/lsp/hover/domain-lang-hover.js +308 -232
- package/out/lsp/hover/domain-lang-hover.js.map +1 -1
- package/out/lsp/hover/domain-lang-keywords.d.ts +3 -7
- package/out/lsp/hover/domain-lang-keywords.js +115 -38
- package/out/lsp/hover/domain-lang-keywords.js.map +1 -1
- package/out/lsp/manifest-diagnostics.js +95 -50
- package/out/lsp/manifest-diagnostics.js.map +1 -1
- package/out/main.js +204 -17
- package/out/main.js.map +1 -1
- package/out/services/import-resolver.d.ts +39 -2
- package/out/services/import-resolver.js +77 -12
- package/out/services/import-resolver.js.map +1 -1
- package/out/services/types.d.ts +2 -2
- package/out/services/workspace-manager.d.ts +33 -31
- package/out/services/workspace-manager.js +92 -148
- package/out/services/workspace-manager.js.map +1 -1
- package/out/utils/document-utils.d.ts +41 -0
- package/out/utils/document-utils.js +64 -0
- package/out/utils/document-utils.js.map +1 -0
- package/out/utils/import-utils.d.ts +0 -17
- package/out/utils/import-utils.js +2 -32
- package/out/utils/import-utils.js.map +1 -1
- package/out/utils/manifest-utils.d.ts +56 -0
- package/out/utils/manifest-utils.js +119 -0
- package/out/utils/manifest-utils.js.map +1 -0
- package/out/validation/constants.d.ts +13 -0
- package/out/validation/constants.js +18 -0
- package/out/validation/constants.js.map +1 -1
- package/out/validation/import.d.ts +12 -2
- package/out/validation/import.js +95 -22
- package/out/validation/import.js.map +1 -1
- package/out/validation/maps.js +51 -2
- package/out/validation/maps.js.map +1 -1
- package/package.json +1 -1
- package/src/domain-lang-module.ts +6 -1
- package/src/domain-lang.langium +37 -13
- package/src/generated/ast.ts +24 -0
- package/src/generated/grammar.ts +22 -32
- package/src/index.ts +12 -6
- package/src/lsp/domain-lang-code-actions.ts +13 -8
- package/src/lsp/domain-lang-completion.ts +61 -13
- package/src/lsp/domain-lang-formatter.ts +28 -23
- package/src/lsp/domain-lang-index-manager.ts +447 -0
- package/src/lsp/domain-lang-scope-provider.ts +134 -0
- package/src/lsp/domain-lang-scope.ts +29 -17
- package/src/lsp/domain-lang-workspace-manager.ts +201 -53
- package/src/lsp/hover/domain-lang-hover.ts +332 -226
- package/src/lsp/hover/domain-lang-keywords.ts +129 -43
- package/src/lsp/manifest-diagnostics.ts +100 -59
- package/src/main.ts +258 -16
- package/src/services/import-resolver.ts +91 -12
- package/src/services/types.ts +2 -2
- package/src/services/workspace-manager.ts +101 -175
- package/src/utils/document-utils.ts +80 -0
- package/src/utils/import-utils.ts +2 -40
- package/src/utils/manifest-utils.ts +132 -0
- package/src/validation/constants.ts +24 -0
- package/src/validation/import.ts +107 -24
- package/src/validation/maps.ts +59 -2
- package/out/lsp/hover/ddd-pattern-explanations.d.ts +0 -50
- package/out/lsp/hover/ddd-pattern-explanations.js +0 -196
- package/out/lsp/hover/ddd-pattern-explanations.js.map +0 -1
- package/out/services/dependency-analyzer.d.ts +0 -58
- package/out/services/dependency-analyzer.js +0 -254
- package/out/services/dependency-analyzer.js.map +0 -1
- package/out/services/dependency-resolver.d.ts +0 -146
- package/out/services/dependency-resolver.js +0 -452
- package/out/services/dependency-resolver.js.map +0 -1
- package/out/services/git-url-resolver.browser.d.ts +0 -10
- package/out/services/git-url-resolver.browser.js +0 -19
- package/out/services/git-url-resolver.browser.js.map +0 -1
- package/out/services/git-url-resolver.d.ts +0 -158
- package/out/services/git-url-resolver.js +0 -416
- package/out/services/git-url-resolver.js.map +0 -1
- package/out/services/governance-validator.d.ts +0 -44
- package/out/services/governance-validator.js +0 -153
- package/out/services/governance-validator.js.map +0 -1
- package/out/services/semver.d.ts +0 -98
- package/out/services/semver.js +0 -195
- package/out/services/semver.js.map +0 -1
- package/src/lsp/hover/ddd-pattern-explanations.ts +0 -237
- package/src/services/dependency-analyzer.ts +0 -321
- package/src/services/dependency-resolver.ts +0 -551
- package/src/services/git-url-resolver.browser.ts +0 -26
- package/src/services/git-url-resolver.ts +0 -517
- package/src/services/governance-validator.ts +0 -177
- package/src/services/semver.ts +0 -213
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { ModelManifest } from '../services/types.js';
|
|
2
|
+
declare const DEFAULT_MANIFEST_FILENAME = "model.yaml";
|
|
3
|
+
declare const DEFAULT_ENTRY_FILE = "index.dlang";
|
|
4
|
+
/**
|
|
5
|
+
* Checks if a file exists at the given path.
|
|
6
|
+
*/
|
|
7
|
+
export declare function fileExists(targetPath: string): Promise<boolean>;
|
|
8
|
+
/**
|
|
9
|
+
* Finds the nearest model.yaml manifest by walking up from startPath.
|
|
10
|
+
*
|
|
11
|
+
* @param startPath - Directory to start searching from
|
|
12
|
+
* @returns Absolute path to model.yaml, or undefined if not found
|
|
13
|
+
*/
|
|
14
|
+
export declare function findNearestManifest(startPath: string): Promise<string | undefined>;
|
|
15
|
+
/**
|
|
16
|
+
* Finds the workspace root (directory containing model.yaml).
|
|
17
|
+
*
|
|
18
|
+
* @param startPath - Directory to start searching from
|
|
19
|
+
* @returns Absolute path to workspace root, or undefined if no manifest found
|
|
20
|
+
*/
|
|
21
|
+
export declare function findWorkspaceRoot(startPath: string): Promise<string | undefined>;
|
|
22
|
+
/**
|
|
23
|
+
* Reads and parses a model.yaml manifest.
|
|
24
|
+
*
|
|
25
|
+
* @param manifestPath - Absolute path to model.yaml
|
|
26
|
+
* @returns Parsed manifest, or undefined if file doesn't exist
|
|
27
|
+
* @throws Error if file exists but cannot be parsed
|
|
28
|
+
*/
|
|
29
|
+
export declare function readManifest(manifestPath: string): Promise<ModelManifest | undefined>;
|
|
30
|
+
/**
|
|
31
|
+
* Reads the entry point from a manifest file.
|
|
32
|
+
*
|
|
33
|
+
* @param manifestPath - Absolute path to model.yaml
|
|
34
|
+
* @returns Entry file path (relative), defaults to 'index.dlang'
|
|
35
|
+
*/
|
|
36
|
+
export declare function readEntryFromManifest(manifestPath: string): Promise<string>;
|
|
37
|
+
/**
|
|
38
|
+
* Gets the absolute entry file path for a manifest.
|
|
39
|
+
*
|
|
40
|
+
* @param manifestPath - Absolute path to model.yaml
|
|
41
|
+
* @returns Absolute path to the entry file
|
|
42
|
+
*/
|
|
43
|
+
export declare function getEntryPath(manifestPath: string): Promise<string>;
|
|
44
|
+
/**
|
|
45
|
+
* Discovers all manifest files within given directories.
|
|
46
|
+
* Only checks direct children, not recursive subdirectories.
|
|
47
|
+
*
|
|
48
|
+
* @param directories - Array of absolute directory paths to search
|
|
49
|
+
* @returns Array of manifest info objects
|
|
50
|
+
*/
|
|
51
|
+
export declare function findManifestsInDirectories(directories: string[]): Promise<Array<{
|
|
52
|
+
manifestPath: string;
|
|
53
|
+
entryPath: string;
|
|
54
|
+
}>>;
|
|
55
|
+
/** Default manifest filename */
|
|
56
|
+
export { DEFAULT_MANIFEST_FILENAME, DEFAULT_ENTRY_FILE };
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import fs from 'node:fs/promises';
|
|
3
|
+
import YAML from 'yaml';
|
|
4
|
+
const DEFAULT_MANIFEST_FILENAME = 'model.yaml';
|
|
5
|
+
const DEFAULT_ENTRY_FILE = 'index.dlang';
|
|
6
|
+
/**
|
|
7
|
+
* Checks if a file exists at the given path.
|
|
8
|
+
*/
|
|
9
|
+
export async function fileExists(targetPath) {
|
|
10
|
+
try {
|
|
11
|
+
await fs.access(targetPath);
|
|
12
|
+
return true;
|
|
13
|
+
}
|
|
14
|
+
catch (error) {
|
|
15
|
+
if (error?.code === 'ENOENT') {
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
throw error;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Finds the nearest model.yaml manifest by walking up from startPath.
|
|
23
|
+
*
|
|
24
|
+
* @param startPath - Directory to start searching from
|
|
25
|
+
* @returns Absolute path to model.yaml, or undefined if not found
|
|
26
|
+
*/
|
|
27
|
+
export async function findNearestManifest(startPath) {
|
|
28
|
+
let current = path.resolve(startPath);
|
|
29
|
+
const { root } = path.parse(current);
|
|
30
|
+
while (true) {
|
|
31
|
+
const candidate = path.join(current, DEFAULT_MANIFEST_FILENAME);
|
|
32
|
+
if (await fileExists(candidate)) {
|
|
33
|
+
return candidate;
|
|
34
|
+
}
|
|
35
|
+
if (current === root) {
|
|
36
|
+
return undefined;
|
|
37
|
+
}
|
|
38
|
+
const parent = path.dirname(current);
|
|
39
|
+
if (parent === current) {
|
|
40
|
+
return undefined;
|
|
41
|
+
}
|
|
42
|
+
current = parent;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Finds the workspace root (directory containing model.yaml).
|
|
47
|
+
*
|
|
48
|
+
* @param startPath - Directory to start searching from
|
|
49
|
+
* @returns Absolute path to workspace root, or undefined if no manifest found
|
|
50
|
+
*/
|
|
51
|
+
export async function findWorkspaceRoot(startPath) {
|
|
52
|
+
const manifestPath = await findNearestManifest(startPath);
|
|
53
|
+
return manifestPath ? path.dirname(manifestPath) : undefined;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Reads and parses a model.yaml manifest.
|
|
57
|
+
*
|
|
58
|
+
* @param manifestPath - Absolute path to model.yaml
|
|
59
|
+
* @returns Parsed manifest, or undefined if file doesn't exist
|
|
60
|
+
* @throws Error if file exists but cannot be parsed
|
|
61
|
+
*/
|
|
62
|
+
export async function readManifest(manifestPath) {
|
|
63
|
+
try {
|
|
64
|
+
const content = await fs.readFile(manifestPath, 'utf-8');
|
|
65
|
+
return (YAML.parse(content) ?? {});
|
|
66
|
+
}
|
|
67
|
+
catch (error) {
|
|
68
|
+
if (error?.code === 'ENOENT') {
|
|
69
|
+
return undefined;
|
|
70
|
+
}
|
|
71
|
+
throw error;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Reads the entry point from a manifest file.
|
|
76
|
+
*
|
|
77
|
+
* @param manifestPath - Absolute path to model.yaml
|
|
78
|
+
* @returns Entry file path (relative), defaults to 'index.dlang'
|
|
79
|
+
*/
|
|
80
|
+
export async function readEntryFromManifest(manifestPath) {
|
|
81
|
+
try {
|
|
82
|
+
const manifest = await readManifest(manifestPath);
|
|
83
|
+
return manifest?.model?.entry ?? DEFAULT_ENTRY_FILE;
|
|
84
|
+
}
|
|
85
|
+
catch {
|
|
86
|
+
return DEFAULT_ENTRY_FILE;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Gets the absolute entry file path for a manifest.
|
|
91
|
+
*
|
|
92
|
+
* @param manifestPath - Absolute path to model.yaml
|
|
93
|
+
* @returns Absolute path to the entry file
|
|
94
|
+
*/
|
|
95
|
+
export async function getEntryPath(manifestPath) {
|
|
96
|
+
const entry = await readEntryFromManifest(manifestPath);
|
|
97
|
+
return path.resolve(path.dirname(manifestPath), entry);
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Discovers all manifest files within given directories.
|
|
101
|
+
* Only checks direct children, not recursive subdirectories.
|
|
102
|
+
*
|
|
103
|
+
* @param directories - Array of absolute directory paths to search
|
|
104
|
+
* @returns Array of manifest info objects
|
|
105
|
+
*/
|
|
106
|
+
export async function findManifestsInDirectories(directories) {
|
|
107
|
+
const results = [];
|
|
108
|
+
for (const dir of directories) {
|
|
109
|
+
const manifestPath = await findNearestManifest(dir);
|
|
110
|
+
if (manifestPath) {
|
|
111
|
+
const entryPath = await getEntryPath(manifestPath);
|
|
112
|
+
results.push({ manifestPath, entryPath });
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
return results;
|
|
116
|
+
}
|
|
117
|
+
/** Default manifest filename */
|
|
118
|
+
export { DEFAULT_MANIFEST_FILENAME, DEFAULT_ENTRY_FILE };
|
|
119
|
+
//# sourceMappingURL=manifest-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manifest-utils.js","sourceRoot":"","sources":["../../src/utils/manifest-utils.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClC,OAAO,IAAI,MAAM,MAAM,CAAC;AAGxB,MAAM,yBAAyB,GAAG,YAAY,CAAC;AAC/C,MAAM,kBAAkB,GAAG,aAAa,CAAC;AAEzC;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,UAAkB;IAC/C,IAAI,CAAC;QACD,MAAM,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;QAC5B,OAAO,IAAI,CAAC;IAChB,CAAC;IAAC,OAAO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nB,CAAC;AAED,gCAAgC;AAChC,OAAO,EAAE,yBAAyB,EAAE,kBAAkB,EAAE,CAAC"}
|
|
@@ -27,6 +27,7 @@ export declare const IssueCodes: {
|
|
|
27
27
|
readonly ImportMissingRef: "import-missing-ref";
|
|
28
28
|
readonly ImportAbsolutePath: "import-absolute-path";
|
|
29
29
|
readonly ImportEscapesWorkspace: "import-escapes-workspace";
|
|
30
|
+
readonly ImportUnresolved: "import-unresolved";
|
|
30
31
|
readonly DomainNoVision: "domain-no-vision";
|
|
31
32
|
readonly DomainCircularHierarchy: "domain-circular-hierarchy";
|
|
32
33
|
readonly BoundedContextNoDescription: "bounded-context-no-description";
|
|
@@ -40,6 +41,7 @@ export declare const IssueCodes: {
|
|
|
40
41
|
readonly ContextMapNoContexts: "context-map-no-contexts";
|
|
41
42
|
readonly ContextMapNoRelationships: "context-map-no-relationships";
|
|
42
43
|
readonly DomainMapNoDomains: "domain-map-no-domains";
|
|
44
|
+
readonly UnresolvedReference: "unresolved-reference";
|
|
43
45
|
readonly MetadataMissingName: "metadata-missing-name";
|
|
44
46
|
readonly DuplicateElement: "duplicate-element";
|
|
45
47
|
};
|
|
@@ -157,6 +159,11 @@ export declare const ValidationMessages: {
|
|
|
157
159
|
* @param alias - The dependency alias
|
|
158
160
|
*/
|
|
159
161
|
readonly IMPORT_ESCAPES_WORKSPACE: (alias: string) => string;
|
|
162
|
+
/**
|
|
163
|
+
* Error when import path cannot be resolved to a file.
|
|
164
|
+
* @param uri - The import URI that couldn't be resolved
|
|
165
|
+
*/
|
|
166
|
+
readonly IMPORT_UNRESOLVED: (uri: string) => string;
|
|
160
167
|
/**
|
|
161
168
|
* Warning when context map contains no bounded contexts.
|
|
162
169
|
* @param name - The context map name
|
|
@@ -173,6 +180,12 @@ export declare const ValidationMessages: {
|
|
|
173
180
|
* @param name - The domain map name
|
|
174
181
|
*/
|
|
175
182
|
readonly DOMAIN_MAP_NO_DOMAINS: (name: string) => string;
|
|
183
|
+
/**
|
|
184
|
+
* Error when a reference cannot be resolved (for MultiReferences).
|
|
185
|
+
* @param type - The type being referenced (e.g., 'BoundedContext')
|
|
186
|
+
* @param name - The unresolved name
|
|
187
|
+
*/
|
|
188
|
+
readonly UNRESOLVED_REFERENCE: (type: string, name: string) => string;
|
|
176
189
|
/**
|
|
177
190
|
* Error when metadata is missing a name.
|
|
178
191
|
*/
|
|
@@ -30,6 +30,7 @@ export const IssueCodes = {
|
|
|
30
30
|
ImportMissingRef: 'import-missing-ref',
|
|
31
31
|
ImportAbsolutePath: 'import-absolute-path',
|
|
32
32
|
ImportEscapesWorkspace: 'import-escapes-workspace',
|
|
33
|
+
ImportUnresolved: 'import-unresolved',
|
|
33
34
|
// Domain Issues
|
|
34
35
|
DomainNoVision: 'domain-no-vision',
|
|
35
36
|
DomainCircularHierarchy: 'domain-circular-hierarchy',
|
|
@@ -47,6 +48,8 @@ export const IssueCodes = {
|
|
|
47
48
|
ContextMapNoContexts: 'context-map-no-contexts',
|
|
48
49
|
ContextMapNoRelationships: 'context-map-no-relationships',
|
|
49
50
|
DomainMapNoDomains: 'domain-map-no-domains',
|
|
51
|
+
// Reference Issues
|
|
52
|
+
UnresolvedReference: 'unresolved-reference',
|
|
50
53
|
// Metadata Issues
|
|
51
54
|
MetadataMissingName: 'metadata-missing-name',
|
|
52
55
|
// General Issues
|
|
@@ -201,6 +204,12 @@ export const ValidationMessages = {
|
|
|
201
204
|
*/
|
|
202
205
|
IMPORT_ESCAPES_WORKSPACE: (alias) => `Local path dependency '${alias}' escapes workspace boundary.\n` +
|
|
203
206
|
`Hint: Local dependencies must be within the workspace. Consider moving the dependency or using a git-based source.`,
|
|
207
|
+
/**
|
|
208
|
+
* Error when import path cannot be resolved to a file.
|
|
209
|
+
* @param uri - The import URI that couldn't be resolved
|
|
210
|
+
*/
|
|
211
|
+
IMPORT_UNRESOLVED: (uri) => `Cannot resolve import '${uri}'.\n` +
|
|
212
|
+
`Hint: Check that the file exists and the path is correct.`,
|
|
204
213
|
// ========================================================================
|
|
205
214
|
// Context Map & Domain Map Validation
|
|
206
215
|
// ========================================================================
|
|
@@ -224,6 +233,15 @@ export const ValidationMessages = {
|
|
|
224
233
|
DOMAIN_MAP_NO_DOMAINS: (name) => `Domain Map '${name}' contains no domains.\n` +
|
|
225
234
|
`Hint: Use 'contains DomainA, DomainB' to specify which domains are in the map.`,
|
|
226
235
|
// ========================================================================
|
|
236
|
+
// Reference Resolution Validation
|
|
237
|
+
// ========================================================================
|
|
238
|
+
/**
|
|
239
|
+
* Error when a reference cannot be resolved (for MultiReferences).
|
|
240
|
+
* @param type - The type being referenced (e.g., 'BoundedContext')
|
|
241
|
+
* @param name - The unresolved name
|
|
242
|
+
*/
|
|
243
|
+
UNRESOLVED_REFERENCE: (type, name) => `Could not resolve reference to ${type} named '${name}'.`,
|
|
244
|
+
// ========================================================================
|
|
227
245
|
// Metadata Validation
|
|
228
246
|
// ========================================================================
|
|
229
247
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/validation/constants.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAIH,+EAA+E;AAC/E,+BAA+B;AAC/B,+EAA+E;AAE/E;;;;;GAKG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG;IACtB,6BAA6B;IAC7B,gBAAgB,EAAE,oBAAoB;IACtC,sBAAsB,EAAE,0BAA0B;IAClD,mBAAmB,EAAE,wBAAwB;IAC7C,kBAAkB,EAAE,sBAAsB;IAC1C,2BAA2B,EAAE,gCAAgC;IAC7D,yBAAyB,EAAE,+BAA+B;IAC1D,gBAAgB,EAAE,oBAAoB;IACtC,kBAAkB,EAAE,sBAAsB;IAC1C,sBAAsB,EAAE,0BAA0B;
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/validation/constants.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAIH,+EAA+E;AAC/E,+BAA+B;AAC/B,+EAA+E;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import type { ValidationAcceptor, ValidationChecks } from 'langium';
|
|
1
|
+
import type { ValidationAcceptor, ValidationChecks, LangiumDocument } from 'langium';
|
|
2
2
|
import { Cancellation } from 'langium';
|
|
3
3
|
import type { DomainLangAstType, ImportStatement } from '../generated/ast.js';
|
|
4
4
|
import type { DomainLangServices } from '../domain-lang-module.js';
|
|
5
|
-
import type { LangiumDocument } from 'langium';
|
|
6
5
|
/**
|
|
7
6
|
* Validates import statements in DomainLang.
|
|
8
7
|
*
|
|
@@ -10,12 +9,14 @@ import type { LangiumDocument } from 'langium';
|
|
|
10
9
|
* the shared WorkspaceManager service with its cached manifest/lock file reading.
|
|
11
10
|
*
|
|
12
11
|
* Checks:
|
|
12
|
+
* - All import URIs resolve to existing files
|
|
13
13
|
* - External imports require manifest + alias
|
|
14
14
|
* - Local path dependencies stay inside workspace
|
|
15
15
|
* - Lock file exists for external dependencies
|
|
16
16
|
*/
|
|
17
17
|
export declare class ImportValidator {
|
|
18
18
|
private readonly workspaceManager;
|
|
19
|
+
private readonly importResolver;
|
|
19
20
|
constructor(services: DomainLangServices);
|
|
20
21
|
/**
|
|
21
22
|
* Validates an import statement asynchronously.
|
|
@@ -33,6 +34,15 @@ export declare class ImportValidator {
|
|
|
33
34
|
* - External: owner/package (requires manifest dependencies)
|
|
34
35
|
*/
|
|
35
36
|
private isExternalImport;
|
|
37
|
+
/**
|
|
38
|
+
* Validates that an import URI resolves to an existing file.
|
|
39
|
+
* Returns true if there was an error (import doesn't resolve).
|
|
40
|
+
*/
|
|
41
|
+
private validateImportResolves;
|
|
42
|
+
/**
|
|
43
|
+
* Checks if a file exists (async).
|
|
44
|
+
*/
|
|
45
|
+
private fileExists;
|
|
36
46
|
/**
|
|
37
47
|
* Gets the normalized dependency configuration for an alias.
|
|
38
48
|
*/
|
package/out/validation/import.js
CHANGED
|
@@ -8,6 +8,7 @@ import { ValidationMessages, buildCodeDescription, IssueCodes } from './constant
|
|
|
8
8
|
* the shared WorkspaceManager service with its cached manifest/lock file reading.
|
|
9
9
|
*
|
|
10
10
|
* Checks:
|
|
11
|
+
* - All import URIs resolve to existing files
|
|
11
12
|
* - External imports require manifest + alias
|
|
12
13
|
* - Local path dependencies stay inside workspace
|
|
13
14
|
* - Lock file exists for external dependencies
|
|
@@ -15,6 +16,7 @@ import { ValidationMessages, buildCodeDescription, IssueCodes } from './constant
|
|
|
15
16
|
export class ImportValidator {
|
|
16
17
|
constructor(services) {
|
|
17
18
|
this.workspaceManager = services.imports.WorkspaceManager;
|
|
19
|
+
this.importResolver = services.imports.ImportResolver;
|
|
18
20
|
}
|
|
19
21
|
/**
|
|
20
22
|
* Validates an import statement asynchronously.
|
|
@@ -32,6 +34,12 @@ export class ImportValidator {
|
|
|
32
34
|
});
|
|
33
35
|
return;
|
|
34
36
|
}
|
|
37
|
+
// First, verify the import resolves to a valid file
|
|
38
|
+
// This catches renamed/moved/deleted files immediately
|
|
39
|
+
const resolveError = await this.validateImportResolves(imp, document, accept);
|
|
40
|
+
if (resolveError) {
|
|
41
|
+
return; // Don't continue with other validations if can't resolve
|
|
42
|
+
}
|
|
35
43
|
if (!this.isExternalImport(imp.uri)) {
|
|
36
44
|
return;
|
|
37
45
|
}
|
|
@@ -92,6 +100,54 @@ export class ImportValidator {
|
|
|
92
100
|
}
|
|
93
101
|
return true;
|
|
94
102
|
}
|
|
103
|
+
/**
|
|
104
|
+
* Validates that an import URI resolves to an existing file.
|
|
105
|
+
* Returns true if there was an error (import doesn't resolve).
|
|
106
|
+
*/
|
|
107
|
+
async validateImportResolves(imp, document, accept) {
|
|
108
|
+
if (!imp.uri) {
|
|
109
|
+
return true; // Error already reported
|
|
110
|
+
}
|
|
111
|
+
const docDir = path.dirname(document.uri.fsPath);
|
|
112
|
+
try {
|
|
113
|
+
const resolvedUri = await this.importResolver.resolveFrom(docDir, imp.uri);
|
|
114
|
+
// Check if the resolved file actually exists
|
|
115
|
+
const filePath = resolvedUri.fsPath;
|
|
116
|
+
const exists = await this.fileExists(filePath);
|
|
117
|
+
if (!exists) {
|
|
118
|
+
accept('error', ValidationMessages.IMPORT_UNRESOLVED(imp.uri), {
|
|
119
|
+
node: imp,
|
|
120
|
+
property: 'uri',
|
|
121
|
+
codeDescription: buildCodeDescription('language.md', 'imports'),
|
|
122
|
+
data: { code: IssueCodes.ImportUnresolved, uri: imp.uri }
|
|
123
|
+
});
|
|
124
|
+
return true;
|
|
125
|
+
}
|
|
126
|
+
return false;
|
|
127
|
+
}
|
|
128
|
+
catch {
|
|
129
|
+
// Resolution failed - report as unresolved import
|
|
130
|
+
accept('error', ValidationMessages.IMPORT_UNRESOLVED(imp.uri), {
|
|
131
|
+
node: imp,
|
|
132
|
+
property: 'uri',
|
|
133
|
+
codeDescription: buildCodeDescription('language.md', 'imports'),
|
|
134
|
+
data: { code: IssueCodes.ImportUnresolved, uri: imp.uri }
|
|
135
|
+
});
|
|
136
|
+
return true;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Checks if a file exists (async).
|
|
141
|
+
*/
|
|
142
|
+
async fileExists(filePath) {
|
|
143
|
+
try {
|
|
144
|
+
const stat = await fs.stat(filePath);
|
|
145
|
+
return stat.isFile();
|
|
146
|
+
}
|
|
147
|
+
catch {
|
|
148
|
+
return false;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
95
151
|
/**
|
|
96
152
|
* Gets the normalized dependency configuration for an alias.
|
|
97
153
|
*/
|
|
@@ -155,16 +211,23 @@ export class ImportValidator {
|
|
|
155
211
|
});
|
|
156
212
|
return;
|
|
157
213
|
}
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
214
|
+
try {
|
|
215
|
+
const workspaceRoot = this.workspaceManager.getWorkspaceRoot();
|
|
216
|
+
const resolvedPath = path.resolve(workspaceRoot, dependencyPath);
|
|
217
|
+
const relativeToWorkspace = path.relative(workspaceRoot, resolvedPath);
|
|
218
|
+
if (relativeToWorkspace.startsWith('..') || path.isAbsolute(relativeToWorkspace)) {
|
|
219
|
+
accept('error', ValidationMessages.IMPORT_ESCAPES_WORKSPACE(alias), {
|
|
220
|
+
node: imp,
|
|
221
|
+
property: 'uri',
|
|
222
|
+
codeDescription: buildCodeDescription('language.md', 'imports'),
|
|
223
|
+
data: { code: IssueCodes.ImportEscapesWorkspace, alias }
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
catch (error) {
|
|
228
|
+
// WorkspaceManager not initialized - skip workspace boundary check
|
|
229
|
+
// This can happen for standalone files without model.yaml
|
|
230
|
+
console.warn(`Could not validate workspace boundary for path dependency: ${error}`);
|
|
168
231
|
}
|
|
169
232
|
}
|
|
170
233
|
/**
|
|
@@ -183,16 +246,22 @@ export class ImportValidator {
|
|
|
183
246
|
});
|
|
184
247
|
return;
|
|
185
248
|
}
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
249
|
+
try {
|
|
250
|
+
const workspaceRoot = this.workspaceManager.getWorkspaceRoot();
|
|
251
|
+
const cacheDir = this.getCacheDirectory(workspaceRoot, packageKey, lockedDep.commit);
|
|
252
|
+
const cacheExists = await this.directoryExists(cacheDir);
|
|
253
|
+
if (!cacheExists) {
|
|
254
|
+
accept('error', ValidationMessages.IMPORT_NOT_INSTALLED(alias), {
|
|
255
|
+
node: imp,
|
|
256
|
+
property: 'uri',
|
|
257
|
+
codeDescription: buildCodeDescription('language.md', 'imports'),
|
|
258
|
+
data: { code: IssueCodes.ImportNotInstalled, alias }
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
catch (error) {
|
|
263
|
+
// WorkspaceManager not initialized - log warning but continue
|
|
264
|
+
console.warn(`Could not validate cached package for ${alias}: ${error}`);
|
|
196
265
|
}
|
|
197
266
|
}
|
|
198
267
|
/**
|
|
@@ -227,9 +296,13 @@ export function createImportChecks(services) {
|
|
|
227
296
|
return {
|
|
228
297
|
// Langium 4.x supports async validators via MaybePromise<void>
|
|
229
298
|
ImportStatement: async (imp, accept, cancelToken) => {
|
|
230
|
-
|
|
231
|
-
|
|
299
|
+
// Get document from root (Model), not from ImportStatement
|
|
300
|
+
// Langium sets $document only on the root AST node
|
|
301
|
+
const root = imp.$container;
|
|
302
|
+
const document = root?.$document;
|
|
303
|
+
if (!document) {
|
|
232
304
|
return;
|
|
305
|
+
}
|
|
233
306
|
await validator.checkImportPath(imp, accept, document, cancelToken);
|
|
234
307
|
}
|
|
235
308
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"import.js","sourceRoot":"","sources":["../../src/validation/import.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClC,OAAO,IAAI,MAAM,WAAW,CAAC;AAQ7B,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAEtF
|
|
1
|
+
{"version":3,"file":"import.js","sourceRoot":"","sources":["../../src/validation/import.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClC,OAAO,IAAI,MAAM,WAAW,CAAC;AAQ7B,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAEtF;;;;;;;;;;;GAWG;AACH,MAAM,OAAO,eAAe;IAIxB,YAAY,QAA4B;QACpC,IAAI,CAAC,gBAAgB,GAAG,QAAQ,CAAC,OAAO,CAAC,gBAAgB,CAAC;QAC1D,IAAI,CAAC,cAAc,GAAG,QAAQ,CAAC,OAAO,CAAC,cAAc,CAAC;IAC1D,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,eAAe,CACjB,GAAoB,EACpB,MAA0B,EAC1B,QAAyB,EACzB,YA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AC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,WAAW,CAAC,CAAC;QACxE,CAAC;KACJ,CAAC;AACN,CAAC"}
|
package/out/validation/maps.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ValidationMessages, buildCodeDescription } from './constants.js';
|
|
1
|
+
import { ValidationMessages, buildCodeDescription, IssueCodes } from './constants.js';
|
|
2
2
|
/**
|
|
3
3
|
* Validates that a context map contains at least one bounded context.
|
|
4
4
|
* Empty context maps are not useful for documentation purposes.
|
|
@@ -15,6 +15,32 @@ function validateContextMapHasContexts(map, accept) {
|
|
|
15
15
|
});
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
|
+
/**
|
|
19
|
+
* Validates that MultiReference items in a context map resolve.
|
|
20
|
+
* Langium doesn't report errors for unresolved MultiReference items by default,
|
|
21
|
+
* so we need custom validation to catch these cases.
|
|
22
|
+
*
|
|
23
|
+
* @param map - The context map to validate
|
|
24
|
+
* @param accept - The validation acceptor for reporting issues
|
|
25
|
+
*/
|
|
26
|
+
function validateContextMapReferences(map, accept) {
|
|
27
|
+
if (!map.boundedContexts)
|
|
28
|
+
return;
|
|
29
|
+
for (const multiRef of map.boundedContexts) {
|
|
30
|
+
// A MultiReference has a $refText (the source text) and items (resolved refs)
|
|
31
|
+
// If $refText exists but items is empty, the reference didn't resolve
|
|
32
|
+
const refText = multiRef.$refText;
|
|
33
|
+
if (refText && multiRef.items.length === 0) {
|
|
34
|
+
accept('error', ValidationMessages.UNRESOLVED_REFERENCE('BoundedContext', refText), {
|
|
35
|
+
node: map,
|
|
36
|
+
// Find the CST node for this specific reference
|
|
37
|
+
property: 'boundedContexts',
|
|
38
|
+
index: map.boundedContexts.indexOf(multiRef),
|
|
39
|
+
code: IssueCodes.UnresolvedReference
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
18
44
|
/**
|
|
19
45
|
* Validates that a context map has at least one relationship if it contains multiple contexts.
|
|
20
46
|
* Multiple unrelated contexts should have documented relationships.
|
|
@@ -50,11 +76,34 @@ function validateDomainMapHasDomains(map, accept) {
|
|
|
50
76
|
});
|
|
51
77
|
}
|
|
52
78
|
}
|
|
79
|
+
/**
|
|
80
|
+
* Validates that MultiReference items in a domain map resolve.
|
|
81
|
+
*
|
|
82
|
+
* @param map - The domain map to validate
|
|
83
|
+
* @param accept - The validation acceptor for reporting issues
|
|
84
|
+
*/
|
|
85
|
+
function validateDomainMapReferences(map, accept) {
|
|
86
|
+
if (!map.domains)
|
|
87
|
+
return;
|
|
88
|
+
for (const multiRef of map.domains) {
|
|
89
|
+
const refText = multiRef.$refText;
|
|
90
|
+
if (refText && multiRef.items.length === 0) {
|
|
91
|
+
accept('error', ValidationMessages.UNRESOLVED_REFERENCE('Domain', refText), {
|
|
92
|
+
node: map,
|
|
93
|
+
property: 'domains',
|
|
94
|
+
index: map.domains.indexOf(multiRef),
|
|
95
|
+
code: IssueCodes.UnresolvedReference
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
53
100
|
export const contextMapChecks = [
|
|
54
101
|
validateContextMapHasContexts,
|
|
102
|
+
validateContextMapReferences,
|
|
55
103
|
validateContextMapHasRelationships
|
|
56
104
|
];
|
|
57
105
|
export const domainMapChecks = [
|
|
58
|
-
validateDomainMapHasDomains
|
|
106
|
+
validateDomainMapHasDomains,
|
|
107
|
+
validateDomainMapReferences
|
|
59
108
|
];
|
|
60
109
|
//# sourceMappingURL=maps.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"maps.js","sourceRoot":"","sources":["../../src/validation/maps.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"maps.js","sourceRoot":"","sources":["../../src/validation/maps.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,UA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AAE,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC;gBACpC,IAAI,EAAE,UAAU,CAAC,mBAAmB;aACvC,CAAC,CAAC;QACP,CAAC;IACL,CAAC;AACL,CAAC;AAED,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC5B,6BAA6B;IAC7B,4BAA4B;IAC5B,kCAAkC;CACrC,CAAC;AAEF,MAAM,CAAC,MAAM,eAAe,GAAG;IAC3B,2BAA2B;IAC3B,2BAA2B;CAC9B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@domainlang/language",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"displayName": "DomainLang Language",
|
|
5
5
|
"description": "Core language library for DomainLang - parse, validate, and query Domain-Driven Design models programmatically",
|
|
6
6
|
"author": "larsbaunwall",
|