@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,98 @@
|
|
|
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
|
+
import type { SemVer, RefType, ParsedRef } from './types.js';
|
|
14
|
+
/**
|
|
15
|
+
* Parses a version string into SemVer components.
|
|
16
|
+
* Returns undefined if not a valid SemVer.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* parseSemVer("v1.2.3") // { major: 1, minor: 2, patch: 3, original: "v1.2.3" }
|
|
20
|
+
* parseSemVer("1.0.0-alpha") // { major: 1, minor: 0, patch: 0, prerelease: "alpha", ... }
|
|
21
|
+
* parseSemVer("main") // undefined (not SemVer)
|
|
22
|
+
*/
|
|
23
|
+
export declare function parseSemVer(version: string): SemVer | undefined;
|
|
24
|
+
/**
|
|
25
|
+
* Detects the type of a git ref based on its format.
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* detectRefType("v1.0.0") // 'tag'
|
|
29
|
+
* detectRefType("1.2.3") // 'tag'
|
|
30
|
+
* detectRefType("main") // 'branch'
|
|
31
|
+
* detectRefType("abc123def") // 'commit'
|
|
32
|
+
*/
|
|
33
|
+
export declare function detectRefType(ref: string): RefType;
|
|
34
|
+
/**
|
|
35
|
+
* Parses a ref string into a structured ParsedRef with type and optional SemVer.
|
|
36
|
+
*/
|
|
37
|
+
export declare function parseRef(ref: string): ParsedRef;
|
|
38
|
+
/**
|
|
39
|
+
* Compares two SemVer versions.
|
|
40
|
+
* Returns: negative if a < b, positive if a > b, zero if equal.
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* compareSemVer(parse("1.0.0"), parse("2.0.0")) // negative (a < b)
|
|
44
|
+
* compareSemVer(parse("1.5.0"), parse("1.2.0")) // positive (a > b)
|
|
45
|
+
* compareSemVer(parse("1.0.0-alpha"), parse("1.0.0")) // negative (prerelease < release)
|
|
46
|
+
*/
|
|
47
|
+
export declare function compareSemVer(a: SemVer, b: SemVer): number;
|
|
48
|
+
/**
|
|
49
|
+
* Picks the latest from a list of SemVer refs.
|
|
50
|
+
* Returns the ref string (with original 'v' prefix if present).
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* pickLatestSemVer(["v1.0.0", "v1.5.0", "v1.2.0"]) // "v1.5.0"
|
|
54
|
+
*/
|
|
55
|
+
export declare function pickLatestSemVer(refs: string[]): string | undefined;
|
|
56
|
+
/**
|
|
57
|
+
* Sorts version strings in descending order (newest first).
|
|
58
|
+
* Non-SemVer refs are sorted lexicographically at the end.
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* sortVersionsDescending(["v1.0.0", "v2.0.0", "v1.5.0"]) // ["v2.0.0", "v1.5.0", "v1.0.0"]
|
|
62
|
+
*/
|
|
63
|
+
export declare function sortVersionsDescending(versions: string[]): string[];
|
|
64
|
+
/**
|
|
65
|
+
* Checks if a version/ref is a pre-release.
|
|
66
|
+
*
|
|
67
|
+
* Pre-release identifiers: alpha, beta, rc, pre, dev, snapshot
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* isPreRelease("v1.0.0") // false
|
|
71
|
+
* isPreRelease("v1.0.0-alpha") // true
|
|
72
|
+
* isPreRelease("v1.0.0-rc.1") // true
|
|
73
|
+
*/
|
|
74
|
+
export declare function isPreRelease(ref: string): boolean;
|
|
75
|
+
/**
|
|
76
|
+
* Checks if two SemVer versions are compatible (same major version).
|
|
77
|
+
*
|
|
78
|
+
* @example
|
|
79
|
+
* areSameMajor(parse("1.0.0"), parse("1.5.0")) // true
|
|
80
|
+
* areSameMajor(parse("1.0.0"), parse("2.0.0")) // false
|
|
81
|
+
*/
|
|
82
|
+
export declare function areSameMajor(a: SemVer, b: SemVer): boolean;
|
|
83
|
+
/**
|
|
84
|
+
* Gets the major version number from a ref string.
|
|
85
|
+
* Returns undefined if not a valid SemVer.
|
|
86
|
+
*/
|
|
87
|
+
export declare function getMajorVersion(ref: string): number | undefined;
|
|
88
|
+
/**
|
|
89
|
+
* Filters refs to only stable versions (excludes pre-releases).
|
|
90
|
+
*
|
|
91
|
+
* @example
|
|
92
|
+
* filterStableVersions(["v1.0.0", "v1.1.0-alpha", "v1.2.0"]) // ["v1.0.0", "v1.2.0"]
|
|
93
|
+
*/
|
|
94
|
+
export declare function filterStableVersions(refs: string[]): string[];
|
|
95
|
+
/**
|
|
96
|
+
* Filters refs to only SemVer tags (excludes branches and commits).
|
|
97
|
+
*/
|
|
98
|
+
export declare function filterSemVerTags(refs: string[]): string[];
|
|
@@ -0,0 +1,195 @@
|
|
|
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
|
+
// Parsing
|
|
15
|
+
// ============================================================================
|
|
16
|
+
/**
|
|
17
|
+
* Parses a version string into SemVer components.
|
|
18
|
+
* Returns undefined if not a valid SemVer.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* parseSemVer("v1.2.3") // { major: 1, minor: 2, patch: 3, original: "v1.2.3" }
|
|
22
|
+
* parseSemVer("1.0.0-alpha") // { major: 1, minor: 0, patch: 0, prerelease: "alpha", ... }
|
|
23
|
+
* parseSemVer("main") // undefined (not SemVer)
|
|
24
|
+
*/
|
|
25
|
+
export function parseSemVer(version) {
|
|
26
|
+
// Strip leading 'v' if present
|
|
27
|
+
const normalized = version.startsWith('v') ? version.slice(1) : version;
|
|
28
|
+
// Match semver pattern: major.minor.patch[-prerelease]
|
|
29
|
+
const match = normalized.match(/^(\d+)\.(\d+)\.(\d+)(?:-(.+))?$/);
|
|
30
|
+
if (!match)
|
|
31
|
+
return undefined;
|
|
32
|
+
return {
|
|
33
|
+
major: parseInt(match[1], 10),
|
|
34
|
+
minor: parseInt(match[2], 10),
|
|
35
|
+
patch: parseInt(match[3], 10),
|
|
36
|
+
preRelease: match[4],
|
|
37
|
+
original: version,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Detects the type of a git ref based on its format.
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* detectRefType("v1.0.0") // 'tag'
|
|
45
|
+
* detectRefType("1.2.3") // 'tag'
|
|
46
|
+
* detectRefType("main") // 'branch'
|
|
47
|
+
* detectRefType("abc123def") // 'commit'
|
|
48
|
+
*/
|
|
49
|
+
export function detectRefType(ref) {
|
|
50
|
+
// Commit SHA: 7-40 hex characters
|
|
51
|
+
if (/^[0-9a-f]{7,40}$/i.test(ref)) {
|
|
52
|
+
return 'commit';
|
|
53
|
+
}
|
|
54
|
+
// Tags typically start with 'v' followed by semver
|
|
55
|
+
if (/^v?\d+\.\d+\.\d+/.test(ref)) {
|
|
56
|
+
return 'tag';
|
|
57
|
+
}
|
|
58
|
+
// Everything else is treated as a branch
|
|
59
|
+
return 'branch';
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Parses a ref string into a structured ParsedRef with type and optional SemVer.
|
|
63
|
+
*/
|
|
64
|
+
export function parseRef(ref) {
|
|
65
|
+
const type = detectRefType(ref);
|
|
66
|
+
const semver = type === 'tag' ? parseSemVer(ref) : undefined;
|
|
67
|
+
return { original: ref, type, semver };
|
|
68
|
+
}
|
|
69
|
+
// ============================================================================
|
|
70
|
+
// Comparison
|
|
71
|
+
// ============================================================================
|
|
72
|
+
/**
|
|
73
|
+
* Compares two SemVer versions.
|
|
74
|
+
* Returns: negative if a < b, positive if a > b, zero if equal.
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* compareSemVer(parse("1.0.0"), parse("2.0.0")) // negative (a < b)
|
|
78
|
+
* compareSemVer(parse("1.5.0"), parse("1.2.0")) // positive (a > b)
|
|
79
|
+
* compareSemVer(parse("1.0.0-alpha"), parse("1.0.0")) // negative (prerelease < release)
|
|
80
|
+
*/
|
|
81
|
+
export function compareSemVer(a, b) {
|
|
82
|
+
if (a.major !== b.major)
|
|
83
|
+
return a.major - b.major;
|
|
84
|
+
if (a.minor !== b.minor)
|
|
85
|
+
return a.minor - b.minor;
|
|
86
|
+
if (a.patch !== b.patch)
|
|
87
|
+
return a.patch - b.patch;
|
|
88
|
+
// Pre-release versions are lower than release versions
|
|
89
|
+
if (a.preRelease && !b.preRelease)
|
|
90
|
+
return -1;
|
|
91
|
+
if (!a.preRelease && b.preRelease)
|
|
92
|
+
return 1;
|
|
93
|
+
if (a.preRelease && b.preRelease) {
|
|
94
|
+
return a.preRelease.localeCompare(b.preRelease);
|
|
95
|
+
}
|
|
96
|
+
return 0;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Picks the latest from a list of SemVer refs.
|
|
100
|
+
* Returns the ref string (with original 'v' prefix if present).
|
|
101
|
+
*
|
|
102
|
+
* @example
|
|
103
|
+
* pickLatestSemVer(["v1.0.0", "v1.5.0", "v1.2.0"]) // "v1.5.0"
|
|
104
|
+
*/
|
|
105
|
+
export function pickLatestSemVer(refs) {
|
|
106
|
+
const parsed = refs
|
|
107
|
+
.map(ref => ({ ref, semver: parseSemVer(ref) }))
|
|
108
|
+
.filter((item) => item.semver !== undefined);
|
|
109
|
+
if (parsed.length === 0)
|
|
110
|
+
return undefined;
|
|
111
|
+
parsed.sort((a, b) => compareSemVer(b.semver, a.semver)); // Descending
|
|
112
|
+
return parsed[0].ref;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Sorts version strings in descending order (newest first).
|
|
116
|
+
* Non-SemVer refs are sorted lexicographically at the end.
|
|
117
|
+
*
|
|
118
|
+
* @example
|
|
119
|
+
* sortVersionsDescending(["v1.0.0", "v2.0.0", "v1.5.0"]) // ["v2.0.0", "v1.5.0", "v1.0.0"]
|
|
120
|
+
*/
|
|
121
|
+
export function sortVersionsDescending(versions) {
|
|
122
|
+
return [...versions].sort((a, b) => {
|
|
123
|
+
const semverA = parseSemVer(a);
|
|
124
|
+
const semverB = parseSemVer(b);
|
|
125
|
+
// Both are SemVer - compare semantically
|
|
126
|
+
if (semverA && semverB) {
|
|
127
|
+
return compareSemVer(semverB, semverA); // Descending
|
|
128
|
+
}
|
|
129
|
+
// SemVer comes before non-SemVer
|
|
130
|
+
if (semverA && !semverB)
|
|
131
|
+
return -1;
|
|
132
|
+
if (!semverA && semverB)
|
|
133
|
+
return 1;
|
|
134
|
+
// Both non-SemVer - lexicographic
|
|
135
|
+
return b.localeCompare(a);
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
// ============================================================================
|
|
139
|
+
// Validation
|
|
140
|
+
// ============================================================================
|
|
141
|
+
/**
|
|
142
|
+
* Checks if a version/ref is a pre-release.
|
|
143
|
+
*
|
|
144
|
+
* Pre-release identifiers: alpha, beta, rc, pre, dev, snapshot
|
|
145
|
+
*
|
|
146
|
+
* @example
|
|
147
|
+
* isPreRelease("v1.0.0") // false
|
|
148
|
+
* isPreRelease("v1.0.0-alpha") // true
|
|
149
|
+
* isPreRelease("v1.0.0-rc.1") // true
|
|
150
|
+
*/
|
|
151
|
+
export function isPreRelease(ref) {
|
|
152
|
+
const semver = parseSemVer(ref);
|
|
153
|
+
if (semver?.preRelease) {
|
|
154
|
+
return true;
|
|
155
|
+
}
|
|
156
|
+
// Also check for common pre-release patterns without proper SemVer
|
|
157
|
+
const clean = ref.replace(/^v/, '');
|
|
158
|
+
return /-(alpha|beta|rc|pre|dev|snapshot)/i.test(clean);
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Checks if two SemVer versions are compatible (same major version).
|
|
162
|
+
*
|
|
163
|
+
* @example
|
|
164
|
+
* areSameMajor(parse("1.0.0"), parse("1.5.0")) // true
|
|
165
|
+
* areSameMajor(parse("1.0.0"), parse("2.0.0")) // false
|
|
166
|
+
*/
|
|
167
|
+
export function areSameMajor(a, b) {
|
|
168
|
+
return a.major === b.major;
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Gets the major version number from a ref string.
|
|
172
|
+
* Returns undefined if not a valid SemVer.
|
|
173
|
+
*/
|
|
174
|
+
export function getMajorVersion(ref) {
|
|
175
|
+
return parseSemVer(ref)?.major;
|
|
176
|
+
}
|
|
177
|
+
// ============================================================================
|
|
178
|
+
// Filtering
|
|
179
|
+
// ============================================================================
|
|
180
|
+
/**
|
|
181
|
+
* Filters refs to only stable versions (excludes pre-releases).
|
|
182
|
+
*
|
|
183
|
+
* @example
|
|
184
|
+
* filterStableVersions(["v1.0.0", "v1.1.0-alpha", "v1.2.0"]) // ["v1.0.0", "v1.2.0"]
|
|
185
|
+
*/
|
|
186
|
+
export function filterStableVersions(refs) {
|
|
187
|
+
return refs.filter(ref => !isPreRelease(ref));
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Filters refs to only SemVer tags (excludes branches and commits).
|
|
191
|
+
*/
|
|
192
|
+
export function filterSemVerTags(refs) {
|
|
193
|
+
return refs.filter(ref => detectRefType(ref) === 'tag' && parseSemVer(ref) !== undefined);
|
|
194
|
+
}
|
|
195
|
+
//# sourceMappingURL=semver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"semver.js","sourceRoot":"","sources":["../../src/services/semver.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAIH,+EAA+E;AAC/E,UAAU;AACV,+EAA+E;AAE/E;;;;;;;;GAQG;AACH,MAAM,UAAU,WAAW,CAAC,OAAe;IACvC,+BAA+B;IAC/B,MAAM,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;IAExE,uDAAuD;IACvD,MAAM,KAAK,GAAG,UAAU,CAAC,KAAK,CAAC,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G,CAAC,EAAE,KAAK,CAAC;AACnC,CAAC;AAED,+EAA+E;AAC/E,YAAY;AACZ,+EAA+E;AAE/E;;;;;GAKG;AACH,MAAM,UAAU,oBAAoB,CAAC,IAAc;IAC/C,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC;AAClD,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,IAAc;IAC3C,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,aAAa,CAAC,GAAG,CAAC,KAAK,KAAK,IAAI,WAAW,CAAC,GAAG,CAAC,KAAK,SAAS,CAAC,CAAC;AAC9F,CAAC"}
|
|
@@ -0,0 +1,340 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Centralized Type Definitions for DomainLang Services
|
|
3
|
+
*
|
|
4
|
+
* Type design principles:
|
|
5
|
+
* - **Atomic**: Each type represents a single, well-defined concept
|
|
6
|
+
* - **Non-overlapping**: Types don't duplicate fields unnecessarily
|
|
7
|
+
* - **Rich**: Types use adjacent types for composition rather than primitives
|
|
8
|
+
* - **Discriminated**: Union types use discriminants for type narrowing
|
|
9
|
+
*
|
|
10
|
+
* Type hierarchy:
|
|
11
|
+
* ```
|
|
12
|
+
* Core Building Blocks
|
|
13
|
+
* ├── RefType (discriminant for git references)
|
|
14
|
+
* └── SemVer (semantic version components)
|
|
15
|
+
*
|
|
16
|
+
* Package Identity
|
|
17
|
+
* └── PackageIdentity (name, version, entry)
|
|
18
|
+
*
|
|
19
|
+
* Dependencies
|
|
20
|
+
* ├── DependencySpec (how deps are specified)
|
|
21
|
+
* │ ├── ShortDependencySpec (string ref only)
|
|
22
|
+
* │ └── ExtendedDependencySpec (full options)
|
|
23
|
+
* └── ResolvedDependency (locked/pinned state)
|
|
24
|
+
*
|
|
25
|
+
* Manifest & Lock
|
|
26
|
+
* ├── ModelManifest (model.yaml schema)
|
|
27
|
+
* └── LockFile (model.lock schema)
|
|
28
|
+
*
|
|
29
|
+
* Resolution Graph
|
|
30
|
+
* ├── DependencyNode (graph node during resolution)
|
|
31
|
+
* └── DependencyGraph (complete resolution graph)
|
|
32
|
+
*
|
|
33
|
+
* Analysis & Governance
|
|
34
|
+
* ├── GovernancePolicy (policy configuration)
|
|
35
|
+
* └── GovernanceViolation (validation result)
|
|
36
|
+
* ```
|
|
37
|
+
*
|
|
38
|
+
* @module services/types
|
|
39
|
+
*/
|
|
40
|
+
/**
|
|
41
|
+
* Type of git reference for version pinning.
|
|
42
|
+
*
|
|
43
|
+
* Used as discriminant in ref-related types:
|
|
44
|
+
* - **tag**: SemVer version tag (v1.0.0, 2.3.4)
|
|
45
|
+
* - **branch**: Branch name (main, develop)
|
|
46
|
+
* - **commit**: Full commit SHA (40 hex chars)
|
|
47
|
+
*/
|
|
48
|
+
export type RefType = 'tag' | 'branch' | 'commit';
|
|
49
|
+
/**
|
|
50
|
+
* Parsed semantic version following SemVer 2.0.0.
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* ```typescript
|
|
54
|
+
* const v: SemVer = {
|
|
55
|
+
* major: 1, minor: 2, patch: 3,
|
|
56
|
+
* preRelease: 'beta.1',
|
|
57
|
+
* original: 'v1.2.3-beta.1'
|
|
58
|
+
* };
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
61
|
+
export interface SemVer {
|
|
62
|
+
readonly major: number;
|
|
63
|
+
readonly minor: number;
|
|
64
|
+
readonly patch: number;
|
|
65
|
+
/** Pre-release identifier (e.g., "alpha", "beta.1", "rc.2") */
|
|
66
|
+
readonly preRelease?: string;
|
|
67
|
+
/** Build metadata - ignored in version comparison */
|
|
68
|
+
readonly buildMetadata?: string;
|
|
69
|
+
/** Original string representation */
|
|
70
|
+
readonly original: string;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Result of parsing a git ref string.
|
|
74
|
+
*/
|
|
75
|
+
export interface ParsedRef {
|
|
76
|
+
readonly type: RefType;
|
|
77
|
+
/** Present only for valid SemVer tags */
|
|
78
|
+
readonly semver?: SemVer;
|
|
79
|
+
readonly original: string;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Core package identity and metadata.
|
|
83
|
+
*
|
|
84
|
+
* Used in model.yaml `model:` section and internally during resolution.
|
|
85
|
+
*/
|
|
86
|
+
export interface PackageIdentity {
|
|
87
|
+
/** Package name in owner/repo format */
|
|
88
|
+
readonly name?: string;
|
|
89
|
+
/** SemVer version string */
|
|
90
|
+
readonly version?: string;
|
|
91
|
+
/** Entry point file (default: index.dlang) */
|
|
92
|
+
readonly entry?: string;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Extended dependency specification with full options.
|
|
96
|
+
*
|
|
97
|
+
* Either `source` OR `path` must be provided (mutually exclusive):
|
|
98
|
+
* - `source`: Remote git coordinates (owner/repo)
|
|
99
|
+
* - `path`: Local filesystem path for monorepo deps
|
|
100
|
+
*/
|
|
101
|
+
export interface ExtendedDependencySpec {
|
|
102
|
+
/** Git coordinates (owner/repo) - mutually exclusive with path */
|
|
103
|
+
readonly source?: string;
|
|
104
|
+
/** Git ref (tag, branch, or commit SHA) */
|
|
105
|
+
readonly ref?: string;
|
|
106
|
+
/** Local path - mutually exclusive with source */
|
|
107
|
+
readonly path?: string;
|
|
108
|
+
/** SHA-256 integrity hash for verification */
|
|
109
|
+
readonly integrity?: string;
|
|
110
|
+
/** Human-readable description */
|
|
111
|
+
readonly description?: string;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Dependency specification in model.yaml.
|
|
115
|
+
*
|
|
116
|
+
* Can be either:
|
|
117
|
+
* - **string**: Short form (just the ref, key is owner/repo)
|
|
118
|
+
* - **ExtendedDependencySpec**: Full form with options
|
|
119
|
+
*
|
|
120
|
+
* @example
|
|
121
|
+
* ```yaml
|
|
122
|
+
* dependencies:
|
|
123
|
+
* acme/core: "v1.0.0" # Short form
|
|
124
|
+
* acme/utils: # Extended form
|
|
125
|
+
* source: acme/utils
|
|
126
|
+
* ref: main
|
|
127
|
+
* integrity: sha256-abc123
|
|
128
|
+
* ```
|
|
129
|
+
*/
|
|
130
|
+
export type DependencySpec = string | ExtendedDependencySpec;
|
|
131
|
+
/**
|
|
132
|
+
* Type guard for extended dependency spec.
|
|
133
|
+
*/
|
|
134
|
+
export declare function isExtendedDependencySpec(dep: DependencySpec): dep is ExtendedDependencySpec;
|
|
135
|
+
/**
|
|
136
|
+
* A fully resolved and locked dependency.
|
|
137
|
+
*
|
|
138
|
+
* Represents a dependency after resolution with all fields pinned
|
|
139
|
+
* to exact values for reproducible builds.
|
|
140
|
+
*/
|
|
141
|
+
export interface LockedDependency {
|
|
142
|
+
/** Original ref from manifest */
|
|
143
|
+
readonly ref: string;
|
|
144
|
+
/** Detected ref type */
|
|
145
|
+
readonly refType: RefType;
|
|
146
|
+
/** Full git URL used for fetching */
|
|
147
|
+
readonly resolved: string;
|
|
148
|
+
/** Exact commit hash (40-char SHA) */
|
|
149
|
+
readonly commit: string;
|
|
150
|
+
/** Optional integrity hash */
|
|
151
|
+
readonly integrity?: string;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Path aliases for @ imports.
|
|
155
|
+
*
|
|
156
|
+
* @example
|
|
157
|
+
* ```yaml
|
|
158
|
+
* paths:
|
|
159
|
+
* "@/": "./src/"
|
|
160
|
+
* "@shared/": "./libs/shared/"
|
|
161
|
+
* ```
|
|
162
|
+
*/
|
|
163
|
+
export type PathAliases = Readonly<Record<string, string>>;
|
|
164
|
+
/**
|
|
165
|
+
* Governance policy configuration.
|
|
166
|
+
*/
|
|
167
|
+
export interface GovernancePolicy {
|
|
168
|
+
/** Allowed git domains (e.g., ['github.com/acme']) */
|
|
169
|
+
readonly allowedSources?: readonly string[];
|
|
170
|
+
/** Blocked packages or patterns */
|
|
171
|
+
readonly blockedPackages?: readonly string[];
|
|
172
|
+
/** Require stable versions only (no pre-release) */
|
|
173
|
+
readonly requireStableVersions?: boolean;
|
|
174
|
+
/** Require team ownership metadata */
|
|
175
|
+
readonly requireTeamOwnership?: boolean;
|
|
176
|
+
/** Allowed licenses */
|
|
177
|
+
readonly allowedLicenses?: readonly string[];
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Package manifest (model.yaml) schema.
|
|
181
|
+
*
|
|
182
|
+
* This is the user-facing YAML file structure.
|
|
183
|
+
*/
|
|
184
|
+
export interface ModelManifest {
|
|
185
|
+
/** Package identity and metadata */
|
|
186
|
+
readonly model?: PackageIdentity;
|
|
187
|
+
/** Path aliases for @ imports */
|
|
188
|
+
readonly paths?: PathAliases;
|
|
189
|
+
/** Dependencies keyed by alias or owner/repo */
|
|
190
|
+
readonly dependencies?: Readonly<Record<string, DependencySpec>>;
|
|
191
|
+
/** Ref overrides for conflict resolution */
|
|
192
|
+
readonly overrides?: Readonly<Record<string, string>>;
|
|
193
|
+
/** Governance policies */
|
|
194
|
+
readonly governance?: GovernancePolicy;
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Lock file schema (model.lock).
|
|
198
|
+
*
|
|
199
|
+
* Pins exact commits for reproducible builds.
|
|
200
|
+
*/
|
|
201
|
+
export interface LockFile {
|
|
202
|
+
/** Lock file format version */
|
|
203
|
+
readonly version: string;
|
|
204
|
+
/** All locked dependencies keyed by package name */
|
|
205
|
+
readonly dependencies: Readonly<Record<string, LockedDependency>>;
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Mutable package metadata during resolution.
|
|
209
|
+
*
|
|
210
|
+
* Unlike PackageIdentity (readonly user-facing), this is mutable
|
|
211
|
+
* because the resolver builds it incrementally during YAML parsing.
|
|
212
|
+
*/
|
|
213
|
+
export interface ResolvingPackage {
|
|
214
|
+
name?: string;
|
|
215
|
+
version?: string;
|
|
216
|
+
entry?: string;
|
|
217
|
+
exports?: Record<string, string>;
|
|
218
|
+
/** Dependencies as name → ref constraint */
|
|
219
|
+
dependencies?: Record<string, string>;
|
|
220
|
+
/** Ref overrides */
|
|
221
|
+
overrides?: Record<string, string>;
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* Node in the dependency graph during resolution.
|
|
225
|
+
*/
|
|
226
|
+
export interface DependencyNode {
|
|
227
|
+
/** Package identifier (owner/repo) */
|
|
228
|
+
readonly packageKey: string;
|
|
229
|
+
/** Primary ref constraint from first encounter */
|
|
230
|
+
refConstraint: string;
|
|
231
|
+
/** All observed constraints from different parents */
|
|
232
|
+
constraints?: Set<string>;
|
|
233
|
+
/** Resolved ref after conflict resolution */
|
|
234
|
+
resolvedRef?: string;
|
|
235
|
+
/** Detected ref type */
|
|
236
|
+
refType?: RefType;
|
|
237
|
+
/** Resolved commit hash */
|
|
238
|
+
commitHash?: string;
|
|
239
|
+
/** Full git repository URL */
|
|
240
|
+
repoUrl?: string;
|
|
241
|
+
/** Direct dependencies of this package */
|
|
242
|
+
dependencies: Record<string, string>;
|
|
243
|
+
/** Parent packages that depend on this one */
|
|
244
|
+
dependents: string[];
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* Complete dependency graph for resolution.
|
|
248
|
+
*/
|
|
249
|
+
export interface DependencyGraph {
|
|
250
|
+
/** All discovered packages */
|
|
251
|
+
readonly nodes: Record<string, DependencyNode>;
|
|
252
|
+
/** Root package name */
|
|
253
|
+
readonly root: string;
|
|
254
|
+
}
|
|
255
|
+
/** Supported git platforms */
|
|
256
|
+
export type GitPlatform = 'github' | 'gitlab' | 'bitbucket' | 'generic';
|
|
257
|
+
/**
|
|
258
|
+
* Parsed git import with repository information.
|
|
259
|
+
*/
|
|
260
|
+
export interface GitImportInfo {
|
|
261
|
+
/** Original import string */
|
|
262
|
+
readonly original: string;
|
|
263
|
+
/** Git platform */
|
|
264
|
+
readonly platform: GitPlatform;
|
|
265
|
+
/** Repository owner/organization */
|
|
266
|
+
readonly owner: string;
|
|
267
|
+
/** Repository name */
|
|
268
|
+
readonly repo: string;
|
|
269
|
+
/** Version (tag, branch, or commit) */
|
|
270
|
+
readonly version: string;
|
|
271
|
+
/** Full git repository URL */
|
|
272
|
+
readonly repoUrl: string;
|
|
273
|
+
/** Package entry point */
|
|
274
|
+
readonly entryPoint: string;
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* Node in a dependency tree visualization.
|
|
278
|
+
*/
|
|
279
|
+
export interface DependencyTreeNode {
|
|
280
|
+
readonly packageKey: string;
|
|
281
|
+
readonly ref: string;
|
|
282
|
+
readonly commit: string;
|
|
283
|
+
readonly dependencies: readonly DependencyTreeNode[];
|
|
284
|
+
/** Depth in tree (0 = root) */
|
|
285
|
+
readonly depth: number;
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* Reverse dependency relationship.
|
|
289
|
+
*/
|
|
290
|
+
export interface ReverseDependency {
|
|
291
|
+
/** Package that depends on the target */
|
|
292
|
+
readonly dependentPackage: string;
|
|
293
|
+
/** Ref of the dependent */
|
|
294
|
+
readonly ref: string;
|
|
295
|
+
/** Relationship type */
|
|
296
|
+
readonly type: 'direct' | 'transitive';
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* Version update policy.
|
|
300
|
+
*/
|
|
301
|
+
export interface VersionPolicy {
|
|
302
|
+
readonly policy: 'latest' | 'stable' | 'pinned';
|
|
303
|
+
readonly ref: string;
|
|
304
|
+
readonly availableRefs?: readonly string[];
|
|
305
|
+
}
|
|
306
|
+
/** Governance violation type discriminant */
|
|
307
|
+
export type GovernanceViolationType = 'blocked-source' | 'unstable-version' | 'missing-metadata' | 'license-violation';
|
|
308
|
+
/** Governance violation severity */
|
|
309
|
+
export type GovernanceViolationSeverity = 'error' | 'warning';
|
|
310
|
+
/**
|
|
311
|
+
* A governance policy violation.
|
|
312
|
+
*/
|
|
313
|
+
export interface GovernanceViolation {
|
|
314
|
+
readonly type: GovernanceViolationType;
|
|
315
|
+
readonly packageKey: string;
|
|
316
|
+
readonly message: string;
|
|
317
|
+
readonly severity: GovernanceViolationSeverity;
|
|
318
|
+
}
|
|
319
|
+
/**
|
|
320
|
+
* Governance metadata for a package (from model.yaml).
|
|
321
|
+
*/
|
|
322
|
+
export interface GovernanceMetadata {
|
|
323
|
+
readonly team?: string;
|
|
324
|
+
readonly contact?: string;
|
|
325
|
+
readonly domain?: string;
|
|
326
|
+
readonly compliance?: readonly string[];
|
|
327
|
+
}
|
|
328
|
+
/**
|
|
329
|
+
* Options for workspace manager initialization.
|
|
330
|
+
*/
|
|
331
|
+
export interface WorkspaceManagerOptions {
|
|
332
|
+
/** Auto-resolve dependencies on initialization */
|
|
333
|
+
readonly autoResolve?: boolean;
|
|
334
|
+
/** Manifest file names to search for */
|
|
335
|
+
readonly manifestFiles?: readonly string[];
|
|
336
|
+
/** Lock file names to search for */
|
|
337
|
+
readonly lockFiles?: readonly string[];
|
|
338
|
+
/** Allow network access for git operations */
|
|
339
|
+
readonly allowNetwork?: boolean;
|
|
340
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Centralized Type Definitions for DomainLang Services
|
|
3
|
+
*
|
|
4
|
+
* Type design principles:
|
|
5
|
+
* - **Atomic**: Each type represents a single, well-defined concept
|
|
6
|
+
* - **Non-overlapping**: Types don't duplicate fields unnecessarily
|
|
7
|
+
* - **Rich**: Types use adjacent types for composition rather than primitives
|
|
8
|
+
* - **Discriminated**: Union types use discriminants for type narrowing
|
|
9
|
+
*
|
|
10
|
+
* Type hierarchy:
|
|
11
|
+
* ```
|
|
12
|
+
* Core Building Blocks
|
|
13
|
+
* ├── RefType (discriminant for git references)
|
|
14
|
+
* └── SemVer (semantic version components)
|
|
15
|
+
*
|
|
16
|
+
* Package Identity
|
|
17
|
+
* └── PackageIdentity (name, version, entry)
|
|
18
|
+
*
|
|
19
|
+
* Dependencies
|
|
20
|
+
* ├── DependencySpec (how deps are specified)
|
|
21
|
+
* │ ├── ShortDependencySpec (string ref only)
|
|
22
|
+
* │ └── ExtendedDependencySpec (full options)
|
|
23
|
+
* └── ResolvedDependency (locked/pinned state)
|
|
24
|
+
*
|
|
25
|
+
* Manifest & Lock
|
|
26
|
+
* ├── ModelManifest (model.yaml schema)
|
|
27
|
+
* └── LockFile (model.lock schema)
|
|
28
|
+
*
|
|
29
|
+
* Resolution Graph
|
|
30
|
+
* ├── DependencyNode (graph node during resolution)
|
|
31
|
+
* └── DependencyGraph (complete resolution graph)
|
|
32
|
+
*
|
|
33
|
+
* Analysis & Governance
|
|
34
|
+
* ├── GovernancePolicy (policy configuration)
|
|
35
|
+
* └── GovernanceViolation (validation result)
|
|
36
|
+
* ```
|
|
37
|
+
*
|
|
38
|
+
* @module services/types
|
|
39
|
+
*/
|
|
40
|
+
/**
|
|
41
|
+
* Type guard for extended dependency spec.
|
|
42
|
+
*/
|
|
43
|
+
export function isExtendedDependencySpec(dep) {
|
|
44
|
+
return typeof dep === 'object' && dep !== null;
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/services/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AA+GH;;GAEG;AACH,MAAM,UAAU,wBAAwB,CAAC,GAAmB;IACxD,OAAO,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,KAAK,IAAI,CAAC;AACnD,CAAC"}
|