@uapkg/registry-tools 1.3.0 → 1.3.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/dist/aggregator/RegistryToolsAggregator.d.ts +31 -28
- package/dist/aggregator/RegistryToolsAggregator.d.ts.map +1 -1
- package/dist/aggregator/RegistryToolsAggregator.js +71 -73
- package/dist/aggregator/RegistryToolsAggregator.js.map +1 -1
- package/dist/contracts/RegistryToolsTypes.d.ts +101 -98
- package/dist/contracts/RegistryToolsTypes.d.ts.map +1 -1
- package/dist/contracts/RegistryToolsTypes.js +5 -4
- package/dist/contracts/RegistryToolsTypes.js.map +1 -1
- package/dist/index.d.ts +18 -18
- package/dist/index.js +18 -30
- package/dist/io/IntegrityCalculator.d.ts +16 -13
- package/dist/io/IntegrityCalculator.d.ts.map +1 -1
- package/dist/io/IntegrityCalculator.js +96 -92
- package/dist/io/IntegrityCalculator.js.map +1 -1
- package/dist/io/ManifestStore.d.ts +31 -28
- package/dist/io/ManifestStore.d.ts.map +1 -1
- package/dist/io/ManifestStore.js +127 -124
- package/dist/io/ManifestStore.js.map +1 -1
- package/dist/listing/PackageLister.d.ts +18 -15
- package/dist/listing/PackageLister.d.ts.map +1 -1
- package/dist/listing/PackageLister.js +75 -77
- package/dist/listing/PackageLister.js.map +1 -1
- package/dist/mutation/AddPackageVersionPlanner.d.ts +18 -15
- package/dist/mutation/AddPackageVersionPlanner.d.ts.map +1 -1
- package/dist/mutation/AddPackageVersionPlanner.js +110 -117
- package/dist/mutation/AddPackageVersionPlanner.js.map +1 -1
- package/dist/mutation/RemovePackagePlanner.d.ts +15 -12
- package/dist/mutation/RemovePackagePlanner.d.ts.map +1 -1
- package/dist/mutation/RemovePackagePlanner.js +45 -37
- package/dist/mutation/RemovePackagePlanner.js.map +1 -1
- package/dist/mutation/RemovePackageVersionPlanner.d.ts +15 -12
- package/dist/mutation/RemovePackageVersionPlanner.d.ts.map +1 -1
- package/dist/mutation/RemovePackageVersionPlanner.js +60 -52
- package/dist/mutation/RemovePackageVersionPlanner.js.map +1 -1
- package/dist/mutation/VersionSorter.d.ts +4 -1
- package/dist/mutation/VersionSorter.d.ts.map +1 -1
- package/dist/mutation/VersionSorter.js +24 -24
- package/dist/mutation/VersionSorter.js.map +1 -1
- package/dist/paths/RegistryRepoPaths.d.ts +15 -12
- package/dist/paths/RegistryRepoPaths.d.ts.map +1 -1
- package/dist/paths/RegistryRepoPaths.js +38 -33
- package/dist/paths/RegistryRepoPaths.js.map +1 -1
- package/dist/tools/RegistryTools.d.ts +53 -50
- package/dist/tools/RegistryTools.d.ts.map +1 -1
- package/dist/tools/RegistryTools.js +205 -220
- package/dist/tools/RegistryTools.js.map +1 -1
- package/dist/validation/DependencyReachabilityValidator.d.ts +15 -12
- package/dist/validation/DependencyReachabilityValidator.d.ts.map +1 -1
- package/dist/validation/DependencyReachabilityValidator.js +62 -55
- package/dist/validation/DependencyReachabilityValidator.js.map +1 -1
- package/dist/validation/ExternalRegistryPolicyValidator.d.ts +13 -10
- package/dist/validation/ExternalRegistryPolicyValidator.d.ts.map +1 -1
- package/dist/validation/ExternalRegistryPolicyValidator.js +63 -63
- package/dist/validation/ExternalRegistryPolicyValidator.js.map +1 -1
- package/dist/validation/ManifestValidator.d.ts +11 -8
- package/dist/validation/ManifestValidator.d.ts.map +1 -1
- package/dist/validation/ManifestValidator.js +29 -24
- package/dist/validation/ManifestValidator.js.map +1 -1
- package/dist/validation/OfficialRegistryPolicyValidator.d.ts +18 -15
- package/dist/validation/OfficialRegistryPolicyValidator.d.ts.map +1 -1
- package/dist/validation/OfficialRegistryPolicyValidator.js +80 -89
- package/dist/validation/OfficialRegistryPolicyValidator.js.map +1 -1
- package/dist/validation/RegistryValidator.d.ts +25 -22
- package/dist/validation/RegistryValidator.d.ts.map +1 -1
- package/dist/validation/RegistryValidator.js +89 -87
- package/dist/validation/RegistryValidator.js.map +1 -1
- package/dist/validation/ReleaseFileNameValidator.d.ts +12 -9
- package/dist/validation/ReleaseFileNameValidator.d.ts.map +1 -1
- package/dist/validation/ReleaseFileNameValidator.js +36 -29
- package/dist/validation/ReleaseFileNameValidator.js.map +1 -1
- package/package.json +19 -21
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
1
|
+
import { AddPackageVersionRequest, ChangedManifestValidation, DependencyValidationReport, ExternalRegistryPolicyReport, IntegrityAlgorithm, IntegrityVerificationResult, OfficialPackagePolicyReport, PackageSummary, RegistryLintReport, RegistryMutationPlan, RegistryMutationSummary, RegistryToolsOptions, RegistryValidationReport, ReleaseFileNameReport, RemovePackageRequest, RemovePackageVersionRequest, WriteManifestResult } from "../contracts/RegistryToolsTypes.js";
|
|
2
|
+
import { OfficialRegistryPolicyRequest } from "../validation/OfficialRegistryPolicyValidator.js";
|
|
3
|
+
import { Result } from "@uapkg/diagnostics";
|
|
4
|
+
import { Integrity, PackageRegistryManifest } from "@uapkg/registry-schema";
|
|
5
|
+
import { PackageName, PackageVersion } from "@uapkg/common-schema";
|
|
6
|
+
//#region src/tools/RegistryTools.d.ts
|
|
6
7
|
/**
|
|
7
8
|
* Programmatic toolkit for registry-owner workflows over a uapkg registry repo.
|
|
8
9
|
*
|
|
@@ -13,50 +14,52 @@ import { type OfficialRegistryPolicyRequest } from '../validation/OfficialRegist
|
|
|
13
14
|
* The `cwd` constructor option is the **registry repo root**, never a package
|
|
14
15
|
* directory inside it.
|
|
15
16
|
*/
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
17
|
+
declare class RegistryTools {
|
|
18
|
+
private readonly policy;
|
|
19
|
+
private readonly paths;
|
|
20
|
+
private readonly aggregator;
|
|
21
|
+
private readonly store;
|
|
22
|
+
private readonly manifestValidator;
|
|
23
|
+
private readonly externalRegistry;
|
|
24
|
+
private readonly dependencyReachability;
|
|
25
|
+
private readonly releaseFileNames;
|
|
26
|
+
private readonly officialPolicy;
|
|
27
|
+
private readonly integrity;
|
|
28
|
+
private readonly lister;
|
|
29
|
+
private readonly registryValidator;
|
|
30
|
+
private readonly addPlanner;
|
|
31
|
+
private readonly removeVersionPlanner;
|
|
32
|
+
private readonly removePackagePlanner;
|
|
33
|
+
constructor(options: RegistryToolsOptions);
|
|
34
|
+
getManifestPath(packageName: PackageName): Result<string>;
|
|
35
|
+
readPackageManifest(packageName: PackageName): Promise<Result<PackageRegistryManifest>>;
|
|
36
|
+
writePackageManifest(manifest: PackageRegistryManifest): Promise<Result<WriteManifestResult>>;
|
|
37
|
+
packageExists(packageName: PackageName): Result<boolean>;
|
|
38
|
+
listPackages(): Promise<Result<PackageSummary[]>>;
|
|
39
|
+
listVersions(packageName: PackageName): Promise<Result<PackageVersion[]>>;
|
|
40
|
+
validatePackageManifest(manifest: unknown): Result<PackageRegistryManifest>;
|
|
41
|
+
validateManifestFile(path: string): Promise<Result<PackageRegistryManifest>>;
|
|
42
|
+
validateRegistry(): Promise<Result<RegistryValidationReport>>;
|
|
43
|
+
validatePackages(packageNames: readonly PackageName[]): Promise<Result<RegistryValidationReport>>;
|
|
44
|
+
validateChangedManifestFiles(paths: readonly string[]): Promise<Result<ChangedManifestValidation>>;
|
|
45
|
+
validateDependencyReachability(packageName: PackageName, version: PackageVersion): Promise<Result<DependencyValidationReport>>;
|
|
46
|
+
validateExternalRegistryPolicy(manifest: PackageRegistryManifest): Result<ExternalRegistryPolicyReport>;
|
|
47
|
+
validateReleaseFileNames(packageName: PackageName, version: PackageVersion, fileNames: readonly string[]): Result<ReleaseFileNameReport>;
|
|
48
|
+
validateOfficialRegistryPolicy(request: OfficialRegistryPolicyRequest): Promise<Result<OfficialPackagePolicyReport>>;
|
|
49
|
+
/** Run lint-style checks across the whole registry. Currently equivalent to a full validation. */
|
|
50
|
+
lintRegistry(): Promise<Result<RegistryLintReport>>;
|
|
51
|
+
/** Lint a single in-memory manifest. */
|
|
52
|
+
lintPackageManifest(manifest: PackageRegistryManifest): Result<RegistryLintReport>;
|
|
53
|
+
planAddPackageVersion(request: AddPackageVersionRequest): Promise<Result<RegistryMutationPlan>>;
|
|
54
|
+
addPackageVersion(request: AddPackageVersionRequest): Promise<Result<RegistryMutationSummary>>;
|
|
55
|
+
planRemovePackageVersion(request: RemovePackageVersionRequest): Promise<Result<RegistryMutationPlan>>;
|
|
56
|
+
removePackageVersion(request: RemovePackageVersionRequest): Promise<Result<RegistryMutationSummary>>;
|
|
57
|
+
planRemovePackage(request: RemovePackageRequest): Promise<Result<RegistryMutationPlan>>;
|
|
58
|
+
removePackage(request: RemovePackageRequest): Promise<Result<RegistryMutationSummary>>;
|
|
59
|
+
computeFileIntegrity(filePath: string, algorithm?: IntegrityAlgorithm): Promise<Result<Integrity>>;
|
|
60
|
+
verifyFileIntegrity(filePath: string, expected: Integrity): Promise<Result<IntegrityVerificationResult>>;
|
|
61
|
+
private applyPlan;
|
|
61
62
|
}
|
|
63
|
+
//#endregion
|
|
64
|
+
export { RegistryTools };
|
|
62
65
|
//# sourceMappingURL=RegistryTools.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RegistryTools.d.ts","
|
|
1
|
+
{"version":3,"file":"RegistryTools.d.ts","names":[],"sources":["../../src/tools/RegistryTools.ts"],"mappings":";;;;;;;;;;;;;;;;cAoDa;mBACM;mBACA;mBACA;mBAEA;mBACA;mBACA;mBACA;mBACA;mBACA;mBACA;mBACA;mBACA;mBACA;mBACA;mBACA;EAEjB,YAAY,SAAS;EAsCrB,gBAAgB,aAAa,cAAc;EAI3C,oBAAoB,aAAa,cAAc,QAAQ,OAAO;EAI9D,qBAAqB,UAAU,0BAA0B,QAAQ,OAAO;EAIxE,cAAc,aAAa,cAAc;EAIzC,gBAAgB,QAAQ,OAAO;EAIzB,aAAa,aAAa,cAAc,QAAQ,OAAO;EAU7D,wBAAwB,oBAAoB,OAAO;EAInD,qBAAqB,eAAe,QAAQ,OAAO;EAInD,oBAAoB,QAAQ,OAAO;EAInC,iBAAiB,uBAAuB,gBAAgB,QAAQ,OAAO;EAIjE,6BAA6B,2BAA2B,QAAQ,OAAO;EAWvE,+BACJ,aAAa,aACb,SAAS,iBACR,QAAQ,OAAO;EAYlB,+BAA+B,UAAU,0BAA0B,OAAO;EAI1E,yBACE,aAAa,aACb,SAAS,gBACT,+BACC,OAAO;EAIV,+BAA+B,SAAS,gCAAgC,QAAQ,OAAO;;EAKjF,gBAAgB,QAAQ,OAAO;;EAOrC,oBAAoB,UAAU,0BAA0B,OAAO;EAS/D,sBAAsB,SAAS,2BAA2B,QAAQ,OAAO;EAInE,kBAAkB,SAAS,2BAA2B,QAAQ,OAAO;EAM3E,yBAAyB,SAAS,8BAA8B,QAAQ,OAAO;EAIzE,qBAAqB,SAAS,8BAA8B,QAAQ,OAAO;EAMjF,kBAAkB,SAAS,uBAAuB,QAAQ,OAAO;EAI3D,cAAc,SAAS,uBAAuB,QAAQ,OAAO;EAUnE,qBAAqB,kBAAkB,YAAY,qBAAqB,QAAQ,OAAO;EAIvF,oBAAoB,kBAAkB,UAAU,YAAY,QAAQ,OAAO;UAQ7D"}
|
|
@@ -1,224 +1,209 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
1
|
+
import { RegistryToolsAggregator } from "../aggregator/RegistryToolsAggregator.js";
|
|
2
|
+
import { IntegrityCalculator } from "../io/IntegrityCalculator.js";
|
|
3
|
+
import { ManifestStore } from "../io/ManifestStore.js";
|
|
4
|
+
import { PackageLister } from "../listing/PackageLister.js";
|
|
5
|
+
import { AddPackageVersionPlanner } from "../mutation/AddPackageVersionPlanner.js";
|
|
6
|
+
import { RemovePackagePlanner } from "../mutation/RemovePackagePlanner.js";
|
|
7
|
+
import { RemovePackageVersionPlanner } from "../mutation/RemovePackageVersionPlanner.js";
|
|
8
|
+
import { RegistryRepoPaths } from "../paths/RegistryRepoPaths.js";
|
|
9
|
+
import { DependencyReachabilityValidator } from "../validation/DependencyReachabilityValidator.js";
|
|
10
|
+
import { ExternalRegistryPolicyValidator } from "../validation/ExternalRegistryPolicyValidator.js";
|
|
11
|
+
import { ManifestValidator } from "../validation/ManifestValidator.js";
|
|
12
|
+
import { OfficialRegistryPolicyValidator } from "../validation/OfficialRegistryPolicyValidator.js";
|
|
13
|
+
import { RegistryValidator } from "../validation/RegistryValidator.js";
|
|
14
|
+
import { ReleaseFileNameValidator } from "../validation/ReleaseFileNameValidator.js";
|
|
15
|
+
import { DiagnosticBag, fail, ok } from "@uapkg/diagnostics";
|
|
16
|
+
import { rm } from "node:fs/promises";
|
|
17
|
+
|
|
18
|
+
//#region src/tools/RegistryTools.ts
|
|
17
19
|
/**
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
const reason = err instanceof Error ? err.message : String(err);
|
|
194
|
-
bag.addError('IO_ERROR', `Failed to delete ${op.path}: ${reason}`, { path: op.path, reason });
|
|
195
|
-
this.aggregator.addMany(bag.all());
|
|
196
|
-
return bag.toFailure();
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
else if (plan.nextManifest) {
|
|
200
|
-
const write = await this.store.write(plan.nextManifest);
|
|
201
|
-
if (!write.ok) {
|
|
202
|
-
bag.mergeArray(write.diagnostics);
|
|
203
|
-
return bag.toFailure();
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
return ok({
|
|
208
|
-
operations: plan.operations,
|
|
209
|
-
diagnostics: bag.all(),
|
|
210
|
-
}, bag.all());
|
|
211
|
-
}
|
|
212
|
-
}
|
|
20
|
+
* Programmatic toolkit for registry-owner workflows over a uapkg registry repo.
|
|
21
|
+
*
|
|
22
|
+
* Always returns `Result<T>`. Never throws for expected failures. Diagnostics
|
|
23
|
+
* are also pushed into a process-wide singleton aggregator (with `once`
|
|
24
|
+
* deduplication) so a CI run can surface a single consolidated list.
|
|
25
|
+
*
|
|
26
|
+
* The `cwd` constructor option is the **registry repo root**, never a package
|
|
27
|
+
* directory inside it.
|
|
28
|
+
*/
|
|
29
|
+
var RegistryTools = class {
|
|
30
|
+
policy;
|
|
31
|
+
paths;
|
|
32
|
+
aggregator;
|
|
33
|
+
store;
|
|
34
|
+
manifestValidator;
|
|
35
|
+
externalRegistry;
|
|
36
|
+
dependencyReachability;
|
|
37
|
+
releaseFileNames;
|
|
38
|
+
officialPolicy;
|
|
39
|
+
integrity;
|
|
40
|
+
lister;
|
|
41
|
+
registryValidator;
|
|
42
|
+
addPlanner;
|
|
43
|
+
removeVersionPlanner;
|
|
44
|
+
removePackagePlanner;
|
|
45
|
+
constructor(options) {
|
|
46
|
+
this.policy = resolvePolicy(options.policy);
|
|
47
|
+
this.paths = new RegistryRepoPaths(options.cwd);
|
|
48
|
+
this.aggregator = RegistryToolsAggregator.getInstance();
|
|
49
|
+
this.store = new ManifestStore(this.paths, this.aggregator);
|
|
50
|
+
this.manifestValidator = new ManifestValidator(this.aggregator);
|
|
51
|
+
this.externalRegistry = new ExternalRegistryPolicyValidator(this.policy, this.aggregator);
|
|
52
|
+
this.dependencyReachability = new DependencyReachabilityValidator(this.policy, this.store, this.aggregator);
|
|
53
|
+
this.releaseFileNames = new ReleaseFileNameValidator(this.aggregator);
|
|
54
|
+
this.officialPolicy = new OfficialRegistryPolicyValidator(this.aggregator);
|
|
55
|
+
this.integrity = new IntegrityCalculator(this.aggregator);
|
|
56
|
+
this.lister = new PackageLister(this.paths, this.store, this.aggregator);
|
|
57
|
+
this.registryValidator = new RegistryValidator(this.policy, this.paths, this.store, this.lister, this.externalRegistry, this.dependencyReachability, this.aggregator);
|
|
58
|
+
this.addPlanner = new AddPackageVersionPlanner(this.policy, this.paths, this.store, this.externalRegistry, this.dependencyReachability, this.aggregator);
|
|
59
|
+
this.removeVersionPlanner = new RemovePackageVersionPlanner(this.policy, this.paths, this.store, this.aggregator);
|
|
60
|
+
this.removePackagePlanner = new RemovePackagePlanner(this.policy, this.paths, this.store, this.aggregator);
|
|
61
|
+
}
|
|
62
|
+
getManifestPath(packageName) {
|
|
63
|
+
return ok(this.paths.manifestPath(packageName));
|
|
64
|
+
}
|
|
65
|
+
readPackageManifest(packageName) {
|
|
66
|
+
return this.store.read(packageName);
|
|
67
|
+
}
|
|
68
|
+
writePackageManifest(manifest) {
|
|
69
|
+
return this.store.write(manifest);
|
|
70
|
+
}
|
|
71
|
+
packageExists(packageName) {
|
|
72
|
+
return ok(this.store.exists(packageName));
|
|
73
|
+
}
|
|
74
|
+
listPackages() {
|
|
75
|
+
return this.lister.listSummaries();
|
|
76
|
+
}
|
|
77
|
+
async listVersions(packageName) {
|
|
78
|
+
const read = await this.store.read(packageName);
|
|
79
|
+
if (!read.ok) return read;
|
|
80
|
+
return ok(Object.keys(read.value.versions), read.diagnostics);
|
|
81
|
+
}
|
|
82
|
+
validatePackageManifest(manifest) {
|
|
83
|
+
return this.manifestValidator.validate(manifest);
|
|
84
|
+
}
|
|
85
|
+
validateManifestFile(path) {
|
|
86
|
+
return this.store.readFromPath(path);
|
|
87
|
+
}
|
|
88
|
+
validateRegistry() {
|
|
89
|
+
return this.registryValidator.validateRegistry();
|
|
90
|
+
}
|
|
91
|
+
validatePackages(packageNames) {
|
|
92
|
+
return this.registryValidator.validatePackages(packageNames);
|
|
93
|
+
}
|
|
94
|
+
async validateChangedManifestFiles(paths) {
|
|
95
|
+
const perFile = [];
|
|
96
|
+
const overall = new DiagnosticBag();
|
|
97
|
+
for (const path of paths) {
|
|
98
|
+
const r = await this.store.readFromPath(path);
|
|
99
|
+
perFile.push({
|
|
100
|
+
path,
|
|
101
|
+
diagnostics: r.diagnostics
|
|
102
|
+
});
|
|
103
|
+
overall.mergeArray(r.diagnostics);
|
|
104
|
+
}
|
|
105
|
+
return ok({ perFile }, overall.all());
|
|
106
|
+
}
|
|
107
|
+
async validateDependencyReachability(packageName, version) {
|
|
108
|
+
const read = await this.store.read(packageName);
|
|
109
|
+
if (!read.ok) return read;
|
|
110
|
+
const entry = read.value.versions[version];
|
|
111
|
+
if (!entry) {
|
|
112
|
+
const bag = new DiagnosticBag();
|
|
113
|
+
bag.mergeArray(read.diagnostics);
|
|
114
|
+
return fail(bag.all());
|
|
115
|
+
}
|
|
116
|
+
return this.dependencyReachability.validate(packageName, version, entry);
|
|
117
|
+
}
|
|
118
|
+
validateExternalRegistryPolicy(manifest) {
|
|
119
|
+
return this.externalRegistry.validate(manifest);
|
|
120
|
+
}
|
|
121
|
+
validateReleaseFileNames(packageName, version, fileNames) {
|
|
122
|
+
return this.releaseFileNames.validate(packageName, version, fileNames);
|
|
123
|
+
}
|
|
124
|
+
validateOfficialRegistryPolicy(request) {
|
|
125
|
+
return this.officialPolicy.validate(request);
|
|
126
|
+
}
|
|
127
|
+
/** Run lint-style checks across the whole registry. Currently equivalent to a full validation. */
|
|
128
|
+
async lintRegistry() {
|
|
129
|
+
const r = await this.registryValidator.validateRegistry();
|
|
130
|
+
if (!r.ok) return r;
|
|
131
|
+
return ok({ diagnostics: r.value.diagnostics }, r.diagnostics);
|
|
132
|
+
}
|
|
133
|
+
/** Lint a single in-memory manifest. */
|
|
134
|
+
lintPackageManifest(manifest) {
|
|
135
|
+
const ext = this.externalRegistry.validate(manifest);
|
|
136
|
+
return ok({ diagnostics: ext.diagnostics }, ext.diagnostics);
|
|
137
|
+
}
|
|
138
|
+
planAddPackageVersion(request) {
|
|
139
|
+
return this.addPlanner.plan(request);
|
|
140
|
+
}
|
|
141
|
+
async addPackageVersion(request) {
|
|
142
|
+
const plan = await this.addPlanner.plan(request);
|
|
143
|
+
if (!plan.ok) return plan;
|
|
144
|
+
return this.applyPlan(plan.value);
|
|
145
|
+
}
|
|
146
|
+
planRemovePackageVersion(request) {
|
|
147
|
+
return this.removeVersionPlanner.plan(request);
|
|
148
|
+
}
|
|
149
|
+
async removePackageVersion(request) {
|
|
150
|
+
const plan = await this.removeVersionPlanner.plan(request);
|
|
151
|
+
if (!plan.ok) return plan;
|
|
152
|
+
return this.applyPlan(plan.value);
|
|
153
|
+
}
|
|
154
|
+
planRemovePackage(request) {
|
|
155
|
+
return this.removePackagePlanner.plan(request);
|
|
156
|
+
}
|
|
157
|
+
async removePackage(request) {
|
|
158
|
+
const plan = await this.removePackagePlanner.plan(request);
|
|
159
|
+
if (!plan.ok) return plan;
|
|
160
|
+
return this.applyPlan(plan.value);
|
|
161
|
+
}
|
|
162
|
+
computeFileIntegrity(filePath, algorithm) {
|
|
163
|
+
return this.integrity.compute(filePath, algorithm);
|
|
164
|
+
}
|
|
165
|
+
verifyFileIntegrity(filePath, expected) {
|
|
166
|
+
return this.integrity.verify(filePath, expected);
|
|
167
|
+
}
|
|
168
|
+
async applyPlan(plan) {
|
|
169
|
+
const bag = new DiagnosticBag();
|
|
170
|
+
bag.mergeArray(plan.diagnostics);
|
|
171
|
+
for (const op of plan.operations) if (op.kind === "delete-manifest") try {
|
|
172
|
+
await rm(op.path, { force: true });
|
|
173
|
+
} catch (err) {
|
|
174
|
+
const reason = err instanceof Error ? err.message : String(err);
|
|
175
|
+
bag.addError("IO_ERROR", `Failed to delete ${op.path}: ${reason}`, {
|
|
176
|
+
path: op.path,
|
|
177
|
+
reason
|
|
178
|
+
});
|
|
179
|
+
this.aggregator.addMany(bag.all());
|
|
180
|
+
return bag.toFailure();
|
|
181
|
+
}
|
|
182
|
+
else if (plan.nextManifest) {
|
|
183
|
+
const write = await this.store.write(plan.nextManifest);
|
|
184
|
+
if (!write.ok) {
|
|
185
|
+
bag.mergeArray(write.diagnostics);
|
|
186
|
+
return bag.toFailure();
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
return ok({
|
|
190
|
+
operations: plan.operations,
|
|
191
|
+
diagnostics: bag.all()
|
|
192
|
+
}, bag.all());
|
|
193
|
+
}
|
|
194
|
+
};
|
|
213
195
|
function resolvePolicy(policy) {
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
196
|
+
return {
|
|
197
|
+
externalRegistries: policy?.externalRegistries ?? "deny",
|
|
198
|
+
allowedExternalRegistryNames: policy?.allowedExternalRegistryNames ?? [],
|
|
199
|
+
removals: policy?.removals ?? "deny",
|
|
200
|
+
unknownKeys: policy?.unknownKeys ?? "warn",
|
|
201
|
+
requireExistingDependencies: policy?.requireExistingDependencies ?? true,
|
|
202
|
+
requireReachableDependencyRanges: policy?.requireReachableDependencyRanges ?? true,
|
|
203
|
+
requireSortedVersions: policy?.requireSortedVersions ?? true
|
|
204
|
+
};
|
|
223
205
|
}
|
|
206
|
+
|
|
207
|
+
//#endregion
|
|
208
|
+
export { RegistryTools };
|
|
224
209
|
//# sourceMappingURL=RegistryTools.js.map
|