@ai-primitives-hub/core 0.0.1-alpha.1
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 +18 -0
- package/dist/domain/bundle/id.d.ts +60 -0
- package/dist/domain/bundle/id.d.ts.map +1 -0
- package/dist/domain/bundle/id.js +75 -0
- package/dist/domain/bundle/id.js.map +1 -0
- package/dist/domain/bundle/identity-matcher.d.ts +48 -0
- package/dist/domain/bundle/identity-matcher.d.ts.map +1 -0
- package/dist/domain/bundle/identity-matcher.js +57 -0
- package/dist/domain/bundle/identity-matcher.js.map +1 -0
- package/dist/domain/bundle/types.d.ts +138 -0
- package/dist/domain/bundle/types.d.ts.map +1 -0
- package/dist/domain/bundle/types.js +17 -0
- package/dist/domain/bundle/types.js.map +1 -0
- package/dist/domain/bundle/version.d.ts +51 -0
- package/dist/domain/bundle/version.d.ts.map +1 -0
- package/dist/domain/bundle/version.js +176 -0
- package/dist/domain/bundle/version.js.map +1 -0
- package/dist/domain/collection/manifest-validator.d.ts +47 -0
- package/dist/domain/collection/manifest-validator.d.ts.map +1 -0
- package/dist/domain/collection/manifest-validator.js +83 -0
- package/dist/domain/collection/manifest-validator.js.map +1 -0
- package/dist/domain/collection/types.d.ts +201 -0
- package/dist/domain/collection/types.d.ts.map +1 -0
- package/dist/domain/collection/types.js +17 -0
- package/dist/domain/collection/types.js.map +1 -0
- package/dist/domain/collection/validate.d.ts +51 -0
- package/dist/domain/collection/validate.d.ts.map +1 -0
- package/dist/domain/collection/validate.js +263 -0
- package/dist/domain/collection/validate.js.map +1 -0
- package/dist/domain/discovery/types.d.ts +95 -0
- package/dist/domain/discovery/types.d.ts.map +1 -0
- package/dist/domain/discovery/types.js +13 -0
- package/dist/domain/discovery/types.js.map +1 -0
- package/dist/domain/errors.d.ts +23 -0
- package/dist/domain/errors.d.ts.map +1 -0
- package/dist/domain/errors.js +41 -0
- package/dist/domain/errors.js.map +1 -0
- package/dist/domain/hub/types.d.ts +254 -0
- package/dist/domain/hub/types.d.ts.map +1 -0
- package/dist/domain/hub/types.js +11 -0
- package/dist/domain/hub/types.js.map +1 -0
- package/dist/domain/hub/validate.d.ts +40 -0
- package/dist/domain/hub/validate.d.ts.map +1 -0
- package/dist/domain/hub/validate.js +89 -0
- package/dist/domain/hub/validate.js.map +1 -0
- package/dist/domain/index.d.ts +31 -0
- package/dist/domain/index.d.ts.map +1 -0
- package/dist/domain/index.js +47 -0
- package/dist/domain/index.js.map +1 -0
- package/dist/domain/install/copilot-file-type.d.ts +84 -0
- package/dist/domain/install/copilot-file-type.d.ts.map +1 -0
- package/dist/domain/install/copilot-file-type.js +190 -0
- package/dist/domain/install/copilot-file-type.js.map +1 -0
- package/dist/domain/install/installable.d.ts +58 -0
- package/dist/domain/install/installable.d.ts.map +1 -0
- package/dist/domain/install/installable.js +36 -0
- package/dist/domain/install/installable.js.map +1 -0
- package/dist/domain/install/layout.d.ts +84 -0
- package/dist/domain/install/layout.d.ts.map +1 -0
- package/dist/domain/install/layout.js +70 -0
- package/dist/domain/install/layout.js.map +1 -0
- package/dist/domain/install/target.d.ts +70 -0
- package/dist/domain/install/target.d.ts.map +1 -0
- package/dist/domain/install/target.js +43 -0
- package/dist/domain/install/target.js.map +1 -0
- package/dist/domain/install/transform.d.ts +47 -0
- package/dist/domain/install/transform.d.ts.map +1 -0
- package/dist/domain/install/transform.js +24 -0
- package/dist/domain/install/transform.js.map +1 -0
- package/dist/domain/install/types.d.ts +51 -0
- package/dist/domain/install/types.d.ts.map +1 -0
- package/dist/domain/install/types.js +3 -0
- package/dist/domain/install/types.js.map +1 -0
- package/dist/domain/primitive/types.d.ts +59 -0
- package/dist/domain/primitive/types.d.ts.map +1 -0
- package/dist/domain/primitive/types.js +22 -0
- package/dist/domain/primitive/types.js.map +1 -0
- package/dist/domain/registry/guards.d.ts +28 -0
- package/dist/domain/registry/guards.d.ts.map +1 -0
- package/dist/domain/registry/guards.js +33 -0
- package/dist/domain/registry/guards.js.map +1 -0
- package/dist/domain/registry/settings.d.ts +49 -0
- package/dist/domain/registry/settings.d.ts.map +1 -0
- package/dist/domain/registry/settings.js +3 -0
- package/dist/domain/registry/settings.js.map +1 -0
- package/dist/domain/registry/types.d.ts +91 -0
- package/dist/domain/registry/types.d.ts.map +1 -0
- package/dist/domain/registry/types.js +3 -0
- package/dist/domain/registry/types.js.map +1 -0
- package/dist/domain/registry-error.d.ts +69 -0
- package/dist/domain/registry-error.d.ts.map +1 -0
- package/dist/domain/registry-error.js +87 -0
- package/dist/domain/registry-error.js.map +1 -0
- package/dist/domain/scaffold/index.d.ts +9 -0
- package/dist/domain/scaffold/index.d.ts.map +1 -0
- package/dist/domain/scaffold/index.js +13 -0
- package/dist/domain/scaffold/index.js.map +1 -0
- package/dist/domain/scaffold/types.d.ts +135 -0
- package/dist/domain/scaffold/types.d.ts.map +1 -0
- package/dist/domain/scaffold/types.js +44 -0
- package/dist/domain/scaffold/types.js.map +1 -0
- package/dist/domain/skill/validate.d.ts +52 -0
- package/dist/domain/skill/validate.d.ts.map +1 -0
- package/dist/domain/skill/validate.js +108 -0
- package/dist/domain/skill/validate.js.map +1 -0
- package/dist/domain/source/types.d.ts +72 -0
- package/dist/domain/source/types.d.ts.map +1 -0
- package/dist/domain/source/types.js +14 -0
- package/dist/domain/source/types.js.map +1 -0
- package/dist/domain/source-id.d.ts +41 -0
- package/dist/domain/source-id.d.ts.map +1 -0
- package/dist/domain/source-id.js +90 -0
- package/dist/domain/source-id.js.map +1 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +74 -0
- package/dist/index.js.map +1 -0
- package/dist/ports/app-storage.d.ts +65 -0
- package/dist/ports/app-storage.d.ts.map +1 -0
- package/dist/ports/app-storage.js +22 -0
- package/dist/ports/app-storage.js.map +1 -0
- package/dist/ports/bundle-downloader.d.ts +28 -0
- package/dist/ports/bundle-downloader.d.ts.map +1 -0
- package/dist/ports/bundle-downloader.js +3 -0
- package/dist/ports/bundle-downloader.js.map +1 -0
- package/dist/ports/bundle-extractor.d.ts +21 -0
- package/dist/ports/bundle-extractor.d.ts.map +1 -0
- package/dist/ports/bundle-extractor.js +8 -0
- package/dist/ports/bundle-extractor.js.map +1 -0
- package/dist/ports/clock.d.ts +29 -0
- package/dist/ports/clock.d.ts.map +1 -0
- package/dist/ports/clock.js +13 -0
- package/dist/ports/clock.js.map +1 -0
- package/dist/ports/copilot-sdk.d.ts +80 -0
- package/dist/ports/copilot-sdk.d.ts.map +1 -0
- package/dist/ports/copilot-sdk.js +16 -0
- package/dist/ports/copilot-sdk.js.map +1 -0
- package/dist/ports/filesystem.d.ts +53 -0
- package/dist/ports/filesystem.d.ts.map +1 -0
- package/dist/ports/filesystem.js +14 -0
- package/dist/ports/filesystem.js.map +1 -0
- package/dist/ports/github-api.d.ts +62 -0
- package/dist/ports/github-api.d.ts.map +1 -0
- package/dist/ports/github-api.js +19 -0
- package/dist/ports/github-api.js.map +1 -0
- package/dist/ports/http.d.ts +58 -0
- package/dist/ports/http.d.ts.map +1 -0
- package/dist/ports/http.js +12 -0
- package/dist/ports/http.js.map +1 -0
- package/dist/ports/index.d.ts +23 -0
- package/dist/ports/index.d.ts.map +1 -0
- package/dist/ports/index.js +39 -0
- package/dist/ports/index.js.map +1 -0
- package/dist/ports/layout-config-loader.d.ts +27 -0
- package/dist/ports/layout-config-loader.d.ts.map +1 -0
- package/dist/ports/layout-config-loader.js +3 -0
- package/dist/ports/layout-config-loader.js.map +1 -0
- package/dist/ports/process-runner.d.ts +31 -0
- package/dist/ports/process-runner.d.ts.map +1 -0
- package/dist/ports/process-runner.js +14 -0
- package/dist/ports/process-runner.js.map +1 -0
- package/dist/ports/registry-operations.d.ts +157 -0
- package/dist/ports/registry-operations.d.ts.map +1 -0
- package/dist/ports/registry-operations.js +3 -0
- package/dist/ports/registry-operations.js.map +1 -0
- package/dist/ports/resource-transformer.d.ts +28 -0
- package/dist/ports/resource-transformer.d.ts.map +1 -0
- package/dist/ports/resource-transformer.js +3 -0
- package/dist/ports/resource-transformer.js.map +1 -0
- package/dist/ports/source-adapter.d.ts +43 -0
- package/dist/ports/source-adapter.d.ts.map +1 -0
- package/dist/ports/source-adapter.js +3 -0
- package/dist/ports/source-adapter.js.map +1 -0
- package/dist/ports/source-resolver.d.ts +19 -0
- package/dist/ports/source-resolver.d.ts.map +1 -0
- package/dist/ports/source-resolver.js +3 -0
- package/dist/ports/source-resolver.js.map +1 -0
- package/dist/ports/target-writer.d.ts +37 -0
- package/dist/ports/target-writer.d.ts.map +1 -0
- package/dist/ports/target-writer.js +3 -0
- package/dist/ports/target-writer.js.map +1 -0
- package/dist/ports/telemetry.d.ts +22 -0
- package/dist/ports/telemetry.d.ts.map +1 -0
- package/dist/ports/telemetry.js +11 -0
- package/dist/ports/telemetry.js.map +1 -0
- package/dist/ports/update-notifier.d.ts +22 -0
- package/dist/ports/update-notifier.d.ts.map +1 -0
- package/dist/ports/update-notifier.js +12 -0
- package/dist/ports/update-notifier.js.map +1 -0
- package/dist/ports/update-store.d.ts +25 -0
- package/dist/ports/update-store.d.ts.map +1 -0
- package/dist/ports/update-store.js +12 -0
- package/dist/ports/update-store.js.map +1 -0
- package/dist/public/schemas/apm.schema.json +59 -0
- package/dist/public/schemas/collection.schema.json +345 -0
- package/dist/public/schemas/default-hubs-config.schema.json +68 -0
- package/dist/public/schemas/hub-config.schema.json +389 -0
- package/dist/public/schemas/lockfile.schema.json +243 -0
- package/package.json +50 -0
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.compareVersions = compareVersions;
|
|
37
|
+
exports.isUpdateAvailable = isUpdateAvailable;
|
|
38
|
+
exports.extractBundleIdentity = extractBundleIdentity;
|
|
39
|
+
exports.isSameBundleIdentity = isSameBundleIdentity;
|
|
40
|
+
/**
|
|
41
|
+
* Domain layer — Bundle version comparison and identity extraction.
|
|
42
|
+
*
|
|
43
|
+
* Ported from the extension's `src/utils/version-manager.ts`
|
|
44
|
+
* (`VersionManager`'s static methods), using the `semver` library for
|
|
45
|
+
* comparison/coercion. That class also called `Logger.getInstance()`
|
|
46
|
+
* for debug/warn diagnostics on its fallback paths (coercion, string-
|
|
47
|
+
* comparison fallback) — untested, non-behavioral side effects that
|
|
48
|
+
* don't belong in `core`'s pure domain layer (same precedent as
|
|
49
|
+
* `domain/errors.ts`), so they are dropped here. The extension's
|
|
50
|
+
* `VersionManager` delegates to these functions unchanged.
|
|
51
|
+
* @module domain/bundle/version
|
|
52
|
+
*/
|
|
53
|
+
const semver = __importStar(require("semver"));
|
|
54
|
+
/**
|
|
55
|
+
* Maximum bundle ID length to prevent ReDoS attacks and excessive memory usage.
|
|
56
|
+
*
|
|
57
|
+
* Rationale: Based on GitHub's repository name limit (100 chars) + owner (39 chars)
|
|
58
|
+
* + version suffix (20 chars) + separators and safety margin = 200 chars total.
|
|
59
|
+
* This prevents malicious inputs from causing regex catastrophic backtracking.
|
|
60
|
+
*/
|
|
61
|
+
const MAX_BUNDLE_ID_LENGTH = 200;
|
|
62
|
+
/**
|
|
63
|
+
* Maximum version string length to prevent ReDoS attacks.
|
|
64
|
+
*
|
|
65
|
+
* Rationale: Semver spec allows for long pre-release/build metadata, but 100 chars
|
|
66
|
+
* is reasonable for legitimate versions (e.g., "1.2.3-beta.1+build.20231201.sha256hash").
|
|
67
|
+
* This prevents malicious inputs from causing performance issues.
|
|
68
|
+
*/
|
|
69
|
+
const MAX_VERSION_LENGTH = 100;
|
|
70
|
+
function isContentHashVersion(version) {
|
|
71
|
+
return version.startsWith('hash:');
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Compare two semantic versions using semver.compare()
|
|
75
|
+
*
|
|
76
|
+
* Comparison strategy:
|
|
77
|
+
* 1. Try semver.clean() for standard versions
|
|
78
|
+
* 2. Fall back to semver.coerce() for non-standard versions
|
|
79
|
+
* 3. Last resort: lexicographic string comparison
|
|
80
|
+
* @param v1 - First version string
|
|
81
|
+
* @param v2 - Second version string
|
|
82
|
+
* @returns -1 if v1 < v2, 0 if equal, 1 if v1 > v2
|
|
83
|
+
* @throws {Error} if either version is empty or exceeds maximum length
|
|
84
|
+
*/
|
|
85
|
+
function compareVersions(v1, v2) {
|
|
86
|
+
if (!v1 || !v2) {
|
|
87
|
+
throw new Error('Version strings cannot be empty or null');
|
|
88
|
+
}
|
|
89
|
+
if (v1.length > MAX_VERSION_LENGTH || v2.length > MAX_VERSION_LENGTH) {
|
|
90
|
+
throw new Error(`Version string exceeds maximum length of ${MAX_VERSION_LENGTH}`);
|
|
91
|
+
}
|
|
92
|
+
const clean1 = semver.clean(v1);
|
|
93
|
+
const clean2 = semver.clean(v2);
|
|
94
|
+
if (clean1 && clean2) {
|
|
95
|
+
return semver.compare(clean1, clean2);
|
|
96
|
+
}
|
|
97
|
+
const coerced1 = semver.coerce(v1);
|
|
98
|
+
const coerced2 = semver.coerce(v2);
|
|
99
|
+
if (coerced1 && coerced2) {
|
|
100
|
+
return semver.compare(coerced1, coerced2);
|
|
101
|
+
}
|
|
102
|
+
return v1.localeCompare(v2);
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Determine if an update is available using semver.gt()
|
|
106
|
+
* @param installedVersion - Currently installed version
|
|
107
|
+
* @param latestVersion - Latest available version
|
|
108
|
+
* @returns True if update available (latest > installed)
|
|
109
|
+
* @throws {Error} if either version is empty or invalid
|
|
110
|
+
*/
|
|
111
|
+
function isUpdateAvailable(installedVersion, latestVersion) {
|
|
112
|
+
if (!installedVersion || !latestVersion) {
|
|
113
|
+
throw new Error('Version strings cannot be empty or null');
|
|
114
|
+
}
|
|
115
|
+
// Hash-based versions update whenever the hash differs.
|
|
116
|
+
if (isContentHashVersion(installedVersion) || isContentHashVersion(latestVersion)) {
|
|
117
|
+
return installedVersion !== latestVersion;
|
|
118
|
+
}
|
|
119
|
+
const cleanInstalled = semver.clean(installedVersion) || semver.coerce(installedVersion)?.version;
|
|
120
|
+
const cleanLatest = semver.clean(latestVersion) || semver.coerce(latestVersion)?.version;
|
|
121
|
+
if (cleanInstalled && cleanLatest) {
|
|
122
|
+
return semver.gt(cleanLatest, cleanInstalled);
|
|
123
|
+
}
|
|
124
|
+
return compareVersions(installedVersion, latestVersion) > 0;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Extract bundle identity from GitHub bundle ID by removing version suffix
|
|
128
|
+
*
|
|
129
|
+
* GitHub bundle IDs follow the format: {owner}-{repo}-{version}
|
|
130
|
+
* This method extracts {owner}-{repo} by identifying and removing the version suffix.
|
|
131
|
+
*
|
|
132
|
+
* For non-GitHub sources, the bundle ID is returned unchanged.
|
|
133
|
+
* @example
|
|
134
|
+
* extractBundleIdentity('microsoft-vscode-v1.0.0', 'github') // 'microsoft-vscode'
|
|
135
|
+
* extractBundleIdentity('my-org-my-repo-2.1.3', 'github') // 'my-org-my-repo'
|
|
136
|
+
* extractBundleIdentity('owner-123-v1.0.0', 'github') // 'owner-123'
|
|
137
|
+
* extractBundleIdentity('bundle-id', 'local') // 'bundle-id' (unchanged)
|
|
138
|
+
* @param bundleId - Bundle ID potentially containing version suffix
|
|
139
|
+
* @param sourceType - Source type of the bundle
|
|
140
|
+
* @returns Bundle identity without version suffix (GitHub only)
|
|
141
|
+
* @throws {Error} if bundleId exceeds maximum length
|
|
142
|
+
*/
|
|
143
|
+
function extractBundleIdentity(bundleId, sourceType) {
|
|
144
|
+
// Security: Prevent ReDoS attacks with length validation
|
|
145
|
+
if (bundleId.length > MAX_BUNDLE_ID_LENGTH) {
|
|
146
|
+
throw new Error(`Bundle ID exceeds maximum length of ${MAX_BUNDLE_ID_LENGTH}`);
|
|
147
|
+
}
|
|
148
|
+
if (sourceType !== 'github') {
|
|
149
|
+
return bundleId; // For non-GitHub, return as-is
|
|
150
|
+
}
|
|
151
|
+
// Match version pattern at the end: -v1.2.3 or -1.2.3
|
|
152
|
+
// This regex is more efficient than iterating through all parts
|
|
153
|
+
// Quantifier limits prevent ReDoS attacks
|
|
154
|
+
// Pattern breakdown: -v? (optional v prefix), \d{1,3} (1-3 digits per version part),
|
|
155
|
+
// optional pre-release/build metadata with restricted character set
|
|
156
|
+
const versionPattern = /-v?\d{1,3}\.\d{1,3}\.\d{1,3}(?:-[a-zA-Z0-9._-]{1,50})?$/;
|
|
157
|
+
const match = bundleId.match(versionPattern);
|
|
158
|
+
if (match && match.index !== undefined) {
|
|
159
|
+
return bundleId.slice(0, match.index);
|
|
160
|
+
}
|
|
161
|
+
// No version suffix found, return as-is
|
|
162
|
+
return bundleId;
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Check if two bundle IDs represent the same bundle identity
|
|
166
|
+
* Handles versioned IDs and different source types
|
|
167
|
+
* @param id1 - First bundle ID
|
|
168
|
+
* @param type1 - Source type of first bundle
|
|
169
|
+
* @param id2 - Second bundle ID
|
|
170
|
+
* @param type2 - Source type of second bundle
|
|
171
|
+
* @returns True if they represent the same bundle identity
|
|
172
|
+
*/
|
|
173
|
+
function isSameBundleIdentity(id1, type1, id2, type2) {
|
|
174
|
+
return extractBundleIdentity(id1, type1) === extractBundleIdentity(id2, type2);
|
|
175
|
+
}
|
|
176
|
+
//# sourceMappingURL=version.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../../src/domain/bundle/version.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoDA,0CAwBC;AASD,8CAkBC;AAmBD,sDAwBC;AAWD,oDAEC;AA/JD;;;;;;;;;;;;GAYG;AACH,+CAAiC;AAKjC;;;;;;GAMG;AACH,MAAM,oBAAoB,GAAG,GAAG,CAAC;AAEjC;;;;;;GAMG;AACH,MAAM,kBAAkB,GAAG,GAAG,CAAC;AAE/B,SAAS,oBAAoB,CAAC,OAAe;IAC3C,OAAO,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;AACrC,CAAC;AAED;;;;;;;;;;;GAWG;AACH,SAAgB,eAAe,CAAC,EAAU,EAAE,EAAU;IACpD,IAAI,CAAC,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CAAC,yCAAyC,CAAC,CAA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}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { ExtractedFiles } from '../../ports/bundle-extractor';
|
|
2
|
+
export declare const MANIFEST_FILENAME = "deployment-manifest.yml";
|
|
3
|
+
/**
|
|
4
|
+
* Options for manifest validation.
|
|
5
|
+
*/
|
|
6
|
+
export interface ManifestValidationOptions {
|
|
7
|
+
/**
|
|
8
|
+
* Expected bundle id from the BundleSpec. Optional: when omitted,
|
|
9
|
+
* the manifest's id is accepted as-is. This is used by hub-driven
|
|
10
|
+
* profile activation, where the hub config carries a synthesized
|
|
11
|
+
* id that does not necessarily match the bundle's natural id.
|
|
12
|
+
*/
|
|
13
|
+
expectedId?: string;
|
|
14
|
+
/** Expected version (skipped when 'latest' or undefined). */
|
|
15
|
+
expectedVersion?: string;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Validated manifest with required fields.
|
|
19
|
+
*/
|
|
20
|
+
export interface ValidatedManifest {
|
|
21
|
+
id: string;
|
|
22
|
+
version: string;
|
|
23
|
+
name: string;
|
|
24
|
+
/** Open-ended remainder. */
|
|
25
|
+
[key: string]: unknown;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Error thrown when manifest validation fails.
|
|
29
|
+
*/
|
|
30
|
+
export declare class ManifestValidationError extends Error {
|
|
31
|
+
readonly code: string;
|
|
32
|
+
/**
|
|
33
|
+
* Create a ManifestValidationError.
|
|
34
|
+
* @param message Error message.
|
|
35
|
+
* @param code Error code for programmatic handling.
|
|
36
|
+
*/
|
|
37
|
+
constructor(message: string, code: string);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Read + validate the deployment manifest in `files`.
|
|
41
|
+
* @param files - ExtractedFiles map.
|
|
42
|
+
* @param opts - Expected id / version.
|
|
43
|
+
* @returns Parsed + validated manifest.
|
|
44
|
+
* @throws {ManifestValidationError} On any failure.
|
|
45
|
+
*/
|
|
46
|
+
export declare const validateManifest: (files: ExtractedFiles, opts: ManifestValidationOptions) => ValidatedManifest;
|
|
47
|
+
//# sourceMappingURL=manifest-validator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manifest-validator.d.ts","sourceRoot":"","sources":["../../../src/domain/collection/manifest-validator.ts"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EACV,cAAc,EACf,MAAM,8BAA8B,CAAC;AAKtC,eAAO,MAAM,iBAAiB,4BAA4B,CAAC;AAE3D;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACxC;;;;;OAKG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,6DAA6D;IAC7D,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,4BAA4B;IAC5B,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED;;GAEG;AACH,qBAAa,uBAAwB,SAAQ,KAAK;aAMI,IAAI,EAAE,MAAM;IALhE;;;;OAIG;gBACgB,OAAO,EAAE,MAAM,EAAkB,IAAI,EAAE,MAAM;CAIjE;AAED;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,GAC3B,OAAO,cAAc,EACrB,MAAM,yBAAyB,KAC9B,iBAkDF,CAAC"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validateManifest = exports.ManifestValidationError = exports.MANIFEST_FILENAME = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Manifest validator.
|
|
6
|
+
*
|
|
7
|
+
* Reads `deployment-manifest.yml` from the extracted file map and
|
|
8
|
+
* validates the same invariants `BundleInstaller.validateBundle()`
|
|
9
|
+
* checks in the VS Code extension:
|
|
10
|
+
*
|
|
11
|
+
* - manifest exists at the bundle root
|
|
12
|
+
* - has `id`, `version`, `name`
|
|
13
|
+
* - `id` matches the expected bundle id (exact or suffix-tolerant,
|
|
14
|
+
* see {@link isManifestIdMatch})
|
|
15
|
+
* - `version` matches `bundleSpec.bundleVersion` (unless 'latest')
|
|
16
|
+
*
|
|
17
|
+
* Returns the parsed manifest on success; throws classed Errors on
|
|
18
|
+
* failure (the install command wraps them at the caller boundary).
|
|
19
|
+
* @module domain/collection/manifest-validator
|
|
20
|
+
*/
|
|
21
|
+
const js_yaml_1 = require("js-yaml");
|
|
22
|
+
const id_1 = require("../bundle/id");
|
|
23
|
+
exports.MANIFEST_FILENAME = 'deployment-manifest.yml';
|
|
24
|
+
/**
|
|
25
|
+
* Error thrown when manifest validation fails.
|
|
26
|
+
*/
|
|
27
|
+
class ManifestValidationError extends Error {
|
|
28
|
+
code;
|
|
29
|
+
/**
|
|
30
|
+
* Create a ManifestValidationError.
|
|
31
|
+
* @param message Error message.
|
|
32
|
+
* @param code Error code for programmatic handling.
|
|
33
|
+
*/
|
|
34
|
+
constructor(message, code) {
|
|
35
|
+
super(message);
|
|
36
|
+
this.code = code;
|
|
37
|
+
this.name = 'ManifestValidationError';
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
exports.ManifestValidationError = ManifestValidationError;
|
|
41
|
+
/**
|
|
42
|
+
* Read + validate the deployment manifest in `files`.
|
|
43
|
+
* @param files - ExtractedFiles map.
|
|
44
|
+
* @param opts - Expected id / version.
|
|
45
|
+
* @returns Parsed + validated manifest.
|
|
46
|
+
* @throws {ManifestValidationError} On any failure.
|
|
47
|
+
*/
|
|
48
|
+
const validateManifest = (files, opts) => {
|
|
49
|
+
const bytes = files.get(exports.MANIFEST_FILENAME);
|
|
50
|
+
if (bytes === undefined) {
|
|
51
|
+
throw new ManifestValidationError(`bundle is missing ${exports.MANIFEST_FILENAME} at root`, 'BUNDLE.MANIFEST_MISSING');
|
|
52
|
+
}
|
|
53
|
+
const text = new TextDecoder().decode(bytes);
|
|
54
|
+
let parsed;
|
|
55
|
+
try {
|
|
56
|
+
parsed = (0, js_yaml_1.load)(text);
|
|
57
|
+
}
|
|
58
|
+
catch (err) {
|
|
59
|
+
throw new ManifestValidationError(`${exports.MANIFEST_FILENAME} is not valid YAML: ${err.message}`, 'BUNDLE.MANIFEST_INVALID');
|
|
60
|
+
}
|
|
61
|
+
if (parsed === null || typeof parsed !== 'object' || Array.isArray(parsed)) {
|
|
62
|
+
throw new ManifestValidationError(`${exports.MANIFEST_FILENAME} must be a YAML mapping`, 'BUNDLE.MANIFEST_INVALID');
|
|
63
|
+
}
|
|
64
|
+
const m = parsed;
|
|
65
|
+
for (const k of ['id', 'version', 'name']) {
|
|
66
|
+
if (typeof m[k] !== 'string' || (m[k]).length === 0) {
|
|
67
|
+
throw new ManifestValidationError(`${exports.MANIFEST_FILENAME} missing or empty "${k}" field`, 'BUNDLE.MANIFEST_INVALID');
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
const id = m.id;
|
|
71
|
+
const version = m.version;
|
|
72
|
+
if (opts.expectedId !== undefined && !(0, id_1.isManifestIdMatch)(id, version, opts.expectedId)) {
|
|
73
|
+
throw new ManifestValidationError(`manifest id "${id}" does not match expected "${opts.expectedId}"`, 'BUNDLE.ID_MISMATCH');
|
|
74
|
+
}
|
|
75
|
+
if (opts.expectedVersion !== undefined
|
|
76
|
+
&& opts.expectedVersion !== 'latest'
|
|
77
|
+
&& version !== opts.expectedVersion) {
|
|
78
|
+
throw new ManifestValidationError(`manifest version "${version}" does not match expected "${opts.expectedVersion}"`, 'BUNDLE.VERSION_MISMATCH');
|
|
79
|
+
}
|
|
80
|
+
return m;
|
|
81
|
+
};
|
|
82
|
+
exports.validateManifest = validateManifest;
|
|
83
|
+
//# sourceMappingURL=manifest-validator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manifest-validator.js","sourceRoot":"","sources":["../../../src/domain/collection/manifest-validator.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;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CAAC,IAAI,EAAE,SAAS,EAAE,MAAM,CAAU,EAAE,CAAC;QACnD,IAAI,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK,QAAQ,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACpD,MAAM,IAAI,uBAAuB,CAC/B,GAAG,yBAAiB,sBAAsB,CAAC,SAAS,EACpD,yBAAyB,CAC1B,CAAC;QACJ,CAAC;IACH,CAAC;IACD,MAAM,EAAE,GAAG,CAAC,CAAC,EAAY,CAAC;IAC1B,MAAM,OAAO,GAAG,CAAC,CAAC,OAAiB,CAAC;IACpC,IAAI,IAAI,CAAC,UAAU,KAAK,SAAS,IAAI,CAAC,IAAA,sBAAiB,EAAC,EAAE,EAAE,OAAO,EAAE,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC;QACtF,MAAM,IAAI,uBAAuB,CAC/B,gBAAgB,EAAE,8BAA8B,IAAI,CAAC,UAAU,GAAG,EAClE,oBAAoB,CACrB,CAAC;IACJ,CAAC;IACD,IAAI,IAAI,CAAC,eAAe,KAAK,SAAS;WACjC,IAAI,CAAC,eAAe,KAAK,QAAQ;WACjC,OAAO,KAAK,IAAI,CAAC,eAAe,EAAE,CAAC;QACtC,MAAM,IAAI,uBAAuB,CAC/B,qBAAqB,OAAO,8BAA8B,IAAI,CAAC,eAAe,GAAG,EACjF,yBAAyB,CAC1B,CAAC;IACJ,CAAC;IACD,OAAO,CAAsB,CAAC;AAChC,CAAC,CAAC;AArDW,QAAA,gBAAgB,oBAqD3B"}
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Domain layer — Collection types.
|
|
3
|
+
*
|
|
4
|
+
* `Collection` is the pre-build, author-facing shape of a directory that
|
|
5
|
+
* validates and builds into a `Bundle` (`../bundle/types.ts`) — mirrors
|
|
6
|
+
* `lib/src/types.ts` (`Collection`, `CollectionItem`) and the
|
|
7
|
+
* `deployment-manifest.yml` schema described in
|
|
8
|
+
* `docs/author-guide/collection-schema.md`.
|
|
9
|
+
*
|
|
10
|
+
* `DeploymentManifest` mirrors the production shape at
|
|
11
|
+
* `src/types/registry.ts` verbatim (field names/casing match the on-disk
|
|
12
|
+
* YAML schema and must not be reformatted to camelCase).
|
|
13
|
+
* @module domain/collection/types
|
|
14
|
+
*/
|
|
15
|
+
/**
|
|
16
|
+
* Compression formats supported when packaging a bundle.
|
|
17
|
+
*/
|
|
18
|
+
export type CompressionFormat = 'zip' | 'tar.gz' | 'tar.bz2' | 'tar.xz' | 'none';
|
|
19
|
+
/**
|
|
20
|
+
* A single item (prompt, instruction, chat mode, agent, skill, ...) declared
|
|
21
|
+
* by a collection.
|
|
22
|
+
*/
|
|
23
|
+
export interface CollectionItem {
|
|
24
|
+
path: string;
|
|
25
|
+
kind: string;
|
|
26
|
+
name?: string;
|
|
27
|
+
description?: string;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Author-facing collection definition, prior to being built into a
|
|
31
|
+
* distributable `Bundle`.
|
|
32
|
+
*/
|
|
33
|
+
export interface Collection {
|
|
34
|
+
id: string;
|
|
35
|
+
name: string;
|
|
36
|
+
description?: string;
|
|
37
|
+
version?: string;
|
|
38
|
+
author?: string;
|
|
39
|
+
tags?: string[];
|
|
40
|
+
items: CollectionItem[];
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Result of validating a single field (collection id, version, item kind).
|
|
44
|
+
*
|
|
45
|
+
* Named `CollectionFieldValidationResult` (not the reference branch's bare
|
|
46
|
+
* `ValidationResult`) to avoid colliding with the differently-shaped
|
|
47
|
+
* `ValidationResult` already exported by `domain/source/types.ts`
|
|
48
|
+
* (`{ valid, errors: string[], warnings? }`, used by `app/registry/hub-manager.ts`)
|
|
49
|
+
* — both are wildcard re-exported from the same `domain/index.ts` barrel.
|
|
50
|
+
*/
|
|
51
|
+
export interface CollectionFieldValidationResult {
|
|
52
|
+
valid: boolean;
|
|
53
|
+
error?: string;
|
|
54
|
+
normalized?: string;
|
|
55
|
+
deprecated?: boolean;
|
|
56
|
+
replacement?: string;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Result of validating a parsed collection object's structure.
|
|
60
|
+
*/
|
|
61
|
+
export interface ObjectValidationResult {
|
|
62
|
+
ok: boolean;
|
|
63
|
+
errors: string[];
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Result of validating a collection file on disk (parse + structure).
|
|
67
|
+
*/
|
|
68
|
+
export interface FileValidationResult extends ObjectValidationResult {
|
|
69
|
+
collection?: Collection;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Aggregate result of validating every collection file in a repository.
|
|
73
|
+
*/
|
|
74
|
+
export interface AllCollectionsResult extends ObjectValidationResult {
|
|
75
|
+
fileResults: ({
|
|
76
|
+
file: string;
|
|
77
|
+
} & FileValidationResult)[];
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Configurable rules used by the collection validators.
|
|
81
|
+
*/
|
|
82
|
+
export interface ValidationRules {
|
|
83
|
+
collectionId: {
|
|
84
|
+
maxLength: number;
|
|
85
|
+
pattern: RegExp;
|
|
86
|
+
description: string;
|
|
87
|
+
};
|
|
88
|
+
version: {
|
|
89
|
+
pattern: RegExp;
|
|
90
|
+
default: string;
|
|
91
|
+
description: string;
|
|
92
|
+
};
|
|
93
|
+
itemKinds: string[];
|
|
94
|
+
deprecatedKinds: Record<string, string>;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Result of `version compute` — the next semver version + git tag for a collection.
|
|
98
|
+
*/
|
|
99
|
+
export interface VersionInfo {
|
|
100
|
+
collectionId: string;
|
|
101
|
+
collectionFile: string;
|
|
102
|
+
lastVersion: string | null;
|
|
103
|
+
manualVersion: string;
|
|
104
|
+
nextVersion: string;
|
|
105
|
+
tag: string;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Result of `bundle build` — the on-disk artifacts produced for a collection.
|
|
109
|
+
*/
|
|
110
|
+
export interface BundleInfo {
|
|
111
|
+
collectionId: string;
|
|
112
|
+
version: string;
|
|
113
|
+
outDir: string;
|
|
114
|
+
manifestAsset: string;
|
|
115
|
+
zipAsset: string;
|
|
116
|
+
bundleId: string;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Parsed `deployment-manifest.yml` — the build spec a `Collection` compiles
|
|
120
|
+
* to. Field names intentionally match the on-disk YAML schema
|
|
121
|
+
* (`snake_case` for schema-defined keys).
|
|
122
|
+
*/
|
|
123
|
+
export interface DeploymentManifest {
|
|
124
|
+
common: {
|
|
125
|
+
directories: string[];
|
|
126
|
+
files: string[];
|
|
127
|
+
include_patterns: string[];
|
|
128
|
+
exclude_patterns: string[];
|
|
129
|
+
};
|
|
130
|
+
environments?: {
|
|
131
|
+
[key: string]: {
|
|
132
|
+
name: string;
|
|
133
|
+
description: string;
|
|
134
|
+
directories: string[];
|
|
135
|
+
files: string[];
|
|
136
|
+
include_patterns: string[];
|
|
137
|
+
exclude_patterns: string[];
|
|
138
|
+
bundle_structure?: {
|
|
139
|
+
preserve_paths: boolean;
|
|
140
|
+
root_folder: string;
|
|
141
|
+
};
|
|
142
|
+
metadata?: Record<string, unknown>;
|
|
143
|
+
};
|
|
144
|
+
};
|
|
145
|
+
bundle_settings: {
|
|
146
|
+
include_common_in_environment_bundles: boolean;
|
|
147
|
+
create_common_bundle: boolean;
|
|
148
|
+
compression: CompressionFormat;
|
|
149
|
+
naming: {
|
|
150
|
+
common_bundle?: string;
|
|
151
|
+
environment_bundle: string;
|
|
152
|
+
full_bundle?: string;
|
|
153
|
+
};
|
|
154
|
+
isCurated?: boolean;
|
|
155
|
+
hubName?: string;
|
|
156
|
+
checksum?: {
|
|
157
|
+
enabled: boolean;
|
|
158
|
+
algorithms: string[];
|
|
159
|
+
};
|
|
160
|
+
output_directory?: string;
|
|
161
|
+
};
|
|
162
|
+
metadata: {
|
|
163
|
+
manifest_version: string;
|
|
164
|
+
prompt_library_version?: string;
|
|
165
|
+
last_updated?: string;
|
|
166
|
+
description: string;
|
|
167
|
+
author?: string;
|
|
168
|
+
homepage?: string;
|
|
169
|
+
repository?: {
|
|
170
|
+
type: string;
|
|
171
|
+
url: string;
|
|
172
|
+
directory?: string;
|
|
173
|
+
};
|
|
174
|
+
license?: string;
|
|
175
|
+
keywords?: string[];
|
|
176
|
+
compatibility?: {
|
|
177
|
+
min_manifest_version?: string;
|
|
178
|
+
platforms?: string[];
|
|
179
|
+
};
|
|
180
|
+
};
|
|
181
|
+
hooks?: {
|
|
182
|
+
pre_bundle?: string[];
|
|
183
|
+
post_bundle?: string[];
|
|
184
|
+
pre_install?: string[];
|
|
185
|
+
post_install?: string[];
|
|
186
|
+
};
|
|
187
|
+
prompts?: {
|
|
188
|
+
id: string;
|
|
189
|
+
name: string;
|
|
190
|
+
description: string;
|
|
191
|
+
file: string;
|
|
192
|
+
tags?: string[];
|
|
193
|
+
type?: 'prompt' | 'instructions' | 'chatmode' | 'agent' | 'skill';
|
|
194
|
+
}[];
|
|
195
|
+
/**
|
|
196
|
+
* MCP server declarations. Loosely typed pending a dedicated
|
|
197
|
+
* `domain/mcp` module — not required by any Phase 2 consumer yet.
|
|
198
|
+
*/
|
|
199
|
+
mcpServers?: Record<string, unknown>;
|
|
200
|
+
}
|
|
201
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/domain/collection/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG,KAAK,GAAG,QAAQ,GAAG,SAAS,GAAG,QAAQ,GAAG,MAAM,CAAC;AAEjF;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IAC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;QACR,EAAE,EAAE,MAAM,CAAC;QACX,IAAI,EAAE,MAAM,CAAC;QACb,WAAW,EAAE,MAAM,CAAC;QACpB,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;QAChB,IAAI,CAAC,EAAE,QAAQ,GAAG,cAAc,GAAG,UAAU,GAAG,OAAO,GAAG,OAAO,CAAC;KACnE,EAAE,CAAC;IACJ;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACtC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Domain layer — Collection types.
|
|
4
|
+
*
|
|
5
|
+
* `Collection` is the pre-build, author-facing shape of a directory that
|
|
6
|
+
* validates and builds into a `Bundle` (`../bundle/types.ts`) — mirrors
|
|
7
|
+
* `lib/src/types.ts` (`Collection`, `CollectionItem`) and the
|
|
8
|
+
* `deployment-manifest.yml` schema described in
|
|
9
|
+
* `docs/author-guide/collection-schema.md`.
|
|
10
|
+
*
|
|
11
|
+
* `DeploymentManifest` mirrors the production shape at
|
|
12
|
+
* `src/types/registry.ts` verbatim (field names/casing match the on-disk
|
|
13
|
+
* YAML schema and must not be reformatted to camelCase).
|
|
14
|
+
* @module domain/collection/types
|
|
15
|
+
*/
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/domain/collection/types.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;GAaG"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { CollectionFieldValidationResult, ObjectValidationResult, ValidationRules } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Default validation rules for collections.
|
|
4
|
+
* Item kinds are loaded from the JSON schema for single source of truth.
|
|
5
|
+
*/
|
|
6
|
+
export declare const DEFAULT_VALIDATION_RULES: ValidationRules;
|
|
7
|
+
/**
|
|
8
|
+
* Validate a collection ID.
|
|
9
|
+
* @param id - Collection ID to validate
|
|
10
|
+
* @param rules - Validation rules (uses DEFAULT_VALIDATION_RULES if not provided)
|
|
11
|
+
* @returns Validation result
|
|
12
|
+
*/
|
|
13
|
+
export declare function validateCollectionId(id: string, rules?: ValidationRules): CollectionFieldValidationResult;
|
|
14
|
+
/**
|
|
15
|
+
* Validate a version string.
|
|
16
|
+
* @param version - Version string to validate
|
|
17
|
+
* @param rules - Validation rules (uses DEFAULT_VALIDATION_RULES if not provided)
|
|
18
|
+
* @returns Validation result with normalized version
|
|
19
|
+
*/
|
|
20
|
+
export declare function validateVersion(version?: string | null, rules?: ValidationRules): CollectionFieldValidationResult;
|
|
21
|
+
/**
|
|
22
|
+
* Validate an item kind.
|
|
23
|
+
* @param kind - Item kind to validate
|
|
24
|
+
* @param rules - Validation rules (uses DEFAULT_VALIDATION_RULES if not provided)
|
|
25
|
+
* @returns Validation result
|
|
26
|
+
*/
|
|
27
|
+
export declare function validateItemKind(kind: string, rules?: ValidationRules): CollectionFieldValidationResult;
|
|
28
|
+
/**
|
|
29
|
+
* Normalize a path to be repo-root relative.
|
|
30
|
+
* Uses POSIX normalization since collection paths are repo-root relative
|
|
31
|
+
* and should work consistently across platforms.
|
|
32
|
+
* @param p - Path to normalize
|
|
33
|
+
* @returns Normalized repo-relative path
|
|
34
|
+
* @throws {Error} if path is empty, traverses outside repo, or is absolute
|
|
35
|
+
*/
|
|
36
|
+
export declare function normalizeRepoRelativePath(p: string): string;
|
|
37
|
+
/**
|
|
38
|
+
* Check if a path is a safe repo-relative path.
|
|
39
|
+
* @param p - Path to check
|
|
40
|
+
* @returns True if path is valid and safe
|
|
41
|
+
*/
|
|
42
|
+
export declare function isSafeRepoRelativePath(p: string): boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Validate a collection object structure.
|
|
45
|
+
* @param collection - Parsed collection object
|
|
46
|
+
* @param sourceLabel - Label for error messages
|
|
47
|
+
* @param rules - Validation rules (uses DEFAULT_VALIDATION_RULES if not provided)
|
|
48
|
+
* @returns Validation result
|
|
49
|
+
*/
|
|
50
|
+
export declare function validateCollectionObject(collection: unknown, sourceLabel: string, rules?: ValidationRules): ObjectValidationResult;
|
|
51
|
+
//# sourceMappingURL=validate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../../src/domain/collection/validate.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EACV,+BAA+B,EAC/B,sBAAsB,EACtB,eAAe,EAChB,MAAM,SAAS,CAAC;AAEjB;;;GAGG;AACH,eAAO,MAAM,wBAAwB,EAAE,eAetC,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,GAAE,eAA0C,GAAG,+BAA+B,CAoBnI;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,EAAE,KAAK,GAAE,eAA0C,GAAG,+BAA+B,CAkB3I;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,GAAE,eAA0C,GAAG,+BAA+B,CA2BjI;AAED;;;;;;;GAOG;AACH,wBAAgB,yBAAyB,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAmB3D;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAOzD;AAED;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CACtC,UAAU,EAAE,OAAO,EACnB,WAAW,EAAE,MAAM,EACnB,KAAK,GAAE,eAA0C,GAChD,sBAAsB,CAiExB"}
|