@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.
- package/README.md +32 -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 +55 -0
- package/out/domain-lang-module.js +59 -0
- package/out/domain-lang-module.js.map +1 -0
- package/out/generated/ast.d.ts +770 -0
- package/out/generated/ast.js +565 -0
- package/out/generated/ast.js.map +1 -0
- package/out/generated/grammar.d.ts +6 -0
- package/out/generated/grammar.js +2502 -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 +13 -0
- package/out/index.js +17 -0
- package/out/index.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/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 +306 -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/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 +47 -0
- package/out/sdk/loader-node.js +104 -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 +301 -0
- package/out/sdk/types.js +8 -0
- package/out/sdk/types.js.map +1 -0
- package/out/services/dependency-analyzer.d.ts +94 -0
- package/out/services/dependency-analyzer.js +279 -0
- package/out/services/dependency-analyzer.js.map +1 -0
- package/out/services/dependency-resolver.d.ts +123 -0
- package/out/services/dependency-resolver.js +252 -0
- package/out/services/dependency-resolver.js.map +1 -0
- package/out/services/git-url-resolver.browser.d.ts +18 -0
- package/out/services/git-url-resolver.browser.js +15 -0
- package/out/services/git-url-resolver.browser.js.map +1 -0
- package/out/services/git-url-resolver.d.ts +192 -0
- package/out/services/git-url-resolver.js +382 -0
- package/out/services/git-url-resolver.js.map +1 -0
- package/out/services/governance-validator.d.ts +80 -0
- package/out/services/governance-validator.js +159 -0
- package/out/services/governance-validator.js.map +1 -0
- package/out/services/import-resolver.d.ts +18 -0
- package/out/services/import-resolver.js +22 -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/workspace-manager.d.ts +76 -0
- package/out/services/workspace-manager.js +323 -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 +57 -0
- package/out/utils/import-utils.js +228 -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 +77 -0
- package/out/validation/constants.js +96 -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 +18 -0
- package/out/validation/domain.js.map +1 -0
- package/out/validation/import.d.ts +44 -0
- package/out/validation/import.js +135 -0
- package/out/validation/import.js.map +1 -0
- package/out/validation/maps.d.ts +21 -0
- package/out/validation/maps.js +56 -0
- package/out/validation/maps.js.map +1 -0
- package/out/validation/metadata.d.ts +7 -0
- package/out/validation/metadata.js +12 -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 +97 -0
- package/src/ast-augmentation.ts +5 -0
- package/src/domain-lang-module.ts +100 -0
- package/src/domain-lang.langium +356 -0
- package/src/generated/ast.ts +999 -0
- package/src/generated/grammar.ts +2504 -0
- package/src/generated/module.ts +25 -0
- package/src/index.ts +17 -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/hover/ddd-pattern-explanations.ts +237 -0
- package/src/lsp/hover/domain-lang-hover.ts +340 -0
- package/src/lsp/hover/domain-lang-keywords.ts +50 -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 +128 -0
- package/src/sdk/indexes.ts +155 -0
- package/src/sdk/loader-node.ts +126 -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 +346 -0
- package/src/services/dependency-analyzer.ts +381 -0
- package/src/services/dependency-resolver.ts +334 -0
- package/src/services/git-url-resolver.browser.ts +31 -0
- package/src/services/git-url-resolver.ts +524 -0
- package/src/services/governance-validator.ts +219 -0
- package/src/services/import-resolver.ts +30 -0
- package/src/services/performance-optimizer.ts +170 -0
- package/src/services/relationship-inference.ts +121 -0
- package/src/services/workspace-manager.ts +416 -0
- package/src/syntaxes/domain-lang.monarch.ts +29 -0
- package/src/utils/import-utils.ts +274 -0
- package/src/validation/bounded-context.ts +99 -0
- package/src/validation/classification.ts +5 -0
- package/src/validation/constants.ts +124 -0
- package/src/validation/domain-lang-validator.ts +33 -0
- package/src/validation/domain.ts +24 -0
- package/src/validation/import.ts +171 -0
- package/src/validation/maps.ts +72 -0
- package/src/validation/metadata.ts +14 -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,416 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import fs from 'node:fs/promises';
|
|
3
|
+
import YAML from 'yaml';
|
|
4
|
+
import { DependencyResolver } from './dependency-resolver.js';
|
|
5
|
+
import { GitUrlResolver } from './git-url-resolver.js';
|
|
6
|
+
import { getGlobalOptimizer } from './performance-optimizer.js';
|
|
7
|
+
import type { LockFile, LockedDependency } from './git-url-resolver.js';
|
|
8
|
+
|
|
9
|
+
const DEFAULT_MANIFEST_FILES = [
|
|
10
|
+
'model.yaml'
|
|
11
|
+
] as const;
|
|
12
|
+
|
|
13
|
+
const DEFAULT_LOCK_FILES = [
|
|
14
|
+
'model.lock'
|
|
15
|
+
] as const;
|
|
16
|
+
|
|
17
|
+
const JSON_SPACE = 2;
|
|
18
|
+
|
|
19
|
+
export interface WorkspaceManagerOptions {
|
|
20
|
+
readonly autoResolve?: boolean;
|
|
21
|
+
readonly manifestFiles?: readonly string[];
|
|
22
|
+
readonly lockFiles?: readonly string[];
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
interface ManifestDependency {
|
|
26
|
+
readonly source?: string;
|
|
27
|
+
readonly version?: string;
|
|
28
|
+
readonly description?: string;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
interface ModelManifest {
|
|
32
|
+
readonly model?: {
|
|
33
|
+
readonly name?: string;
|
|
34
|
+
readonly version?: string;
|
|
35
|
+
readonly entry?: string;
|
|
36
|
+
};
|
|
37
|
+
readonly dependencies?: Record<string, ManifestDependency>;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
interface ManifestCache {
|
|
41
|
+
readonly manifest: ModelManifest;
|
|
42
|
+
readonly path: string;
|
|
43
|
+
readonly mtimeMs: number;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
interface LoadedLockFile {
|
|
47
|
+
readonly lockFile: LockFile;
|
|
48
|
+
readonly filePath: string;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Coordinates workspace discovery, lock file lifecycle management, and git resolver configuration.
|
|
53
|
+
*/
|
|
54
|
+
export class WorkspaceManager {
|
|
55
|
+
private readonly manifestFiles: readonly string[];
|
|
56
|
+
private readonly lockFiles: readonly string[];
|
|
57
|
+
private workspaceRoot: string | undefined;
|
|
58
|
+
private lockFile: LockFile | undefined;
|
|
59
|
+
private gitResolver: GitUrlResolver | undefined;
|
|
60
|
+
private dependencyResolver: DependencyResolver | undefined;
|
|
61
|
+
private initializePromise: Promise<void> | undefined;
|
|
62
|
+
private manifestCache: ManifestCache | undefined;
|
|
63
|
+
|
|
64
|
+
constructor(private readonly options: WorkspaceManagerOptions = {}) {
|
|
65
|
+
this.manifestFiles = options.manifestFiles ?? [...DEFAULT_MANIFEST_FILES];
|
|
66
|
+
this.lockFiles = options.lockFiles ?? [...DEFAULT_LOCK_FILES];
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Finds the workspace root, loads any existing lock file, and prepares the git resolver.
|
|
71
|
+
* Repeated calls await the same initialization work.
|
|
72
|
+
*/
|
|
73
|
+
async initialize(startPath: string): Promise<void> {
|
|
74
|
+
if (!this.initializePromise) {
|
|
75
|
+
this.initializePromise = this.performInitialization(startPath);
|
|
76
|
+
}
|
|
77
|
+
await this.initializePromise;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Returns the absolute path of the workspace root.
|
|
82
|
+
* @throws Error if {@link initialize} has not completed successfully.
|
|
83
|
+
*/
|
|
84
|
+
getWorkspaceRoot(): string {
|
|
85
|
+
if (!this.workspaceRoot) {
|
|
86
|
+
throw new Error('WorkspaceManager not initialized. Call initialize() first.');
|
|
87
|
+
}
|
|
88
|
+
return this.workspaceRoot;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Resolves the manifest file path within the workspace, if present.
|
|
93
|
+
*/
|
|
94
|
+
async getManifestPath(): Promise<string | undefined> {
|
|
95
|
+
await this.ensureInitialized();
|
|
96
|
+
const root = this.workspaceRoot;
|
|
97
|
+
if (!root) {
|
|
98
|
+
return undefined;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
for (const manifest of this.manifestFiles) {
|
|
102
|
+
const candidate = path.join(root, manifest);
|
|
103
|
+
if (await this.fileExists(candidate)) {
|
|
104
|
+
return candidate;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
return undefined;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Returns the cached lock file or triggers resolution when missing.
|
|
113
|
+
*/
|
|
114
|
+
async ensureLockFile(): Promise<LockFile> {
|
|
115
|
+
await this.ensureInitialized();
|
|
116
|
+
|
|
117
|
+
if (!this.lockFile) {
|
|
118
|
+
// Try loading from cache first
|
|
119
|
+
const optimizer = getGlobalOptimizer();
|
|
120
|
+
const cached = await optimizer.getCachedLockFile(this.workspaceRoot || '');
|
|
121
|
+
|
|
122
|
+
if (cached) {
|
|
123
|
+
this.lockFile = cached;
|
|
124
|
+
} else {
|
|
125
|
+
await this.generateLockFile();
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
if (!this.lockFile) {
|
|
130
|
+
throw new Error('Unable to resolve workspace lock file.');
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
return this.lockFile;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Gets the currently cached lock file without refreshing from disk.
|
|
138
|
+
*/
|
|
139
|
+
async getLockFile(): Promise<LockFile | undefined> {
|
|
140
|
+
await this.ensureInitialized();
|
|
141
|
+
return this.lockFile;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Reloads the lock file from disk, updating the git resolver.
|
|
146
|
+
*/
|
|
147
|
+
async refreshLockFile(): Promise<LockFile | undefined> {
|
|
148
|
+
await this.ensureInitialized();
|
|
149
|
+
const loaded = await this.loadLockFileFromDisk();
|
|
150
|
+
this.applyLockFile(loaded);
|
|
151
|
+
return this.lockFile;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Provides the shared git URL resolver configured with the current lock file.
|
|
156
|
+
*/
|
|
157
|
+
async getGitResolver(): Promise<GitUrlResolver> {
|
|
158
|
+
await this.ensureInitialized();
|
|
159
|
+
if (!this.gitResolver) {
|
|
160
|
+
throw new Error('GitUrlResolver not available. Workspace initialization failed.');
|
|
161
|
+
}
|
|
162
|
+
return this.gitResolver;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Forces dependency resolution and regenerates lock files on disk.
|
|
167
|
+
*/
|
|
168
|
+
async regenerateLockFile(): Promise<LockFile> {
|
|
169
|
+
await this.ensureInitialized();
|
|
170
|
+
await this.generateLockFile(true);
|
|
171
|
+
if (!this.lockFile) {
|
|
172
|
+
throw new Error('Failed to regenerate workspace lock file.');
|
|
173
|
+
}
|
|
174
|
+
return this.lockFile;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Resolves a manifest dependency alias to its git import string.
|
|
179
|
+
*
|
|
180
|
+
* @param aliasPath - Alias from import statement (may include subpaths)
|
|
181
|
+
* @returns Resolved git import string or undefined when alias is unknown
|
|
182
|
+
*/
|
|
183
|
+
async resolveDependencyImport(aliasPath: string): Promise<string | undefined> {
|
|
184
|
+
await this.ensureInitialized();
|
|
185
|
+
const manifest = await this.loadManifest();
|
|
186
|
+
const dependencies = manifest?.dependencies;
|
|
187
|
+
|
|
188
|
+
if (!dependencies) {
|
|
189
|
+
return undefined;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
for (const [alias, dep] of Object.entries(dependencies)) {
|
|
193
|
+
if (!dep?.source) {
|
|
194
|
+
continue;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
if (aliasPath === alias || aliasPath.startsWith(`${alias}/`)) {
|
|
198
|
+
const suffix = aliasPath.slice(alias.length);
|
|
199
|
+
const version = dep.version ?? '';
|
|
200
|
+
const versionSegment = version
|
|
201
|
+
? (version.startsWith('@') ? version : `@${version}`)
|
|
202
|
+
: '';
|
|
203
|
+
return `${dep.source}${versionSegment}${suffix}`;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
return undefined;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
private async performInitialization(startPath: string): Promise<void> {
|
|
211
|
+
this.workspaceRoot = await this.findWorkspaceRoot(startPath);
|
|
212
|
+
if (!this.workspaceRoot) {
|
|
213
|
+
throw new Error('Workspace root (directory with model.yaml) not found.');
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
this.gitResolver = new GitUrlResolver();
|
|
217
|
+
const loaded = await this.loadLockFileFromDisk();
|
|
218
|
+
this.applyLockFile(loaded);
|
|
219
|
+
|
|
220
|
+
if (!this.lockFile && this.options.autoResolve !== false) {
|
|
221
|
+
await this.generateLockFile();
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
private async ensureInitialized(): Promise<void> {
|
|
226
|
+
if (this.initializePromise) {
|
|
227
|
+
await this.initializePromise;
|
|
228
|
+
} else if (!this.workspaceRoot) {
|
|
229
|
+
throw new Error('WorkspaceManager not initialized. Call initialize() first.');
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
private applyLockFile(loaded: LoadedLockFile | undefined): void {
|
|
234
|
+
if (!this.gitResolver) {
|
|
235
|
+
return;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
if (loaded) {
|
|
239
|
+
this.lockFile = loaded.lockFile;
|
|
240
|
+
this.gitResolver.setLockFile(this.lockFile);
|
|
241
|
+
} else {
|
|
242
|
+
this.lockFile = undefined;
|
|
243
|
+
this.gitResolver.setLockFile(undefined);
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
private async generateLockFile(force = false): Promise<void> {
|
|
248
|
+
if (!this.workspaceRoot || !this.gitResolver) {
|
|
249
|
+
throw new Error('WorkspaceManager not initialized.');
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
const resolver = this.ensureDependencyResolver();
|
|
253
|
+
if (!force && this.lockFile) {
|
|
254
|
+
return;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
const lockFile = await resolver.resolveDependencies();
|
|
258
|
+
this.lockFile = lockFile;
|
|
259
|
+
this.gitResolver.setLockFile(lockFile);
|
|
260
|
+
|
|
261
|
+
// Write JSON lock file
|
|
262
|
+
await this.writeJsonLockFile(lockFile);
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
private ensureDependencyResolver(): DependencyResolver {
|
|
266
|
+
if (!this.workspaceRoot || !this.gitResolver) {
|
|
267
|
+
throw new Error('WorkspaceManager not initialized.');
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
if (!this.dependencyResolver) {
|
|
271
|
+
this.dependencyResolver = new DependencyResolver(this.workspaceRoot, this.gitResolver);
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
return this.dependencyResolver;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
private async writeJsonLockFile(lockFile: LockFile): Promise<void> {
|
|
278
|
+
if (!this.workspaceRoot) {
|
|
279
|
+
return;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
const jsonPath = path.join(this.workspaceRoot, 'model.lock');
|
|
283
|
+
const payload = {
|
|
284
|
+
version: lockFile.version,
|
|
285
|
+
dependencies: lockFile.dependencies,
|
|
286
|
+
} satisfies LockFile;
|
|
287
|
+
|
|
288
|
+
await fs.writeFile(jsonPath, JSON.stringify(payload, undefined, JSON_SPACE), 'utf-8');
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
private async loadLockFileFromDisk(): Promise<LoadedLockFile | undefined> {
|
|
292
|
+
if (!this.workspaceRoot) {
|
|
293
|
+
return undefined;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
for (const filename of this.lockFiles) {
|
|
297
|
+
const filePath = path.join(this.workspaceRoot, filename);
|
|
298
|
+
const lockFile = await this.tryReadLockFile(filePath, filename);
|
|
299
|
+
if (lockFile) {
|
|
300
|
+
return { lockFile, filePath };
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
return undefined;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
private async tryReadLockFile(filePath: string, _filename: string): Promise<LockFile | undefined> {
|
|
308
|
+
try {
|
|
309
|
+
const content = await fs.readFile(filePath, 'utf-8');
|
|
310
|
+
return this.parseJsonLockFile(content);
|
|
311
|
+
} catch (error) {
|
|
312
|
+
if ((error as NodeJS.ErrnoException)?.code === 'ENOENT') {
|
|
313
|
+
return undefined;
|
|
314
|
+
}
|
|
315
|
+
throw error;
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
private async loadManifest(): Promise<ModelManifest | undefined> {
|
|
320
|
+
const manifestPath = await this.getManifestPath();
|
|
321
|
+
if (!manifestPath) {
|
|
322
|
+
this.manifestCache = undefined;
|
|
323
|
+
return undefined;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
try {
|
|
327
|
+
const stat = await fs.stat(manifestPath);
|
|
328
|
+
if (this.manifestCache &&
|
|
329
|
+
this.manifestCache.path === manifestPath &&
|
|
330
|
+
this.manifestCache.mtimeMs === stat.mtimeMs) {
|
|
331
|
+
return this.manifestCache.manifest;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
const content = await fs.readFile(manifestPath, 'utf-8');
|
|
335
|
+
const manifest = (YAML.parse(content) ?? {}) as ModelManifest;
|
|
336
|
+
this.manifestCache = {
|
|
337
|
+
manifest,
|
|
338
|
+
path: manifestPath,
|
|
339
|
+
mtimeMs: stat.mtimeMs,
|
|
340
|
+
};
|
|
341
|
+
return manifest;
|
|
342
|
+
} catch (error) {
|
|
343
|
+
if ((error as NodeJS.ErrnoException)?.code === 'ENOENT') {
|
|
344
|
+
this.manifestCache = undefined;
|
|
345
|
+
return undefined;
|
|
346
|
+
}
|
|
347
|
+
throw error;
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
private parseJsonLockFile(content: string): LockFile {
|
|
352
|
+
const parsed = JSON.parse(content) as Partial<LockFile> & {
|
|
353
|
+
dependencies?: Record<string, Partial<LockedDependency>>;
|
|
354
|
+
};
|
|
355
|
+
|
|
356
|
+
const version = typeof parsed.version === 'string' ? parsed.version : '1';
|
|
357
|
+
const dependencies: Record<string, LockedDependency> = {};
|
|
358
|
+
|
|
359
|
+
for (const [key, value] of Object.entries(parsed.dependencies ?? {})) {
|
|
360
|
+
if (!value || typeof value.version !== 'string' || typeof value.resolved !== 'string' || typeof value.commit !== 'string') {
|
|
361
|
+
continue;
|
|
362
|
+
}
|
|
363
|
+
dependencies[key] = {
|
|
364
|
+
version: value.version,
|
|
365
|
+
resolved: value.resolved,
|
|
366
|
+
commit: value.commit,
|
|
367
|
+
integrity: value.integrity,
|
|
368
|
+
};
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
return { version, dependencies };
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
private async findWorkspaceRoot(startPath: string): Promise<string | undefined> {
|
|
375
|
+
let current = path.resolve(startPath);
|
|
376
|
+
const { root } = path.parse(current);
|
|
377
|
+
|
|
378
|
+
while (true) {
|
|
379
|
+
if (await this.containsManifest(current)) {
|
|
380
|
+
return current;
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
if (current === root) {
|
|
384
|
+
return undefined;
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
const parent = path.dirname(current);
|
|
388
|
+
if (parent === current) {
|
|
389
|
+
return undefined;
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
current = parent;
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
private async containsManifest(dir: string): Promise<boolean> {
|
|
397
|
+
for (const manifest of this.manifestFiles) {
|
|
398
|
+
if (await this.fileExists(path.join(dir, manifest))) {
|
|
399
|
+
return true;
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
return false;
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
private async fileExists(targetPath: string): Promise<boolean> {
|
|
406
|
+
try {
|
|
407
|
+
await fs.access(targetPath);
|
|
408
|
+
return true;
|
|
409
|
+
} catch (error) {
|
|
410
|
+
if ((error as NodeJS.ErrnoException)?.code === 'ENOENT') {
|
|
411
|
+
return false;
|
|
412
|
+
}
|
|
413
|
+
throw error;
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// Monarch syntax highlighting for the domain-lang language.
|
|
2
|
+
export default {
|
|
3
|
+
keywords: [
|
|
4
|
+
'ACL','AntiCorruptionLayer','BBoM','BigBallOfMud','BoundedContext','CF','Classification','Conformist','ContextMap','CustomerSupplier','Decision','Domain','DomainMap','Import','Metadata','Namespace','OHS','OpenHostService','P','PL','Partnership','Policy','PublishedLanguage','Rule','SK','SeparateWays','SharedKernel','Team','Term','UpstreamDownstream','aka','archetype','as','bc','businessModel','by','classification','cmap','contains','decision','decisions','description','dmap','dom','evolution','examples','for','from','glossary','import','in','integrations','integrity','is','meta','metadata','ns','policy','relationships','rule','rules','synonyms','team','term','terminology','this','type','vision'
|
|
5
|
+
],
|
|
6
|
+
operators: [
|
|
7
|
+
',','->','.',':','<-','<->','=','><'
|
|
8
|
+
],
|
|
9
|
+
symbols: /,|->|\.|:|<-|<->|=|><|\[|\]|\{|\}/,
|
|
10
|
+
|
|
11
|
+
tokenizer: {
|
|
12
|
+
initial: [
|
|
13
|
+
{ regex: /[_a-zA-Z][\w_-]*/, action: { cases: { '@keywords': {"token":"keyword"}, '@default': {"token":"ID"} }} },
|
|
14
|
+
{ regex: /"(\\.|[^"\\])*"|'(\\.|[^'\\])*'/, action: {"token":"string"} },
|
|
15
|
+
{ include: '@whitespace' },
|
|
16
|
+
{ regex: /@symbols/, action: { cases: { '@operators': {"token":"operator"}, '@default': {"token":""} }} },
|
|
17
|
+
],
|
|
18
|
+
whitespace: [
|
|
19
|
+
{ regex: /\s+/, action: {"token":"white"} },
|
|
20
|
+
{ regex: /\/\*/, action: {"token":"comment","next":"@comment"} },
|
|
21
|
+
{ regex: /\/\/[^\n\r]*/, action: {"token":"comment"} },
|
|
22
|
+
],
|
|
23
|
+
comment: [
|
|
24
|
+
{ regex: /[^/\*]+/, action: {"token":"comment"} },
|
|
25
|
+
{ regex: /\*\//, action: {"token":"comment","next":"@pop"} },
|
|
26
|
+
{ regex: /[/\*]/, action: {"token":"comment"} },
|
|
27
|
+
],
|
|
28
|
+
}
|
|
29
|
+
};
|