@domainlang/language 0.1.20 → 0.1.82
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/out/domain-lang-module.d.ts +0 -2
- package/out/domain-lang-module.js +3 -11
- package/out/domain-lang-module.js.map +1 -1
- package/out/generated/ast.d.ts +19 -8
- package/out/generated/ast.js +10 -1
- package/out/generated/ast.js.map +1 -1
- package/out/generated/grammar.d.ts +1 -1
- package/out/generated/grammar.js +123 -28
- package/out/generated/grammar.js.map +1 -1
- package/out/generated/module.d.ts +1 -1
- package/out/generated/module.js +1 -1
- package/out/index.d.ts +0 -3
- package/out/index.js +0 -5
- package/out/index.js.map +1 -1
- package/out/lsp/hover/domain-lang-hover.js +4 -0
- package/out/lsp/hover/domain-lang-hover.js.map +1 -1
- package/out/sdk/index.d.ts +1 -1
- package/out/sdk/loader-node.d.ts +3 -7
- package/out/sdk/loader-node.js +9 -24
- package/out/sdk/loader-node.js.map +1 -1
- package/out/sdk/types.d.ts +21 -0
- package/out/services/dependency-analyzer.d.ts +39 -3
- package/out/services/dependency-analyzer.js +47 -22
- package/out/services/dependency-analyzer.js.map +1 -1
- package/out/services/dependency-resolver.d.ts +45 -68
- package/out/services/dependency-resolver.js +43 -243
- package/out/services/dependency-resolver.js.map +1 -1
- package/out/services/git-url-resolver.browser.d.ts +12 -4
- package/out/services/git-url-resolver.browser.js +1 -5
- package/out/services/git-url-resolver.browser.js.map +1 -1
- package/out/services/git-url-resolver.d.ts +56 -22
- package/out/services/git-url-resolver.js +36 -70
- package/out/services/git-url-resolver.js.map +1 -1
- package/out/services/governance-validator.d.ts +37 -1
- package/out/services/governance-validator.js +10 -4
- package/out/services/governance-validator.js.map +1 -1
- package/out/services/import-resolver.d.ts +6 -65
- package/out/services/import-resolver.js +5 -223
- package/out/services/import-resolver.js.map +1 -1
- package/out/services/performance-optimizer.d.ts +1 -1
- package/out/services/workspace-manager.d.ts +10 -57
- package/out/services/workspace-manager.js +21 -187
- package/out/services/workspace-manager.js.map +1 -1
- package/out/syntaxes/domain-lang.monarch.js +1 -1
- package/out/syntaxes/domain-lang.monarch.js.map +1 -1
- package/out/utils/import-utils.d.ts +12 -4
- package/out/utils/import-utils.js +135 -35
- package/out/utils/import-utils.js.map +1 -1
- package/out/validation/constants.d.ts +0 -103
- package/out/validation/constants.js +1 -140
- package/out/validation/constants.js.map +1 -1
- package/out/validation/domain.js +1 -46
- package/out/validation/domain.js.map +1 -1
- package/out/validation/import.d.ts +22 -46
- package/out/validation/import.js +85 -187
- package/out/validation/import.js.map +1 -1
- package/out/validation/maps.js +6 -10
- package/out/validation/maps.js.map +1 -1
- package/out/validation/metadata.js +1 -5
- package/out/validation/metadata.js.map +1 -1
- package/package.json +6 -8
- package/src/domain-lang-module.ts +6 -18
- package/src/domain-lang.langium +12 -7
- package/src/generated/ast.ts +20 -7
- package/src/generated/grammar.ts +123 -28
- package/src/generated/module.ts +1 -1
- package/src/index.ts +0 -7
- package/src/lsp/hover/domain-lang-hover.ts +2 -0
- package/src/sdk/index.ts +2 -0
- package/src/sdk/loader-node.ts +9 -29
- package/src/sdk/types.ts +23 -0
- package/src/services/dependency-analyzer.ts +84 -24
- package/src/services/dependency-resolver.ts +84 -301
- package/src/services/git-url-resolver.browser.ts +14 -9
- package/src/services/git-url-resolver.ts +93 -86
- package/src/services/governance-validator.ts +47 -5
- package/src/services/import-resolver.ts +8 -270
- package/src/services/performance-optimizer.ts +1 -1
- package/src/services/workspace-manager.ts +46 -237
- package/src/syntaxes/domain-lang.monarch.ts +1 -1
- package/src/utils/import-utils.ts +160 -38
- package/src/validation/constants.ts +1 -181
- package/src/validation/domain.ts +1 -54
- package/src/validation/import.ts +104 -228
- package/src/validation/maps.ts +6 -10
- package/src/validation/metadata.ts +1 -5
- package/out/lsp/domain-lang-code-actions.d.ts +0 -55
- package/out/lsp/domain-lang-code-actions.js +0 -143
- package/out/lsp/domain-lang-code-actions.js.map +0 -1
- package/out/lsp/domain-lang-workspace-manager.d.ts +0 -21
- package/out/lsp/domain-lang-workspace-manager.js +0 -93
- package/out/lsp/domain-lang-workspace-manager.js.map +0 -1
- package/out/lsp/manifest-diagnostics.d.ts +0 -82
- package/out/lsp/manifest-diagnostics.js +0 -230
- package/out/lsp/manifest-diagnostics.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/out/services/types.d.ts +0 -340
- package/out/services/types.js +0 -46
- package/out/services/types.js.map +0 -1
- package/out/validation/manifest.d.ts +0 -144
- package/out/validation/manifest.js +0 -327
- package/out/validation/manifest.js.map +0 -1
- package/src/lsp/domain-lang-code-actions.ts +0 -189
- package/src/lsp/domain-lang-workspace-manager.ts +0 -104
- package/src/lsp/manifest-diagnostics.ts +0 -290
- package/src/services/semver.ts +0 -213
- package/src/services/types.ts +0 -415
- package/src/validation/manifest.ts +0 -439
|
@@ -1,439 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Manifest Validation for DomainLang.
|
|
3
|
-
*
|
|
4
|
-
* Provides schema validation and issue detection for model.yaml files.
|
|
5
|
-
* This validation is triggered by the workspace manager when manifests are loaded.
|
|
6
|
-
*
|
|
7
|
-
* Validation includes:
|
|
8
|
-
* - Required fields for publishable packages
|
|
9
|
-
* - Dependency configuration correctness
|
|
10
|
-
* - Path alias validation
|
|
11
|
-
* - Version format validation
|
|
12
|
-
*
|
|
13
|
-
* @module
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
import type { ModelManifest, DependencySpec, ExtendedDependencySpec } from '../services/types.js';
|
|
17
|
-
import { IssueCodes } from './constants.js';
|
|
18
|
-
|
|
19
|
-
// ============================================================================
|
|
20
|
-
// Manifest Validation Types
|
|
21
|
-
// ============================================================================
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Severity levels for manifest diagnostics.
|
|
25
|
-
*/
|
|
26
|
-
export type ManifestSeverity = 'error' | 'warning' | 'info';
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* A diagnostic issue found in model.yaml.
|
|
30
|
-
*/
|
|
31
|
-
export interface ManifestDiagnostic {
|
|
32
|
-
/** Issue code for code action mapping */
|
|
33
|
-
readonly code: string;
|
|
34
|
-
/** Error severity */
|
|
35
|
-
readonly severity: ManifestSeverity;
|
|
36
|
-
/** Human-readable message */
|
|
37
|
-
readonly message: string;
|
|
38
|
-
/** YAML path to the issue (e.g., "dependencies.core.version") */
|
|
39
|
-
readonly path: string;
|
|
40
|
-
/** Optional hint for resolution */
|
|
41
|
-
readonly hint?: string;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Result of manifest validation.
|
|
46
|
-
*/
|
|
47
|
-
export interface ManifestValidationResult {
|
|
48
|
-
/** Whether the manifest is valid (no errors) */
|
|
49
|
-
readonly valid: boolean;
|
|
50
|
-
/** All diagnostics found */
|
|
51
|
-
readonly diagnostics: ManifestDiagnostic[];
|
|
52
|
-
/** Count of errors only */
|
|
53
|
-
readonly errorCount: number;
|
|
54
|
-
/** Count of warnings only */
|
|
55
|
-
readonly warningCount: number;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
// ============================================================================
|
|
59
|
-
// Issue Code Mapping for Manifest Validation
|
|
60
|
-
// ============================================================================
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* Issue codes specific to manifest validation.
|
|
64
|
-
* These extend the general IssueCodes for manifest-specific issues.
|
|
65
|
-
*/
|
|
66
|
-
export const ManifestIssueCodes = {
|
|
67
|
-
// Model section issues
|
|
68
|
-
ModelMissingName: 'manifest-model-missing-name',
|
|
69
|
-
ModelMissingVersion: 'manifest-model-missing-version',
|
|
70
|
-
ModelInvalidVersion: 'manifest-model-invalid-version',
|
|
71
|
-
|
|
72
|
-
// Dependency section issues
|
|
73
|
-
DependencyMissingRef: 'manifest-dependency-missing-ref',
|
|
74
|
-
DependencyInvalidRef: 'manifest-dependency-invalid-ref',
|
|
75
|
-
DependencyConflictingSourcePath: 'manifest-dependency-conflicting-source-path',
|
|
76
|
-
DependencyMissingSourceOrPath: 'manifest-dependency-missing-source-or-path',
|
|
77
|
-
DependencyInvalidSource: 'manifest-dependency-invalid-source',
|
|
78
|
-
DependencyAbsolutePath: 'manifest-dependency-absolute-path',
|
|
79
|
-
|
|
80
|
-
// Path alias issues
|
|
81
|
-
PathAliasMissingAtPrefix: 'manifest-path-alias-missing-at-prefix',
|
|
82
|
-
PathAliasAbsolutePath: 'manifest-path-alias-absolute-path'
|
|
83
|
-
} as const;
|
|
84
|
-
|
|
85
|
-
type ManifestIssueCode = typeof ManifestIssueCodes[keyof typeof ManifestIssueCodes] | typeof IssueCodes[keyof typeof IssueCodes];
|
|
86
|
-
|
|
87
|
-
// ============================================================================
|
|
88
|
-
// Manifest Validator
|
|
89
|
-
// ============================================================================
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* Validates model.yaml manifests and reports issues.
|
|
93
|
-
*
|
|
94
|
-
* Usage:
|
|
95
|
-
* ```typescript
|
|
96
|
-
* const validator = new ManifestValidator();
|
|
97
|
-
* const result = validator.validate(manifest);
|
|
98
|
-
* if (!result.valid) {
|
|
99
|
-
* console.log(result.diagnostics);
|
|
100
|
-
* }
|
|
101
|
-
* ```
|
|
102
|
-
*/
|
|
103
|
-
export class ManifestValidator {
|
|
104
|
-
|
|
105
|
-
/**
|
|
106
|
-
* Validates a parsed model.yaml manifest.
|
|
107
|
-
*
|
|
108
|
-
* @param manifest - The parsed manifest object
|
|
109
|
-
* @param options - Optional validation options
|
|
110
|
-
* @returns Validation result with diagnostics
|
|
111
|
-
*/
|
|
112
|
-
validate(
|
|
113
|
-
manifest: ModelManifest,
|
|
114
|
-
options: { requirePublishable?: boolean } = {}
|
|
115
|
-
): ManifestValidationResult {
|
|
116
|
-
const diagnostics: ManifestDiagnostic[] = [];
|
|
117
|
-
|
|
118
|
-
// Validate model section
|
|
119
|
-
this.validateModelSection(manifest, diagnostics, options.requirePublishable ?? false);
|
|
120
|
-
|
|
121
|
-
// Validate dependencies section
|
|
122
|
-
this.validateDependenciesSection(manifest, diagnostics);
|
|
123
|
-
|
|
124
|
-
// Validate paths section
|
|
125
|
-
this.validatePathsSection(manifest, diagnostics);
|
|
126
|
-
|
|
127
|
-
// Calculate counts
|
|
128
|
-
const errorCount = diagnostics.filter(d => d.severity === 'error').length;
|
|
129
|
-
const warningCount = diagnostics.filter(d => d.severity === 'warning').length;
|
|
130
|
-
|
|
131
|
-
return {
|
|
132
|
-
valid: errorCount === 0,
|
|
133
|
-
diagnostics,
|
|
134
|
-
errorCount,
|
|
135
|
-
warningCount
|
|
136
|
-
};
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
/**
|
|
140
|
-
* Validates the model section of the manifest.
|
|
141
|
-
*/
|
|
142
|
-
private validateModelSection(
|
|
143
|
-
manifest: ModelManifest,
|
|
144
|
-
diagnostics: ManifestDiagnostic[],
|
|
145
|
-
requirePublishable: boolean
|
|
146
|
-
): void {
|
|
147
|
-
const model = manifest.model;
|
|
148
|
-
|
|
149
|
-
// If no model section and not requiring publishable, that's OK
|
|
150
|
-
if (!model && !requirePublishable) {
|
|
151
|
-
return;
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
// If requiring publishable package, name and version are required
|
|
155
|
-
if (requirePublishable) {
|
|
156
|
-
if (!model?.name) {
|
|
157
|
-
diagnostics.push({
|
|
158
|
-
code: ManifestIssueCodes.ModelMissingName as ManifestIssueCode,
|
|
159
|
-
severity: 'error',
|
|
160
|
-
message: 'Publishable packages require a model.name field.',
|
|
161
|
-
path: 'model.name',
|
|
162
|
-
hint: 'Add "name: my-package" under the model section.'
|
|
163
|
-
});
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
if (!model?.version) {
|
|
167
|
-
diagnostics.push({
|
|
168
|
-
code: ManifestIssueCodes.ModelMissingVersion as ManifestIssueCode,
|
|
169
|
-
severity: 'error',
|
|
170
|
-
message: 'Publishable packages require a model.version field.',
|
|
171
|
-
path: 'model.version',
|
|
172
|
-
hint: 'Add "version: 1.0.0" under the model section.'
|
|
173
|
-
});
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
// Validate version format if present
|
|
178
|
-
if (model?.version && !this.isValidSemVer(model.version)) {
|
|
179
|
-
diagnostics.push({
|
|
180
|
-
code: ManifestIssueCodes.ModelInvalidVersion as ManifestIssueCode,
|
|
181
|
-
severity: 'warning',
|
|
182
|
-
message: `Version '${model.version}' is not valid SemVer format.`,
|
|
183
|
-
path: 'model.version',
|
|
184
|
-
hint: 'Use SemVer format like "1.0.0" or "1.2.3-beta".'
|
|
185
|
-
});
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
/**
|
|
190
|
-
* Validates the dependencies section of the manifest.
|
|
191
|
-
*/
|
|
192
|
-
private validateDependenciesSection(
|
|
193
|
-
manifest: ModelManifest,
|
|
194
|
-
diagnostics: ManifestDiagnostic[]
|
|
195
|
-
): void {
|
|
196
|
-
const dependencies = manifest.dependencies;
|
|
197
|
-
if (!dependencies) {
|
|
198
|
-
return;
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
for (const [key, dep] of Object.entries(dependencies)) {
|
|
202
|
-
this.validateDependency(key, dep, diagnostics);
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
/**
|
|
207
|
-
* Validates a single dependency entry.
|
|
208
|
-
*/
|
|
209
|
-
private validateDependency(
|
|
210
|
-
key: string,
|
|
211
|
-
dep: DependencySpec,
|
|
212
|
-
diagnostics: ManifestDiagnostic[]
|
|
213
|
-
): void {
|
|
214
|
-
const normalized = this.normalizeDependency(key, dep);
|
|
215
|
-
const basePath = `dependencies.${key}`;
|
|
216
|
-
|
|
217
|
-
// Check for conflicting source and path
|
|
218
|
-
if (normalized.source && normalized.path) {
|
|
219
|
-
diagnostics.push({
|
|
220
|
-
code: IssueCodes.ImportConflictingSourcePath,
|
|
221
|
-
severity: 'error',
|
|
222
|
-
message: `Dependency '${key}' cannot have both 'source' and 'path'.`,
|
|
223
|
-
path: basePath,
|
|
224
|
-
hint: `Use 'source' for git packages or 'path' for local workspace packages.`
|
|
225
|
-
});
|
|
226
|
-
return; // Don't validate further if this fundamental issue exists
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
// Check that at least one of source or path is present
|
|
230
|
-
if (!normalized.source && !normalized.path) {
|
|
231
|
-
diagnostics.push({
|
|
232
|
-
code: IssueCodes.ImportMissingSourceOrPath,
|
|
233
|
-
severity: 'error',
|
|
234
|
-
message: `Dependency '${key}' must have either 'source' or 'path'.`,
|
|
235
|
-
path: basePath,
|
|
236
|
-
hint: `Add 'source: owner/repo' for git packages or 'path: ./local' for local packages.`
|
|
237
|
-
});
|
|
238
|
-
return;
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
// Validate source-based dependencies
|
|
242
|
-
if (normalized.source) {
|
|
243
|
-
this.validateSourceDependency(key, normalized, basePath, diagnostics);
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
// Validate path-based dependencies
|
|
247
|
-
if (normalized.path) {
|
|
248
|
-
this.validatePathDependency(key, normalized, basePath, diagnostics);
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
/**
|
|
253
|
-
* Validates a git-source based dependency.
|
|
254
|
-
*/
|
|
255
|
-
private validateSourceDependency(
|
|
256
|
-
key: string,
|
|
257
|
-
dep: ExtendedDependencySpec,
|
|
258
|
-
basePath: string,
|
|
259
|
-
diagnostics: ManifestDiagnostic[]
|
|
260
|
-
): void {
|
|
261
|
-
// Source dependencies require a ref (tag, branch, or commit)
|
|
262
|
-
if (!dep.ref) {
|
|
263
|
-
diagnostics.push({
|
|
264
|
-
code: IssueCodes.ImportMissingRef,
|
|
265
|
-
severity: 'error',
|
|
266
|
-
message: `Git dependency '${key}' requires a ref.`,
|
|
267
|
-
path: `${basePath}.ref`,
|
|
268
|
-
hint: `Add a git ref: 'ref: v1.0.0' (tag), 'ref: main' (branch), or a commit SHA.`
|
|
269
|
-
});
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
// Validate ref format
|
|
273
|
-
if (dep.ref && !this.isValidRefSpec(dep.ref)) {
|
|
274
|
-
diagnostics.push({
|
|
275
|
-
code: ManifestIssueCodes.DependencyInvalidRef as ManifestIssueCode,
|
|
276
|
-
severity: 'warning',
|
|
277
|
-
message: `Ref '${dep.ref}' for '${key}' may be invalid.`,
|
|
278
|
-
path: `${basePath}.ref`,
|
|
279
|
-
hint: `Use a tag (v1.0.0), branch name (main), or commit SHA.`
|
|
280
|
-
});
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
// Validate source format (should be owner/repo)
|
|
284
|
-
if (dep.source && !this.isValidSourceFormat(dep.source)) {
|
|
285
|
-
diagnostics.push({
|
|
286
|
-
code: ManifestIssueCodes.DependencyInvalidSource as ManifestIssueCode,
|
|
287
|
-
severity: 'error',
|
|
288
|
-
message: `Source '${dep.source}' is not valid owner/repo format.`,
|
|
289
|
-
path: `${basePath}.source`,
|
|
290
|
-
hint: `Use format 'owner/repo' like 'domainlang/core'.`
|
|
291
|
-
});
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
/**
|
|
296
|
-
* Validates a path-based local dependency.
|
|
297
|
-
*/
|
|
298
|
-
private validatePathDependency(
|
|
299
|
-
key: string,
|
|
300
|
-
dep: ExtendedDependencySpec,
|
|
301
|
-
basePath: string,
|
|
302
|
-
diagnostics: ManifestDiagnostic[]
|
|
303
|
-
): void {
|
|
304
|
-
// Path dependencies should use relative paths
|
|
305
|
-
if (dep.path && this.isAbsolutePath(dep.path)) {
|
|
306
|
-
diagnostics.push({
|
|
307
|
-
code: IssueCodes.ImportAbsolutePath,
|
|
308
|
-
severity: 'error',
|
|
309
|
-
message: `Local path '${dep.path}' for '${key}' must be relative.`,
|
|
310
|
-
path: `${basePath}.path`,
|
|
311
|
-
hint: `Use a relative path like './packages/shared'.`
|
|
312
|
-
});
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
/**
|
|
317
|
-
* Validates the paths section of the manifest.
|
|
318
|
-
*/
|
|
319
|
-
private validatePathsSection(
|
|
320
|
-
manifest: ModelManifest,
|
|
321
|
-
diagnostics: ManifestDiagnostic[]
|
|
322
|
-
): void {
|
|
323
|
-
const paths = manifest.paths;
|
|
324
|
-
if (!paths) {
|
|
325
|
-
return;
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
for (const [alias, targetPath] of Object.entries(paths)) {
|
|
329
|
-
// Path aliases should start with @
|
|
330
|
-
if (!alias.startsWith('@')) {
|
|
331
|
-
diagnostics.push({
|
|
332
|
-
code: ManifestIssueCodes.PathAliasMissingAtPrefix as ManifestIssueCode,
|
|
333
|
-
severity: 'warning',
|
|
334
|
-
message: `Path alias '${alias}' should start with '@'.`,
|
|
335
|
-
path: `paths.${alias}`,
|
|
336
|
-
hint: `Rename to '@${alias}' for consistency.`
|
|
337
|
-
});
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
// Target paths should be relative
|
|
341
|
-
if (this.isAbsolutePath(targetPath)) {
|
|
342
|
-
diagnostics.push({
|
|
343
|
-
code: ManifestIssueCodes.PathAliasAbsolutePath as ManifestIssueCode,
|
|
344
|
-
severity: 'error',
|
|
345
|
-
message: `Path alias '${alias}' cannot map to absolute path '${targetPath}'.`,
|
|
346
|
-
path: `paths.${alias}`,
|
|
347
|
-
hint: `Use a relative path like './src' or '.'`
|
|
348
|
-
});
|
|
349
|
-
}
|
|
350
|
-
}
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
// ========================================================================
|
|
354
|
-
// Helpers
|
|
355
|
-
// ========================================================================
|
|
356
|
-
|
|
357
|
-
/**
|
|
358
|
-
* Normalizes a dependency to extended form.
|
|
359
|
-
*/
|
|
360
|
-
private normalizeDependency(key: string, dep: DependencySpec): ExtendedDependencySpec {
|
|
361
|
-
if (typeof dep === 'string') {
|
|
362
|
-
return { source: key, ref: dep };
|
|
363
|
-
}
|
|
364
|
-
if (dep.source || dep.path) {
|
|
365
|
-
return dep;
|
|
366
|
-
}
|
|
367
|
-
return { ...dep, source: key };
|
|
368
|
-
}
|
|
369
|
-
|
|
370
|
-
/**
|
|
371
|
-
* Checks if a version string is valid SemVer.
|
|
372
|
-
*/
|
|
373
|
-
private isValidSemVer(version: string): boolean {
|
|
374
|
-
const semverRegex = /^\d+\.\d+\.\d+(-[\w.]+)?(\+[\w.]+)?$/;
|
|
375
|
-
return semverRegex.test(version);
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
/**
|
|
379
|
-
* Checks if a ref spec is valid (tag, branch, or commit SHA).
|
|
380
|
-
*/
|
|
381
|
-
private isValidRefSpec(ref: string): boolean {
|
|
382
|
-
// SemVer with optional v prefix (tags)
|
|
383
|
-
if (/^v?\d+\.\d+\.\d+/.test(ref)) {
|
|
384
|
-
return true;
|
|
385
|
-
}
|
|
386
|
-
// Branch names (simple word chars)
|
|
387
|
-
if (/^[\w][\w.-]*$/.test(ref)) {
|
|
388
|
-
return true;
|
|
389
|
-
}
|
|
390
|
-
// Commit SHAs (40 hex chars)
|
|
391
|
-
if (/^[0-9a-f]{40}$/i.test(ref)) {
|
|
392
|
-
return true;
|
|
393
|
-
}
|
|
394
|
-
// Short commit SHAs (7+ hex chars)
|
|
395
|
-
if (/^[0-9a-f]{7,}$/i.test(ref)) {
|
|
396
|
-
return true;
|
|
397
|
-
}
|
|
398
|
-
return false;
|
|
399
|
-
}
|
|
400
|
-
|
|
401
|
-
/**
|
|
402
|
-
* Checks if source is valid owner/repo format.
|
|
403
|
-
*/
|
|
404
|
-
private isValidSourceFormat(source: string): boolean {
|
|
405
|
-
return /^[a-zA-Z0-9_.-]+\/[a-zA-Z0-9_.-]+$/.test(source);
|
|
406
|
-
}
|
|
407
|
-
|
|
408
|
-
/**
|
|
409
|
-
* Checks if a path is absolute.
|
|
410
|
-
*/
|
|
411
|
-
private isAbsolutePath(p: string): boolean {
|
|
412
|
-
return p.startsWith('/') || /^[A-Za-z]:/.test(p);
|
|
413
|
-
}
|
|
414
|
-
}
|
|
415
|
-
|
|
416
|
-
// ============================================================================
|
|
417
|
-
// Convenience Functions
|
|
418
|
-
// ============================================================================
|
|
419
|
-
|
|
420
|
-
/**
|
|
421
|
-
* Validates a manifest and returns true if valid, false otherwise.
|
|
422
|
-
* Use this for simple pass/fail checks.
|
|
423
|
-
*/
|
|
424
|
-
export function isManifestValid(manifest: ModelManifest): boolean {
|
|
425
|
-
const validator = new ManifestValidator();
|
|
426
|
-
return validator.validate(manifest).valid;
|
|
427
|
-
}
|
|
428
|
-
|
|
429
|
-
/**
|
|
430
|
-
* Validates a manifest and returns all diagnostics.
|
|
431
|
-
* Use this to display validation errors to users.
|
|
432
|
-
*/
|
|
433
|
-
export function validateManifest(
|
|
434
|
-
manifest: ModelManifest,
|
|
435
|
-
options?: { requirePublishable?: boolean }
|
|
436
|
-
): ManifestDiagnostic[] {
|
|
437
|
-
const validator = new ManifestValidator();
|
|
438
|
-
return validator.validate(manifest, options).diagnostics;
|
|
439
|
-
}
|