@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
package/src/services/semver.ts
DELETED
|
@@ -1,213 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Semantic Versioning Utilities
|
|
3
|
-
*
|
|
4
|
-
* Centralized SemVer parsing, comparison, and validation for the dependency system.
|
|
5
|
-
* All version-related logic should use these utilities to ensure consistency.
|
|
6
|
-
*
|
|
7
|
-
* Supported formats:
|
|
8
|
-
* - "1.0.0" or "v1.0.0" (tags)
|
|
9
|
-
* - "1.0.0-alpha.1" (pre-release)
|
|
10
|
-
* - "main", "develop" (branches)
|
|
11
|
-
* - "abc123def" (commit SHAs, 7-40 hex chars)
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
import type { SemVer, RefType, ParsedRef } from './types.js';
|
|
15
|
-
|
|
16
|
-
// ============================================================================
|
|
17
|
-
// Parsing
|
|
18
|
-
// ============================================================================
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Parses a version string into SemVer components.
|
|
22
|
-
* Returns undefined if not a valid SemVer.
|
|
23
|
-
*
|
|
24
|
-
* @example
|
|
25
|
-
* parseSemVer("v1.2.3") // { major: 1, minor: 2, patch: 3, original: "v1.2.3" }
|
|
26
|
-
* parseSemVer("1.0.0-alpha") // { major: 1, minor: 0, patch: 0, prerelease: "alpha", ... }
|
|
27
|
-
* parseSemVer("main") // undefined (not SemVer)
|
|
28
|
-
*/
|
|
29
|
-
export function parseSemVer(version: string): SemVer | undefined {
|
|
30
|
-
// Strip leading 'v' if present
|
|
31
|
-
const normalized = version.startsWith('v') ? version.slice(1) : version;
|
|
32
|
-
|
|
33
|
-
// Match semver pattern: major.minor.patch[-prerelease]
|
|
34
|
-
const match = normalized.match(/^(\d+)\.(\d+)\.(\d+)(?:-(.+))?$/);
|
|
35
|
-
if (!match) return undefined;
|
|
36
|
-
|
|
37
|
-
return {
|
|
38
|
-
major: parseInt(match[1], 10),
|
|
39
|
-
minor: parseInt(match[2], 10),
|
|
40
|
-
patch: parseInt(match[3], 10),
|
|
41
|
-
preRelease: match[4],
|
|
42
|
-
original: version,
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* Detects the type of a git ref based on its format.
|
|
48
|
-
*
|
|
49
|
-
* @example
|
|
50
|
-
* detectRefType("v1.0.0") // 'tag'
|
|
51
|
-
* detectRefType("1.2.3") // 'tag'
|
|
52
|
-
* detectRefType("main") // 'branch'
|
|
53
|
-
* detectRefType("abc123def") // 'commit'
|
|
54
|
-
*/
|
|
55
|
-
export function detectRefType(ref: string): RefType {
|
|
56
|
-
// Commit SHA: 7-40 hex characters
|
|
57
|
-
if (/^[0-9a-f]{7,40}$/i.test(ref)) {
|
|
58
|
-
return 'commit';
|
|
59
|
-
}
|
|
60
|
-
// Tags typically start with 'v' followed by semver
|
|
61
|
-
if (/^v?\d+\.\d+\.\d+/.test(ref)) {
|
|
62
|
-
return 'tag';
|
|
63
|
-
}
|
|
64
|
-
// Everything else is treated as a branch
|
|
65
|
-
return 'branch';
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* Parses a ref string into a structured ParsedRef with type and optional SemVer.
|
|
70
|
-
*/
|
|
71
|
-
export function parseRef(ref: string): ParsedRef {
|
|
72
|
-
const type = detectRefType(ref);
|
|
73
|
-
const semver = type === 'tag' ? parseSemVer(ref) : undefined;
|
|
74
|
-
|
|
75
|
-
return { original: ref, type, semver };
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
// ============================================================================
|
|
79
|
-
// Comparison
|
|
80
|
-
// ============================================================================
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* Compares two SemVer versions.
|
|
84
|
-
* Returns: negative if a < b, positive if a > b, zero if equal.
|
|
85
|
-
*
|
|
86
|
-
* @example
|
|
87
|
-
* compareSemVer(parse("1.0.0"), parse("2.0.0")) // negative (a < b)
|
|
88
|
-
* compareSemVer(parse("1.5.0"), parse("1.2.0")) // positive (a > b)
|
|
89
|
-
* compareSemVer(parse("1.0.0-alpha"), parse("1.0.0")) // negative (prerelease < release)
|
|
90
|
-
*/
|
|
91
|
-
export function compareSemVer(a: SemVer, b: SemVer): number {
|
|
92
|
-
if (a.major !== b.major) return a.major - b.major;
|
|
93
|
-
if (a.minor !== b.minor) return a.minor - b.minor;
|
|
94
|
-
if (a.patch !== b.patch) return a.patch - b.patch;
|
|
95
|
-
|
|
96
|
-
// Pre-release versions are lower than release versions
|
|
97
|
-
if (a.preRelease && !b.preRelease) return -1;
|
|
98
|
-
if (!a.preRelease && b.preRelease) return 1;
|
|
99
|
-
if (a.preRelease && b.preRelease) {
|
|
100
|
-
return a.preRelease.localeCompare(b.preRelease);
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
return 0;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
* Picks the latest from a list of SemVer refs.
|
|
108
|
-
* Returns the ref string (with original 'v' prefix if present).
|
|
109
|
-
*
|
|
110
|
-
* @example
|
|
111
|
-
* pickLatestSemVer(["v1.0.0", "v1.5.0", "v1.2.0"]) // "v1.5.0"
|
|
112
|
-
*/
|
|
113
|
-
export function pickLatestSemVer(refs: string[]): string | undefined {
|
|
114
|
-
const parsed = refs
|
|
115
|
-
.map(ref => ({ ref, semver: parseSemVer(ref) }))
|
|
116
|
-
.filter((item): item is { ref: string; semver: SemVer } => item.semver !== undefined);
|
|
117
|
-
|
|
118
|
-
if (parsed.length === 0) return undefined;
|
|
119
|
-
|
|
120
|
-
parsed.sort((a, b) => compareSemVer(b.semver, a.semver)); // Descending
|
|
121
|
-
return parsed[0].ref;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
/**
|
|
125
|
-
* Sorts version strings in descending order (newest first).
|
|
126
|
-
* Non-SemVer refs are sorted lexicographically at the end.
|
|
127
|
-
*
|
|
128
|
-
* @example
|
|
129
|
-
* sortVersionsDescending(["v1.0.0", "v2.0.0", "v1.5.0"]) // ["v2.0.0", "v1.5.0", "v1.0.0"]
|
|
130
|
-
*/
|
|
131
|
-
export function sortVersionsDescending(versions: string[]): string[] {
|
|
132
|
-
return [...versions].sort((a, b) => {
|
|
133
|
-
const semverA = parseSemVer(a);
|
|
134
|
-
const semverB = parseSemVer(b);
|
|
135
|
-
|
|
136
|
-
// Both are SemVer - compare semantically
|
|
137
|
-
if (semverA && semverB) {
|
|
138
|
-
return compareSemVer(semverB, semverA); // Descending
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
// SemVer comes before non-SemVer
|
|
142
|
-
if (semverA && !semverB) return -1;
|
|
143
|
-
if (!semverA && semverB) return 1;
|
|
144
|
-
|
|
145
|
-
// Both non-SemVer - lexicographic
|
|
146
|
-
return b.localeCompare(a);
|
|
147
|
-
});
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
// ============================================================================
|
|
151
|
-
// Validation
|
|
152
|
-
// ============================================================================
|
|
153
|
-
|
|
154
|
-
/**
|
|
155
|
-
* Checks if a version/ref is a pre-release.
|
|
156
|
-
*
|
|
157
|
-
* Pre-release identifiers: alpha, beta, rc, pre, dev, snapshot
|
|
158
|
-
*
|
|
159
|
-
* @example
|
|
160
|
-
* isPreRelease("v1.0.0") // false
|
|
161
|
-
* isPreRelease("v1.0.0-alpha") // true
|
|
162
|
-
* isPreRelease("v1.0.0-rc.1") // true
|
|
163
|
-
*/
|
|
164
|
-
export function isPreRelease(ref: string): boolean {
|
|
165
|
-
const semver = parseSemVer(ref);
|
|
166
|
-
if (semver?.preRelease) {
|
|
167
|
-
return true;
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
// Also check for common pre-release patterns without proper SemVer
|
|
171
|
-
const clean = ref.replace(/^v/, '');
|
|
172
|
-
return /-(alpha|beta|rc|pre|dev|snapshot)/i.test(clean);
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
/**
|
|
176
|
-
* Checks if two SemVer versions are compatible (same major version).
|
|
177
|
-
*
|
|
178
|
-
* @example
|
|
179
|
-
* areSameMajor(parse("1.0.0"), parse("1.5.0")) // true
|
|
180
|
-
* areSameMajor(parse("1.0.0"), parse("2.0.0")) // false
|
|
181
|
-
*/
|
|
182
|
-
export function areSameMajor(a: SemVer, b: SemVer): boolean {
|
|
183
|
-
return a.major === b.major;
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
/**
|
|
187
|
-
* Gets the major version number from a ref string.
|
|
188
|
-
* Returns undefined if not a valid SemVer.
|
|
189
|
-
*/
|
|
190
|
-
export function getMajorVersion(ref: string): number | undefined {
|
|
191
|
-
return parseSemVer(ref)?.major;
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
// ============================================================================
|
|
195
|
-
// Filtering
|
|
196
|
-
// ============================================================================
|
|
197
|
-
|
|
198
|
-
/**
|
|
199
|
-
* Filters refs to only stable versions (excludes pre-releases).
|
|
200
|
-
*
|
|
201
|
-
* @example
|
|
202
|
-
* filterStableVersions(["v1.0.0", "v1.1.0-alpha", "v1.2.0"]) // ["v1.0.0", "v1.2.0"]
|
|
203
|
-
*/
|
|
204
|
-
export function filterStableVersions(refs: string[]): string[] {
|
|
205
|
-
return refs.filter(ref => !isPreRelease(ref));
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
/**
|
|
209
|
-
* Filters refs to only SemVer tags (excludes branches and commits).
|
|
210
|
-
*/
|
|
211
|
-
export function filterSemVerTags(refs: string[]): string[] {
|
|
212
|
-
return refs.filter(ref => detectRefType(ref) === 'tag' && parseSemVer(ref) !== undefined);
|
|
213
|
-
}
|