@evref-bl/plexus 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -2
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +296 -0
- package/dist/cli.js.map +1 -0
- package/dist/config/config.d.ts +29 -0
- package/dist/config/config.d.ts.map +1 -0
- package/dist/config/config.js +111 -0
- package/dist/config/config.js.map +1 -0
- package/dist/config/plexusHome.d.ts +17 -0
- package/dist/config/plexusHome.d.ts.map +1 -0
- package/dist/config/plexusHome.js +30 -0
- package/dist/config/plexusHome.js.map +1 -0
- package/dist/config/projectConfig.d.ts +228 -0
- package/dist/config/projectConfig.d.ts.map +1 -0
- package/dist/config/projectConfig.js +1159 -0
- package/dist/config/projectConfig.js.map +1 -0
- package/dist/config/target.d.ts +19 -0
- package/dist/config/target.d.ts.map +1 -0
- package/dist/config/target.js +2 -0
- package/dist/config/target.js.map +1 -0
- package/dist/gateway/projectGateway.d.ts +80 -0
- package/dist/gateway/projectGateway.d.ts.map +1 -0
- package/dist/gateway/projectGateway.js +435 -0
- package/dist/gateway/projectGateway.js.map +1 -0
- package/dist/gateway/projectImageMcpEndpoint.d.ts +24 -0
- package/dist/gateway/projectImageMcpEndpoint.d.ts.map +1 -0
- package/dist/gateway/projectImageMcpEndpoint.js +79 -0
- package/dist/gateway/projectImageMcpEndpoint.js.map +1 -0
- package/dist/images/homeImageCache.d.ts +264 -0
- package/dist/images/homeImageCache.d.ts.map +1 -0
- package/dist/images/homeImageCache.js +930 -0
- package/dist/images/homeImageCache.js.map +1 -0
- package/dist/images/imageRescue.d.ts +155 -0
- package/dist/images/imageRescue.d.ts.map +1 -0
- package/dist/images/imageRescue.js +847 -0
- package/dist/images/imageRescue.js.map +1 -0
- package/dist/images/preparedImageCache.d.ts +90 -0
- package/dist/images/preparedImageCache.d.ts.map +1 -0
- package/dist/images/preparedImageCache.js +237 -0
- package/dist/images/preparedImageCache.js.map +1 -0
- package/dist/images/scopedTemplateCatalog.d.ts +32 -0
- package/dist/images/scopedTemplateCatalog.d.ts.map +1 -0
- package/dist/images/scopedTemplateCatalog.js +316 -0
- package/dist/images/scopedTemplateCatalog.js.map +1 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +22 -0
- package/dist/index.js.map +1 -0
- package/dist/launcher/pharoLauncherMcpClient.d.ts +17 -0
- package/dist/launcher/pharoLauncherMcpClient.d.ts.map +1 -0
- package/dist/launcher/pharoLauncherMcpClient.js +78 -0
- package/dist/launcher/pharoLauncherMcpClient.js.map +1 -0
- package/dist/launcher/pharoLauncherProfile.d.ts +31 -0
- package/dist/launcher/pharoLauncherProfile.d.ts.map +1 -0
- package/dist/launcher/pharoLauncherProfile.js +122 -0
- package/dist/launcher/pharoLauncherProfile.js.map +1 -0
- package/dist/launcher/scopedPharoLauncherServer.d.ts +247 -0
- package/dist/launcher/scopedPharoLauncherServer.d.ts.map +1 -0
- package/dist/launcher/scopedPharoLauncherServer.js +1097 -0
- package/dist/launcher/scopedPharoLauncherServer.js.map +1 -0
- package/dist/lifecycle/projectCleanup.d.ts +59 -0
- package/dist/lifecycle/projectCleanup.d.ts.map +1 -0
- package/dist/lifecycle/projectCleanup.js +483 -0
- package/dist/lifecycle/projectCleanup.js.map +1 -0
- package/dist/lifecycle/projectClose.d.ts +35 -0
- package/dist/lifecycle/projectClose.d.ts.map +1 -0
- package/dist/lifecycle/projectClose.js +273 -0
- package/dist/lifecycle/projectClose.js.map +1 -0
- package/dist/lifecycle/projectLifecycle.d.ts +422 -0
- package/dist/lifecycle/projectLifecycle.d.ts.map +1 -0
- package/dist/lifecycle/projectLifecycle.js +2114 -0
- package/dist/lifecycle/projectLifecycle.js.map +1 -0
- package/dist/lifecycle/projectOpen.d.ts +68 -0
- package/dist/lifecycle/projectOpen.d.ts.map +1 -0
- package/dist/lifecycle/projectOpen.js +1471 -0
- package/dist/lifecycle/projectOpen.js.map +1 -0
- package/dist/mcp/pharoMcpHealth.d.ts +26 -0
- package/dist/mcp/pharoMcpHealth.d.ts.map +1 -0
- package/dist/mcp/pharoMcpHealth.js +97 -0
- package/dist/mcp/pharoMcpHealth.js.map +1 -0
- package/dist/mcp/server.d.ts +86 -0
- package/dist/mcp/server.d.ts.map +1 -0
- package/dist/mcp/server.js +357 -0
- package/dist/mcp/server.js.map +1 -0
- package/dist/ports/imagePortClaims.d.ts +41 -0
- package/dist/ports/imagePortClaims.d.ts.map +1 -0
- package/dist/ports/imagePortClaims.js +337 -0
- package/dist/ports/imagePortClaims.js.map +1 -0
- package/dist/ports/portClaims.d.ts +116 -0
- package/dist/ports/portClaims.d.ts.map +1 -0
- package/dist/ports/portClaims.js +393 -0
- package/dist/ports/portClaims.js.map +1 -0
- package/dist/support/pathStyle.d.ts +11 -0
- package/dist/support/pathStyle.d.ts.map +1 -0
- package/dist/support/pathStyle.js +61 -0
- package/dist/support/pathStyle.js.map +1 -0
- package/dist/support/runtimeIdentity.d.ts +13 -0
- package/dist/support/runtimeIdentity.d.ts.map +1 -0
- package/dist/support/runtimeIdentity.js +38 -0
- package/dist/support/runtimeIdentity.js.map +1 -0
- package/dist/support/toolResultFormatting.d.ts +8 -0
- package/dist/support/toolResultFormatting.d.ts.map +1 -0
- package/dist/support/toolResultFormatting.js +81 -0
- package/dist/support/toolResultFormatting.js.map +1 -0
- package/dist/workspace/projectRepositoryWorkspace.d.ts +74 -0
- package/dist/workspace/projectRepositoryWorkspace.d.ts.map +1 -0
- package/dist/workspace/projectRepositoryWorkspace.js +553 -0
- package/dist/workspace/projectRepositoryWorkspace.js.map +1 -0
- package/dist/workspace/projectStartupScript.d.ts +74 -0
- package/dist/workspace/projectStartupScript.d.ts.map +1 -0
- package/dist/workspace/projectStartupScript.js +748 -0
- package/dist/workspace/projectStartupScript.js.map +1 -0
- package/dist/workspace/projectState.d.ts +319 -0
- package/dist/workspace/projectState.d.ts.map +1 -0
- package/dist/workspace/projectState.js +399 -0
- package/dist/workspace/projectState.js.map +1 -0
- package/dist/workspace/scopedProjectContext.d.ts +169 -0
- package/dist/workspace/scopedProjectContext.d.ts.map +1 -0
- package/dist/workspace/scopedProjectContext.js +358 -0
- package/dist/workspace/scopedProjectContext.js.map +1 -0
- package/package.json +39 -4
|
@@ -0,0 +1,1159 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import { joinPathLike } from "../support/pathStyle.js";
|
|
3
|
+
export const plexusProjectConfigFileName = "plexus.project.json";
|
|
4
|
+
export const defaultPharoMcpMetadataKey = "io.github.evref-bl/pharo";
|
|
5
|
+
export const defaultPharoMcpSupportedMajorVersions = [12, 13, 14];
|
|
6
|
+
export class ProjectConfigError extends Error {
|
|
7
|
+
issues;
|
|
8
|
+
constructor(message, issues) {
|
|
9
|
+
super(message);
|
|
10
|
+
this.issues = issues;
|
|
11
|
+
this.name = "ProjectConfigError";
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
function isObject(value) {
|
|
15
|
+
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
16
|
+
}
|
|
17
|
+
export function defaultProjectRuntimePolicy() {
|
|
18
|
+
return {
|
|
19
|
+
scope: "project",
|
|
20
|
+
stateRoot: {
|
|
21
|
+
mode: "project-local",
|
|
22
|
+
},
|
|
23
|
+
gateway: {
|
|
24
|
+
mode: "project-local",
|
|
25
|
+
host: "127.0.0.1",
|
|
26
|
+
portRange: {
|
|
27
|
+
start: 8_133,
|
|
28
|
+
end: 8_199,
|
|
29
|
+
},
|
|
30
|
+
mcpPath: "/mcp",
|
|
31
|
+
routeControlMcpPath: "/control-mcp",
|
|
32
|
+
},
|
|
33
|
+
imagePorts: {
|
|
34
|
+
allocation: "configured-or-dynamic",
|
|
35
|
+
range: {
|
|
36
|
+
start: 7_100,
|
|
37
|
+
end: 7_199,
|
|
38
|
+
},
|
|
39
|
+
coordination: {
|
|
40
|
+
mode: "host-local",
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
launcherProfile: {
|
|
44
|
+
mode: "project-owned",
|
|
45
|
+
},
|
|
46
|
+
pharoMcp: {
|
|
47
|
+
metadataKey: defaultPharoMcpMetadataKey,
|
|
48
|
+
supportedMajorVersions: [...defaultPharoMcpSupportedMajorVersions],
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
export function resolveProjectRuntimePolicy(config) {
|
|
53
|
+
return config.runtime ?? defaultProjectRuntimePolicy();
|
|
54
|
+
}
|
|
55
|
+
export function projectConfigId(config) {
|
|
56
|
+
return config.id;
|
|
57
|
+
}
|
|
58
|
+
export function projectMcpStartupMode(mcp) {
|
|
59
|
+
return mcp.startupMode ?? "required";
|
|
60
|
+
}
|
|
61
|
+
export function projectMcpLoadPolicy(mcp) {
|
|
62
|
+
return mcp.loadPolicy ?? "ifMissing";
|
|
63
|
+
}
|
|
64
|
+
export function projectImageDisplayMode(image) {
|
|
65
|
+
return image.displayMode ?? "headless";
|
|
66
|
+
}
|
|
67
|
+
export function projectImageCreateCleanupPolicy(create) {
|
|
68
|
+
return create.cleanupPolicy ?? "workspace_cleanup_only";
|
|
69
|
+
}
|
|
70
|
+
function stringField(object, key, issues, pathPrefix) {
|
|
71
|
+
const value = object[key];
|
|
72
|
+
if (typeof value === "string" && value.trim().length > 0) {
|
|
73
|
+
return value;
|
|
74
|
+
}
|
|
75
|
+
issues.push(`${pathPrefix}.${key} must be a non-empty string`);
|
|
76
|
+
return "";
|
|
77
|
+
}
|
|
78
|
+
function stringFieldAllowingEmpty(object, key, issues, pathPrefix) {
|
|
79
|
+
const value = object[key];
|
|
80
|
+
if (typeof value === "string") {
|
|
81
|
+
return value;
|
|
82
|
+
}
|
|
83
|
+
issues.push(`${pathPrefix}.${key} must be a string`);
|
|
84
|
+
return "";
|
|
85
|
+
}
|
|
86
|
+
function booleanField(object, key, issues, pathPrefix) {
|
|
87
|
+
const value = object[key];
|
|
88
|
+
if (typeof value === "boolean") {
|
|
89
|
+
return value;
|
|
90
|
+
}
|
|
91
|
+
issues.push(`${pathPrefix}.${key} must be a boolean`);
|
|
92
|
+
return false;
|
|
93
|
+
}
|
|
94
|
+
function booleanFieldWithDefault(object, key, issues, pathPrefix, defaultValue) {
|
|
95
|
+
const value = object[key];
|
|
96
|
+
if (value === undefined) {
|
|
97
|
+
return defaultValue;
|
|
98
|
+
}
|
|
99
|
+
if (typeof value === "boolean") {
|
|
100
|
+
return value;
|
|
101
|
+
}
|
|
102
|
+
issues.push(`${pathPrefix}.${key} must be a boolean`);
|
|
103
|
+
return defaultValue;
|
|
104
|
+
}
|
|
105
|
+
function optionalPortField(object, key, issues, pathPrefix) {
|
|
106
|
+
const value = object[key];
|
|
107
|
+
if (value === undefined) {
|
|
108
|
+
return undefined;
|
|
109
|
+
}
|
|
110
|
+
if (typeof value === "number" &&
|
|
111
|
+
Number.isInteger(value) &&
|
|
112
|
+
value >= 1 &&
|
|
113
|
+
value <= 65_535) {
|
|
114
|
+
return value;
|
|
115
|
+
}
|
|
116
|
+
issues.push(`${pathPrefix}.${key} must be an integer between 1 and 65535`);
|
|
117
|
+
return undefined;
|
|
118
|
+
}
|
|
119
|
+
function optionalPharoMcpStartupModeField(object, key, issues, pathPrefix) {
|
|
120
|
+
const value = object[key];
|
|
121
|
+
if (value === undefined) {
|
|
122
|
+
return undefined;
|
|
123
|
+
}
|
|
124
|
+
if (value === "required" || value === "optional" || value === "disabled") {
|
|
125
|
+
return value;
|
|
126
|
+
}
|
|
127
|
+
issues.push(`${pathPrefix}.${key} must be one of required, optional, disabled`);
|
|
128
|
+
return undefined;
|
|
129
|
+
}
|
|
130
|
+
function optionalPharoMcpLoadPolicyField(object, key, issues, pathPrefix) {
|
|
131
|
+
const value = object[key];
|
|
132
|
+
if (value === undefined) {
|
|
133
|
+
return undefined;
|
|
134
|
+
}
|
|
135
|
+
if (value === "ifMissing" || value === "always" || value === "never") {
|
|
136
|
+
return value;
|
|
137
|
+
}
|
|
138
|
+
issues.push(`${pathPrefix}.${key} must be one of ifMissing, always, never`);
|
|
139
|
+
return undefined;
|
|
140
|
+
}
|
|
141
|
+
function imageMcpLoadScriptField(object, key, issues, pathPrefix, loadPolicy) {
|
|
142
|
+
if (loadPolicy === "never" && object[key] === undefined) {
|
|
143
|
+
return "";
|
|
144
|
+
}
|
|
145
|
+
return stringField(object, key, issues, pathPrefix);
|
|
146
|
+
}
|
|
147
|
+
function optionalImageDisplayModeField(object, key, issues, pathPrefix) {
|
|
148
|
+
const value = object[key];
|
|
149
|
+
if (value === undefined) {
|
|
150
|
+
return undefined;
|
|
151
|
+
}
|
|
152
|
+
if (value === "headless" || value === "interactive") {
|
|
153
|
+
return value;
|
|
154
|
+
}
|
|
155
|
+
issues.push(`${pathPrefix}.${key} must be one of headless, interactive`);
|
|
156
|
+
return undefined;
|
|
157
|
+
}
|
|
158
|
+
function optionalImageCreateCleanupPolicyField(object, key, issues, pathPrefix) {
|
|
159
|
+
const value = object[key];
|
|
160
|
+
if (value === undefined) {
|
|
161
|
+
return undefined;
|
|
162
|
+
}
|
|
163
|
+
if (value === "workspace_cleanup_only") {
|
|
164
|
+
return value;
|
|
165
|
+
}
|
|
166
|
+
issues.push(`${pathPrefix}.${key} must be workspace_cleanup_only`);
|
|
167
|
+
return undefined;
|
|
168
|
+
}
|
|
169
|
+
function optionalPositiveIntegerField(object, key, issues, pathPrefix) {
|
|
170
|
+
const value = object[key];
|
|
171
|
+
if (value === undefined) {
|
|
172
|
+
return undefined;
|
|
173
|
+
}
|
|
174
|
+
if (typeof value === "number" && Number.isInteger(value) && value > 0) {
|
|
175
|
+
return value;
|
|
176
|
+
}
|
|
177
|
+
issues.push(`${pathPrefix}.${key} must be a positive integer`);
|
|
178
|
+
return undefined;
|
|
179
|
+
}
|
|
180
|
+
function requiredPortField(object, key, issues, pathPrefix, fallback) {
|
|
181
|
+
const value = optionalPortField(object, key, issues, pathPrefix);
|
|
182
|
+
if (value !== undefined) {
|
|
183
|
+
return value;
|
|
184
|
+
}
|
|
185
|
+
if (object[key] === undefined) {
|
|
186
|
+
issues.push(`${pathPrefix}.${key} must be an integer between 1 and 65535`);
|
|
187
|
+
}
|
|
188
|
+
return fallback;
|
|
189
|
+
}
|
|
190
|
+
function optionalStringField(object, key, issues, pathPrefix) {
|
|
191
|
+
const value = object[key];
|
|
192
|
+
if (value === undefined) {
|
|
193
|
+
return undefined;
|
|
194
|
+
}
|
|
195
|
+
if (typeof value === "string" && value.trim().length > 0) {
|
|
196
|
+
return value;
|
|
197
|
+
}
|
|
198
|
+
issues.push(`${pathPrefix}.${key} must be a non-empty string`);
|
|
199
|
+
return undefined;
|
|
200
|
+
}
|
|
201
|
+
function stringFieldWithDefault(object, key, issues, pathPrefix, defaultValue) {
|
|
202
|
+
return optionalStringField(object, key, issues, pathPrefix) ?? defaultValue;
|
|
203
|
+
}
|
|
204
|
+
function urlField(object, key, issues, pathPrefix) {
|
|
205
|
+
const value = object[key];
|
|
206
|
+
if (typeof value === "string" && value.trim().length > 0) {
|
|
207
|
+
try {
|
|
208
|
+
new URL(value);
|
|
209
|
+
return value;
|
|
210
|
+
}
|
|
211
|
+
catch {
|
|
212
|
+
issues.push(`${pathPrefix}.${key} must be a valid URL`);
|
|
213
|
+
return "";
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
issues.push(`${pathPrefix}.${key} must be a valid URL`);
|
|
217
|
+
return "";
|
|
218
|
+
}
|
|
219
|
+
function optionalUrlField(object, key, issues, pathPrefix) {
|
|
220
|
+
const value = object[key];
|
|
221
|
+
if (value === undefined) {
|
|
222
|
+
return undefined;
|
|
223
|
+
}
|
|
224
|
+
if (typeof value === "string" && value.trim().length > 0) {
|
|
225
|
+
try {
|
|
226
|
+
new URL(value);
|
|
227
|
+
return value;
|
|
228
|
+
}
|
|
229
|
+
catch {
|
|
230
|
+
issues.push(`${pathPrefix}.${key} must be a valid URL`);
|
|
231
|
+
return undefined;
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
issues.push(`${pathPrefix}.${key} must be a valid URL`);
|
|
235
|
+
return undefined;
|
|
236
|
+
}
|
|
237
|
+
function pathFieldWithDefault(object, key, issues, pathPrefix, defaultValue) {
|
|
238
|
+
const value = stringFieldWithDefault(object, key, issues, pathPrefix, defaultValue);
|
|
239
|
+
if (!value.startsWith("/")) {
|
|
240
|
+
issues.push(`${pathPrefix}.${key} must start with /`);
|
|
241
|
+
return defaultValue;
|
|
242
|
+
}
|
|
243
|
+
return value;
|
|
244
|
+
}
|
|
245
|
+
function parseRuntimePortRange(value, issues, pathPrefix, fallback) {
|
|
246
|
+
if (!isObject(value)) {
|
|
247
|
+
issues.push(`${pathPrefix} must be an object`);
|
|
248
|
+
return { ...fallback };
|
|
249
|
+
}
|
|
250
|
+
const start = requiredPortField(value, "start", issues, pathPrefix, fallback.start);
|
|
251
|
+
const end = requiredPortField(value, "end", issues, pathPrefix, fallback.end);
|
|
252
|
+
if (start > end) {
|
|
253
|
+
issues.push(`${pathPrefix}.start must be less than or equal to ${pathPrefix}.end`);
|
|
254
|
+
}
|
|
255
|
+
return { start, end };
|
|
256
|
+
}
|
|
257
|
+
function parsePositiveIntegerArray(value, issues, pathPrefix, fallback) {
|
|
258
|
+
if (value === undefined) {
|
|
259
|
+
return [...fallback];
|
|
260
|
+
}
|
|
261
|
+
if (!Array.isArray(value) ||
|
|
262
|
+
value.length === 0 ||
|
|
263
|
+
!value.every((item) => Number.isInteger(item) && item > 0)) {
|
|
264
|
+
issues.push(`${pathPrefix} must be a non-empty array of positive integers`);
|
|
265
|
+
return [...fallback];
|
|
266
|
+
}
|
|
267
|
+
return [...new Set(value)];
|
|
268
|
+
}
|
|
269
|
+
function parseHomeImageCache(value, issues) {
|
|
270
|
+
const fallback = {
|
|
271
|
+
enabled: true,
|
|
272
|
+
networkPolicy: "online",
|
|
273
|
+
};
|
|
274
|
+
if (value === undefined) {
|
|
275
|
+
return fallback;
|
|
276
|
+
}
|
|
277
|
+
if (!isObject(value)) {
|
|
278
|
+
issues.push("home.imageCache must be an object");
|
|
279
|
+
return fallback;
|
|
280
|
+
}
|
|
281
|
+
const networkPolicy = value.networkPolicy ?? "online";
|
|
282
|
+
if (networkPolicy !== "online" && networkPolicy !== "local-only") {
|
|
283
|
+
issues.push("home.imageCache.networkPolicy must be one of online, local-only");
|
|
284
|
+
}
|
|
285
|
+
return {
|
|
286
|
+
enabled: booleanFieldWithDefault(value, "enabled", issues, "home.imageCache", true),
|
|
287
|
+
networkPolicy: networkPolicy === "local-only" ? "local-only" : "online",
|
|
288
|
+
};
|
|
289
|
+
}
|
|
290
|
+
function parseHomeDependencyRepositories(value, issues) {
|
|
291
|
+
const fallback = {
|
|
292
|
+
networkPolicy: "online",
|
|
293
|
+
};
|
|
294
|
+
if (value === undefined) {
|
|
295
|
+
return fallback;
|
|
296
|
+
}
|
|
297
|
+
if (!isObject(value)) {
|
|
298
|
+
issues.push("home.dependencyRepositories must be an object");
|
|
299
|
+
return fallback;
|
|
300
|
+
}
|
|
301
|
+
const networkPolicy = value.networkPolicy ?? "online";
|
|
302
|
+
if (networkPolicy !== "online" && networkPolicy !== "local-only") {
|
|
303
|
+
issues.push("home.dependencyRepositories.networkPolicy must be one of online, local-only");
|
|
304
|
+
}
|
|
305
|
+
return {
|
|
306
|
+
networkPolicy: networkPolicy === "local-only" ? "local-only" : "online",
|
|
307
|
+
};
|
|
308
|
+
}
|
|
309
|
+
function parseHome(value, issues) {
|
|
310
|
+
if (value === undefined) {
|
|
311
|
+
return undefined;
|
|
312
|
+
}
|
|
313
|
+
if (!isObject(value)) {
|
|
314
|
+
issues.push("home must be an object");
|
|
315
|
+
return undefined;
|
|
316
|
+
}
|
|
317
|
+
const imageCache = parseHomeImageCache(value.imageCache, issues);
|
|
318
|
+
const dependencyRepositories = parseHomeDependencyRepositories(value.dependencyRepositories, issues);
|
|
319
|
+
const path = optionalStringField(value, "path", issues, "home");
|
|
320
|
+
return {
|
|
321
|
+
...(path ? { path } : {}),
|
|
322
|
+
imageCache,
|
|
323
|
+
dependencyRepositories,
|
|
324
|
+
};
|
|
325
|
+
}
|
|
326
|
+
function parseProjectIdentity(value, issues) {
|
|
327
|
+
if (typeof value.id === "string" && value.id.trim().length > 0) {
|
|
328
|
+
return value.id;
|
|
329
|
+
}
|
|
330
|
+
issues.push("config.id must be a non-empty string");
|
|
331
|
+
return "";
|
|
332
|
+
}
|
|
333
|
+
function parseImageMcp(value, issues, pathPrefix) {
|
|
334
|
+
if (!isObject(value)) {
|
|
335
|
+
issues.push(`${pathPrefix}.mcp must be an object`);
|
|
336
|
+
return { loadScript: "" };
|
|
337
|
+
}
|
|
338
|
+
const loadPolicy = optionalPharoMcpLoadPolicyField(value, "loadPolicy", issues, `${pathPrefix}.mcp`);
|
|
339
|
+
return {
|
|
340
|
+
port: optionalPortField(value, "port", issues, `${pathPrefix}.mcp`),
|
|
341
|
+
loadScript: imageMcpLoadScriptField(value, "loadScript", issues, `${pathPrefix}.mcp`, loadPolicy),
|
|
342
|
+
startupMode: optionalPharoMcpStartupModeField(value, "startupMode", issues, `${pathPrefix}.mcp`),
|
|
343
|
+
loadPolicy,
|
|
344
|
+
};
|
|
345
|
+
}
|
|
346
|
+
function parsePharoMcpRepository(value, issues, pathPrefix) {
|
|
347
|
+
if (value === undefined) {
|
|
348
|
+
return undefined;
|
|
349
|
+
}
|
|
350
|
+
if (!isObject(value)) {
|
|
351
|
+
issues.push(`${pathPrefix}.repository must be an object`);
|
|
352
|
+
return undefined;
|
|
353
|
+
}
|
|
354
|
+
return {
|
|
355
|
+
githubUser: stringField(value, "githubUser", issues, `${pathPrefix}.repository`),
|
|
356
|
+
project: stringField(value, "project", issues, `${pathPrefix}.repository`),
|
|
357
|
+
commitish: stringField(value, "commitish", issues, `${pathPrefix}.repository`),
|
|
358
|
+
path: stringFieldAllowingEmpty(value, "path", issues, `${pathPrefix}.repository`),
|
|
359
|
+
baseline: stringField(value, "baseline", issues, `${pathPrefix}.repository`),
|
|
360
|
+
};
|
|
361
|
+
}
|
|
362
|
+
function parsePreparedImageMcp(value, issues, pathPrefix) {
|
|
363
|
+
if (!isObject(value)) {
|
|
364
|
+
issues.push(`${pathPrefix}.mcp must be an object`);
|
|
365
|
+
return { loadScript: "" };
|
|
366
|
+
}
|
|
367
|
+
return {
|
|
368
|
+
loadScript: stringField(value, "loadScript", issues, `${pathPrefix}.mcp`),
|
|
369
|
+
repository: parsePharoMcpRepository(value.repository, issues, `${pathPrefix}.mcp`),
|
|
370
|
+
startupMode: optionalPharoMcpStartupModeField(value, "startupMode", issues, `${pathPrefix}.mcp`),
|
|
371
|
+
};
|
|
372
|
+
}
|
|
373
|
+
function parseImageSshConfig(value, issues, pathPrefix) {
|
|
374
|
+
if (value === undefined) {
|
|
375
|
+
return undefined;
|
|
376
|
+
}
|
|
377
|
+
if (!isObject(value)) {
|
|
378
|
+
issues.push(`${pathPrefix}.ssh must be an object`);
|
|
379
|
+
return undefined;
|
|
380
|
+
}
|
|
381
|
+
const username = optionalStringField(value, "username", issues, `${pathPrefix}.ssh`);
|
|
382
|
+
const host = optionalStringField(value, "host", issues, `${pathPrefix}.ssh`);
|
|
383
|
+
const port = optionalPortField(value, "port", issues, `${pathPrefix}.ssh`);
|
|
384
|
+
if (port !== undefined && host === undefined) {
|
|
385
|
+
issues.push(`${pathPrefix}.ssh.host must be set when ${pathPrefix}.ssh.port is set`);
|
|
386
|
+
}
|
|
387
|
+
const hasPublicKey = value.publicKey !== undefined;
|
|
388
|
+
const hasPrivateKey = value.privateKey !== undefined;
|
|
389
|
+
const hasCustomKeys = hasPublicKey || hasPrivateKey;
|
|
390
|
+
const publicKey = hasCustomKeys
|
|
391
|
+
? stringField(value, "publicKey", issues, `${pathPrefix}.ssh`)
|
|
392
|
+
: undefined;
|
|
393
|
+
const privateKey = hasCustomKeys
|
|
394
|
+
? stringField(value, "privateKey", issues, `${pathPrefix}.ssh`)
|
|
395
|
+
: undefined;
|
|
396
|
+
return {
|
|
397
|
+
...(username ? { username } : {}),
|
|
398
|
+
...(host ? { host } : {}),
|
|
399
|
+
...(port ? { port } : {}),
|
|
400
|
+
...(publicKey !== undefined ? { publicKey } : {}),
|
|
401
|
+
...(privateKey !== undefined ? { privateKey } : {}),
|
|
402
|
+
};
|
|
403
|
+
}
|
|
404
|
+
function parseImagePlainCredentialsConfig(value, issues, pathPrefix) {
|
|
405
|
+
if (value === undefined) {
|
|
406
|
+
return undefined;
|
|
407
|
+
}
|
|
408
|
+
if (!isObject(value)) {
|
|
409
|
+
issues.push(`${pathPrefix}.plainCredentials must be an object`);
|
|
410
|
+
return undefined;
|
|
411
|
+
}
|
|
412
|
+
return {
|
|
413
|
+
username: stringField(value, "username", issues, `${pathPrefix}.plainCredentials`),
|
|
414
|
+
password: stringField(value, "password", issues, `${pathPrefix}.plainCredentials`),
|
|
415
|
+
};
|
|
416
|
+
}
|
|
417
|
+
function parseImageGit(value, issues, pathPrefix) {
|
|
418
|
+
if (value === undefined) {
|
|
419
|
+
return undefined;
|
|
420
|
+
}
|
|
421
|
+
if (!isObject(value)) {
|
|
422
|
+
issues.push(`${pathPrefix}.git must be an object`);
|
|
423
|
+
return undefined;
|
|
424
|
+
}
|
|
425
|
+
const transportValue = value.transport ?? "ssh";
|
|
426
|
+
const transport = transportValue === "ssh" ||
|
|
427
|
+
transportValue === "https" ||
|
|
428
|
+
transportValue === "http"
|
|
429
|
+
? transportValue
|
|
430
|
+
: "ssh";
|
|
431
|
+
if (transport !== transportValue) {
|
|
432
|
+
issues.push(`${pathPrefix}.git.transport must be one of ssh, https, http`);
|
|
433
|
+
}
|
|
434
|
+
const ssh = parseImageSshConfig(value.ssh, issues, `${pathPrefix}.git`);
|
|
435
|
+
const plainCredentials = parseImagePlainCredentialsConfig(value.plainCredentials, issues, `${pathPrefix}.git`);
|
|
436
|
+
if (transport === "ssh" && plainCredentials) {
|
|
437
|
+
issues.push(`${pathPrefix}.git.plainCredentials can only be used with https or http`);
|
|
438
|
+
}
|
|
439
|
+
if (transport !== "ssh" && ssh) {
|
|
440
|
+
issues.push(`${pathPrefix}.git.ssh can only be used with ssh`);
|
|
441
|
+
}
|
|
442
|
+
return {
|
|
443
|
+
transport,
|
|
444
|
+
...(ssh ? { ssh } : {}),
|
|
445
|
+
...(plainCredentials ? { plainCredentials } : {}),
|
|
446
|
+
};
|
|
447
|
+
}
|
|
448
|
+
function parseImageCreate(value, issues, pathPrefix) {
|
|
449
|
+
if (value === undefined) {
|
|
450
|
+
return undefined;
|
|
451
|
+
}
|
|
452
|
+
const createPath = `${pathPrefix}.create`;
|
|
453
|
+
if (!isObject(value)) {
|
|
454
|
+
issues.push(`${createPath} must be an object`);
|
|
455
|
+
return undefined;
|
|
456
|
+
}
|
|
457
|
+
const kindValue = value.kind ?? "template";
|
|
458
|
+
const kind = kindValue === "template" ? kindValue : "template";
|
|
459
|
+
if (kind !== kindValue) {
|
|
460
|
+
issues.push(`${createPath}.kind must be template`);
|
|
461
|
+
}
|
|
462
|
+
const profileId = optionalStringField(value, "profileId", issues, createPath);
|
|
463
|
+
const templateName = stringField(value, "templateName", issues, createPath);
|
|
464
|
+
const templateCategory = optionalStringField(value, "templateCategory", issues, createPath);
|
|
465
|
+
const role = optionalStringField(value, "role", issues, createPath);
|
|
466
|
+
const cleanupPolicy = optionalImageCreateCleanupPolicyField(value, "cleanupPolicy", issues, createPath);
|
|
467
|
+
return {
|
|
468
|
+
kind,
|
|
469
|
+
...(profileId ? { profileId } : {}),
|
|
470
|
+
templateName,
|
|
471
|
+
...(templateCategory ? { templateCategory } : {}),
|
|
472
|
+
...(role ? { role } : {}),
|
|
473
|
+
...(cleanupPolicy ? { cleanupPolicy } : {}),
|
|
474
|
+
};
|
|
475
|
+
}
|
|
476
|
+
function parseImagePreparedImage(value, issues, pathPrefix) {
|
|
477
|
+
if (value === undefined) {
|
|
478
|
+
return undefined;
|
|
479
|
+
}
|
|
480
|
+
const preparedPath = `${pathPrefix}.preparedImage`;
|
|
481
|
+
if (!isObject(value)) {
|
|
482
|
+
issues.push(`${preparedPath} must be an object`);
|
|
483
|
+
return undefined;
|
|
484
|
+
}
|
|
485
|
+
const copyModeValue = value.copyMode ?? "copy-on-open";
|
|
486
|
+
const copyMode = copyModeValue === "copy-on-open" ? copyModeValue : "copy-on-open";
|
|
487
|
+
if (copyMode !== copyModeValue) {
|
|
488
|
+
issues.push(`${preparedPath}.copyMode must be copy-on-open`);
|
|
489
|
+
}
|
|
490
|
+
return {
|
|
491
|
+
cacheId: stringField(value, "cacheId", issues, preparedPath),
|
|
492
|
+
copyMode,
|
|
493
|
+
};
|
|
494
|
+
}
|
|
495
|
+
function parseImageRepositoryIdentity(value, issues, pathPrefix) {
|
|
496
|
+
if (!isObject(value)) {
|
|
497
|
+
issues.push(`${pathPrefix}.repository must be an object`);
|
|
498
|
+
return { id: "" };
|
|
499
|
+
}
|
|
500
|
+
const componentId = optionalStringField(value, "componentId", issues, `${pathPrefix}.repository`);
|
|
501
|
+
const remoteUrl = optionalStringField(value, "remoteUrl", issues, `${pathPrefix}.repository`);
|
|
502
|
+
const originPath = optionalStringField(value, "originPath", issues, `${pathPrefix}.repository`);
|
|
503
|
+
if (!componentId && !remoteUrl && !originPath) {
|
|
504
|
+
issues.push(`${pathPrefix}.repository must set at least one of componentId, remoteUrl, or originPath`);
|
|
505
|
+
}
|
|
506
|
+
return {
|
|
507
|
+
id: stringField(value, "id", issues, `${pathPrefix}.repository`),
|
|
508
|
+
...(componentId ? { componentId } : {}),
|
|
509
|
+
...(remoteUrl ? { remoteUrl } : {}),
|
|
510
|
+
...(originPath ? { originPath } : {}),
|
|
511
|
+
};
|
|
512
|
+
}
|
|
513
|
+
function parseImageRepositoryWorkspaceMaterialization(value, issues, pathPrefix) {
|
|
514
|
+
const materializationPath = `${pathPrefix}.materialization`;
|
|
515
|
+
if (value === undefined) {
|
|
516
|
+
return { strategy: "copy" };
|
|
517
|
+
}
|
|
518
|
+
if (!isObject(value)) {
|
|
519
|
+
issues.push(`${materializationPath} must be an object`);
|
|
520
|
+
return { strategy: "copy" };
|
|
521
|
+
}
|
|
522
|
+
const strategyValue = value.strategy ?? "copy";
|
|
523
|
+
const strategy = strategyValue === "copy" ||
|
|
524
|
+
strategyValue === "git-worktree" ||
|
|
525
|
+
strategyValue === "clone"
|
|
526
|
+
? strategyValue
|
|
527
|
+
: "copy";
|
|
528
|
+
if (strategy !== strategyValue) {
|
|
529
|
+
issues.push(`${materializationPath}.strategy must be one of copy, git-worktree, clone`);
|
|
530
|
+
}
|
|
531
|
+
const path = optionalStringField(value, "path", issues, materializationPath);
|
|
532
|
+
return {
|
|
533
|
+
strategy,
|
|
534
|
+
...(path ? { path } : {}),
|
|
535
|
+
};
|
|
536
|
+
}
|
|
537
|
+
function parseImageRepositoryWorkspace(value, issues, workspacePath) {
|
|
538
|
+
if (value === undefined) {
|
|
539
|
+
return undefined;
|
|
540
|
+
}
|
|
541
|
+
if (!isObject(value)) {
|
|
542
|
+
issues.push(`${workspacePath} must be an object`);
|
|
543
|
+
return undefined;
|
|
544
|
+
}
|
|
545
|
+
const pharoVersion = optionalPositiveIntegerField(value, "pharoVersion", issues, workspacePath);
|
|
546
|
+
return {
|
|
547
|
+
repository: parseImageRepositoryIdentity(value.repository, issues, workspacePath),
|
|
548
|
+
sourceDirectory: stringField(value, "sourceDirectory", issues, workspacePath),
|
|
549
|
+
baseline: stringField(value, "baseline", issues, workspacePath),
|
|
550
|
+
loadGroup: optionalStringField(value, "loadGroup", issues, workspacePath),
|
|
551
|
+
...(pharoVersion !== undefined ? { pharoVersion } : {}),
|
|
552
|
+
templateName: optionalStringField(value, "templateName", issues, workspacePath),
|
|
553
|
+
templateCategory: optionalStringField(value, "templateCategory", issues, workspacePath),
|
|
554
|
+
branch: optionalStringField(value, "branch", issues, workspacePath),
|
|
555
|
+
baseBranch: optionalStringField(value, "baseBranch", issues, workspacePath),
|
|
556
|
+
baseCommit: optionalStringField(value, "baseCommit", issues, workspacePath),
|
|
557
|
+
materialization: parseImageRepositoryWorkspaceMaterialization(value.materialization, issues, workspacePath),
|
|
558
|
+
};
|
|
559
|
+
}
|
|
560
|
+
function parseImageRepositoryWorkspaces(value, issues, pathPrefix) {
|
|
561
|
+
if (value === undefined) {
|
|
562
|
+
return undefined;
|
|
563
|
+
}
|
|
564
|
+
const workspacesPath = `${pathPrefix}.repositoryWorkspaces`;
|
|
565
|
+
if (!Array.isArray(value)) {
|
|
566
|
+
issues.push(`${workspacesPath} must be an array`);
|
|
567
|
+
return undefined;
|
|
568
|
+
}
|
|
569
|
+
return value.map((workspace, index) => parseImageRepositoryWorkspace(workspace, issues, `${workspacesPath}[${index}]`) ?? {
|
|
570
|
+
repository: { id: "" },
|
|
571
|
+
sourceDirectory: "",
|
|
572
|
+
baseline: "",
|
|
573
|
+
materialization: { strategy: "copy" },
|
|
574
|
+
});
|
|
575
|
+
}
|
|
576
|
+
export function imageRepositoryWorkspaceConfigs(image) {
|
|
577
|
+
if (image.repositoryWorkspaces && image.repositoryWorkspaces.length > 0) {
|
|
578
|
+
return image.repositoryWorkspaces;
|
|
579
|
+
}
|
|
580
|
+
return image.repositoryWorkspace ? [image.repositoryWorkspace] : [];
|
|
581
|
+
}
|
|
582
|
+
function parseImages(value, issues) {
|
|
583
|
+
if (!Array.isArray(value)) {
|
|
584
|
+
issues.push("images must be an array");
|
|
585
|
+
return [];
|
|
586
|
+
}
|
|
587
|
+
return value.map((image, index) => {
|
|
588
|
+
const pathPrefix = `images[${index}]`;
|
|
589
|
+
if (!isObject(image)) {
|
|
590
|
+
issues.push(`${pathPrefix} must be an object`);
|
|
591
|
+
return {
|
|
592
|
+
id: "",
|
|
593
|
+
imageName: "",
|
|
594
|
+
active: false,
|
|
595
|
+
mcp: { loadScript: "" },
|
|
596
|
+
};
|
|
597
|
+
}
|
|
598
|
+
const repositoryWorkspace = parseImageRepositoryWorkspace(image.repositoryWorkspace, issues, `${pathPrefix}.repositoryWorkspace`);
|
|
599
|
+
const repositoryWorkspaces = parseImageRepositoryWorkspaces(image.repositoryWorkspaces, issues, pathPrefix);
|
|
600
|
+
const effectiveRepositoryWorkspaces = repositoryWorkspaces ??
|
|
601
|
+
(repositoryWorkspace ? [repositoryWorkspace] : undefined);
|
|
602
|
+
return {
|
|
603
|
+
id: stringField(image, "id", issues, pathPrefix),
|
|
604
|
+
imageName: stringField(image, "imageName", issues, pathPrefix),
|
|
605
|
+
active: booleanField(image, "active", issues, pathPrefix),
|
|
606
|
+
displayMode: optionalImageDisplayModeField(image, "displayMode", issues, pathPrefix),
|
|
607
|
+
mcp: parseImageMcp(image.mcp, issues, pathPrefix),
|
|
608
|
+
create: parseImageCreate(image.create, issues, pathPrefix),
|
|
609
|
+
preparedImage: parseImagePreparedImage(image.preparedImage, issues, pathPrefix),
|
|
610
|
+
repositoryWorkspace: repositoryWorkspace ?? effectiveRepositoryWorkspaces?.[0],
|
|
611
|
+
...(effectiveRepositoryWorkspaces
|
|
612
|
+
? { repositoryWorkspaces: effectiveRepositoryWorkspaces }
|
|
613
|
+
: {}),
|
|
614
|
+
git: parseImageGit(image.git, issues, pathPrefix),
|
|
615
|
+
};
|
|
616
|
+
});
|
|
617
|
+
}
|
|
618
|
+
function parsePreparedImageSource(value, issues, pathPrefix) {
|
|
619
|
+
if (!isObject(value)) {
|
|
620
|
+
issues.push(`${pathPrefix}.source must be an object`);
|
|
621
|
+
return {
|
|
622
|
+
kind: "template",
|
|
623
|
+
templateName: "",
|
|
624
|
+
};
|
|
625
|
+
}
|
|
626
|
+
const kindValue = value.kind ?? "template";
|
|
627
|
+
const kind = kindValue === "template" ? kindValue : "template";
|
|
628
|
+
if (kind !== kindValue) {
|
|
629
|
+
issues.push(`${pathPrefix}.source.kind must be template`);
|
|
630
|
+
}
|
|
631
|
+
return {
|
|
632
|
+
kind,
|
|
633
|
+
profileId: optionalStringField(value, "profileId", issues, `${pathPrefix}.source`),
|
|
634
|
+
templateName: stringField(value, "templateName", issues, `${pathPrefix}.source`),
|
|
635
|
+
templateCategory: optionalStringField(value, "templateCategory", issues, `${pathPrefix}.source`),
|
|
636
|
+
};
|
|
637
|
+
}
|
|
638
|
+
function parsePreparedImages(value, issues) {
|
|
639
|
+
if (value === undefined) {
|
|
640
|
+
return undefined;
|
|
641
|
+
}
|
|
642
|
+
if (!Array.isArray(value)) {
|
|
643
|
+
issues.push("preparedImages must be an array");
|
|
644
|
+
return undefined;
|
|
645
|
+
}
|
|
646
|
+
return value.map((preparedImage, index) => {
|
|
647
|
+
const pathPrefix = `preparedImages[${index}]`;
|
|
648
|
+
if (!isObject(preparedImage)) {
|
|
649
|
+
issues.push(`${pathPrefix} must be an object`);
|
|
650
|
+
return {
|
|
651
|
+
id: "",
|
|
652
|
+
imageName: "",
|
|
653
|
+
source: {
|
|
654
|
+
kind: "template",
|
|
655
|
+
templateName: "",
|
|
656
|
+
},
|
|
657
|
+
mcp: {
|
|
658
|
+
loadScript: "",
|
|
659
|
+
},
|
|
660
|
+
};
|
|
661
|
+
}
|
|
662
|
+
return {
|
|
663
|
+
id: stringField(preparedImage, "id", issues, pathPrefix),
|
|
664
|
+
imageName: stringField(preparedImage, "imageName", issues, pathPrefix),
|
|
665
|
+
source: parsePreparedImageSource(preparedImage.source, issues, pathPrefix),
|
|
666
|
+
mcp: parsePreparedImageMcp(preparedImage.mcp, issues, pathPrefix),
|
|
667
|
+
};
|
|
668
|
+
});
|
|
669
|
+
}
|
|
670
|
+
function parseRuntimeStateRoot(value, issues) {
|
|
671
|
+
if (value === undefined) {
|
|
672
|
+
return { ...defaultProjectRuntimePolicy().stateRoot };
|
|
673
|
+
}
|
|
674
|
+
if (!isObject(value)) {
|
|
675
|
+
issues.push("runtime.stateRoot must be an object");
|
|
676
|
+
return { ...defaultProjectRuntimePolicy().stateRoot };
|
|
677
|
+
}
|
|
678
|
+
const modeValue = value.mode ?? "project-local";
|
|
679
|
+
const mode = modeValue === "project-local" || modeValue === "external"
|
|
680
|
+
? modeValue
|
|
681
|
+
: "project-local";
|
|
682
|
+
if (mode !== modeValue) {
|
|
683
|
+
issues.push("runtime.stateRoot.mode must be one of project-local, external");
|
|
684
|
+
}
|
|
685
|
+
if (mode === "external") {
|
|
686
|
+
return {
|
|
687
|
+
mode,
|
|
688
|
+
path: stringField(value, "path", issues, "runtime.stateRoot"),
|
|
689
|
+
};
|
|
690
|
+
}
|
|
691
|
+
if (value.path !== undefined) {
|
|
692
|
+
issues.push("runtime.stateRoot.path can only be used when runtime.stateRoot.mode is \"external\"");
|
|
693
|
+
}
|
|
694
|
+
return { mode };
|
|
695
|
+
}
|
|
696
|
+
function parseProjectLocalGateway(value, issues) {
|
|
697
|
+
const defaultGateway = defaultProjectRuntimePolicy()
|
|
698
|
+
.gateway;
|
|
699
|
+
const port = optionalPortField(value, "port", issues, "runtime.gateway");
|
|
700
|
+
const hasPortRange = value.portRange !== undefined;
|
|
701
|
+
const parsedPortRange = hasPortRange
|
|
702
|
+
? parseRuntimePortRange(value.portRange, issues, "runtime.gateway.portRange", defaultGateway.portRange ?? { start: 8_133, end: 8_199 })
|
|
703
|
+
: undefined;
|
|
704
|
+
if (port !== undefined && hasPortRange) {
|
|
705
|
+
issues.push("runtime.gateway must use either port or portRange, not both");
|
|
706
|
+
}
|
|
707
|
+
const portPolicy = port !== undefined
|
|
708
|
+
? { port }
|
|
709
|
+
: { portRange: parsedPortRange ?? defaultGateway.portRange };
|
|
710
|
+
return {
|
|
711
|
+
mode: "project-local",
|
|
712
|
+
host: stringFieldWithDefault(value, "host", issues, "runtime.gateway", defaultGateway.host),
|
|
713
|
+
...portPolicy,
|
|
714
|
+
mcpPath: pathFieldWithDefault(value, "mcpPath", issues, "runtime.gateway", defaultGateway.mcpPath),
|
|
715
|
+
routeControlMcpPath: pathFieldWithDefault(value, "routeControlMcpPath", issues, "runtime.gateway", defaultGateway.routeControlMcpPath),
|
|
716
|
+
};
|
|
717
|
+
}
|
|
718
|
+
function parseSharedGateway(value, issues) {
|
|
719
|
+
return {
|
|
720
|
+
mode: "shared",
|
|
721
|
+
mcpUrl: urlField(value, "mcpUrl", issues, "runtime.gateway"),
|
|
722
|
+
routeControlMcpUrl: urlField(value, "routeControlMcpUrl", issues, "runtime.gateway"),
|
|
723
|
+
};
|
|
724
|
+
}
|
|
725
|
+
function parseRuntimeGateway(value, issues) {
|
|
726
|
+
if (value === undefined) {
|
|
727
|
+
return {
|
|
728
|
+
...defaultProjectRuntimePolicy().gateway,
|
|
729
|
+
};
|
|
730
|
+
}
|
|
731
|
+
if (!isObject(value)) {
|
|
732
|
+
issues.push("runtime.gateway must be an object");
|
|
733
|
+
return {
|
|
734
|
+
...defaultProjectRuntimePolicy().gateway,
|
|
735
|
+
};
|
|
736
|
+
}
|
|
737
|
+
const modeValue = value.mode ?? "project-local";
|
|
738
|
+
if (modeValue === "shared") {
|
|
739
|
+
return parseSharedGateway(value, issues);
|
|
740
|
+
}
|
|
741
|
+
if (modeValue !== "project-local") {
|
|
742
|
+
issues.push("runtime.gateway.mode must be one of project-local, shared");
|
|
743
|
+
}
|
|
744
|
+
return parseProjectLocalGateway(value, issues);
|
|
745
|
+
}
|
|
746
|
+
function parseRemoteNodeTargetMappings(value, issues, pathPrefix) {
|
|
747
|
+
if (value === undefined) {
|
|
748
|
+
return undefined;
|
|
749
|
+
}
|
|
750
|
+
if (!Array.isArray(value)) {
|
|
751
|
+
issues.push(`${pathPrefix}.targets must be an array`);
|
|
752
|
+
return undefined;
|
|
753
|
+
}
|
|
754
|
+
return value.map((item, index) => {
|
|
755
|
+
const itemPath = `${pathPrefix}.targets[${index}]`;
|
|
756
|
+
if (!isObject(item)) {
|
|
757
|
+
issues.push(`${itemPath} must be an object`);
|
|
758
|
+
return {
|
|
759
|
+
targetId: "",
|
|
760
|
+
};
|
|
761
|
+
}
|
|
762
|
+
const remoteTargetId = optionalStringField(item, "remoteTargetId", issues, itemPath);
|
|
763
|
+
return {
|
|
764
|
+
targetId: stringField(item, "targetId", issues, itemPath),
|
|
765
|
+
...(remoteTargetId ? { remoteTargetId } : {}),
|
|
766
|
+
};
|
|
767
|
+
});
|
|
768
|
+
}
|
|
769
|
+
function parseRemoteNodeWorkspaceMappings(value, issues, pathPrefix) {
|
|
770
|
+
if (value === undefined) {
|
|
771
|
+
return undefined;
|
|
772
|
+
}
|
|
773
|
+
if (!Array.isArray(value)) {
|
|
774
|
+
issues.push(`${pathPrefix}.workspaces must be an array`);
|
|
775
|
+
return undefined;
|
|
776
|
+
}
|
|
777
|
+
return value.map((item, index) => {
|
|
778
|
+
const itemPath = `${pathPrefix}.workspaces[${index}]`;
|
|
779
|
+
if (!isObject(item)) {
|
|
780
|
+
issues.push(`${itemPath} must be an object`);
|
|
781
|
+
return {
|
|
782
|
+
workspaceId: "",
|
|
783
|
+
};
|
|
784
|
+
}
|
|
785
|
+
const remoteWorkspaceId = optionalStringField(item, "remoteWorkspaceId", issues, itemPath);
|
|
786
|
+
const remoteProjectPath = optionalStringField(item, "remoteProjectPath", issues, itemPath);
|
|
787
|
+
const targets = parseRemoteNodeTargetMappings(item.targets, issues, itemPath);
|
|
788
|
+
return {
|
|
789
|
+
workspaceId: stringField(item, "workspaceId", issues, itemPath),
|
|
790
|
+
...(remoteWorkspaceId ? { remoteWorkspaceId } : {}),
|
|
791
|
+
...(remoteProjectPath ? { remoteProjectPath } : {}),
|
|
792
|
+
...(targets ? { targets } : {}),
|
|
793
|
+
};
|
|
794
|
+
});
|
|
795
|
+
}
|
|
796
|
+
function parseRemoteNodes(value, issues) {
|
|
797
|
+
if (value === undefined) {
|
|
798
|
+
return undefined;
|
|
799
|
+
}
|
|
800
|
+
if (!Array.isArray(value)) {
|
|
801
|
+
issues.push("runtime.remoteNodes must be an array");
|
|
802
|
+
return undefined;
|
|
803
|
+
}
|
|
804
|
+
return value.map((item, index) => {
|
|
805
|
+
const itemPath = `runtime.remoteNodes[${index}]`;
|
|
806
|
+
if (!isObject(item)) {
|
|
807
|
+
issues.push(`${itemPath} must be an object`);
|
|
808
|
+
return {
|
|
809
|
+
id: "",
|
|
810
|
+
projectMcpUrl: "",
|
|
811
|
+
gatewayMcpUrl: "",
|
|
812
|
+
};
|
|
813
|
+
}
|
|
814
|
+
const workspaces = parseRemoteNodeWorkspaceMappings(item.workspaces, issues, itemPath);
|
|
815
|
+
const parentNodeId = optionalStringField(item, "parentNodeId", issues, itemPath);
|
|
816
|
+
return {
|
|
817
|
+
id: stringField(item, "id", issues, itemPath),
|
|
818
|
+
...(parentNodeId ? { parentNodeId } : {}),
|
|
819
|
+
projectMcpUrl: urlField(item, "projectMcpUrl", issues, itemPath),
|
|
820
|
+
gatewayMcpUrl: urlField(item, "gatewayMcpUrl", issues, itemPath),
|
|
821
|
+
...(workspaces ? { workspaces } : {}),
|
|
822
|
+
};
|
|
823
|
+
});
|
|
824
|
+
}
|
|
825
|
+
function parseImagePortCoordination(value, issues) {
|
|
826
|
+
if (value === undefined) {
|
|
827
|
+
return { ...defaultProjectRuntimePolicy().imagePorts.coordination };
|
|
828
|
+
}
|
|
829
|
+
if (!isObject(value)) {
|
|
830
|
+
issues.push("runtime.imagePorts.coordination must be an object");
|
|
831
|
+
return { ...defaultProjectRuntimePolicy().imagePorts.coordination };
|
|
832
|
+
}
|
|
833
|
+
const defaultMode = defaultProjectRuntimePolicy().imagePorts.coordination.mode;
|
|
834
|
+
const modeValue = value.mode ?? defaultMode;
|
|
835
|
+
const mode = modeValue === "project-state" || modeValue === "host-local"
|
|
836
|
+
? modeValue
|
|
837
|
+
: defaultMode;
|
|
838
|
+
if (mode !== modeValue) {
|
|
839
|
+
issues.push("runtime.imagePorts.coordination.mode must be one of project-state, host-local");
|
|
840
|
+
}
|
|
841
|
+
const root = optionalStringField(value, "root", issues, "runtime.imagePorts.coordination");
|
|
842
|
+
if (root && mode !== "host-local") {
|
|
843
|
+
issues.push("runtime.imagePorts.coordination.root can only be used when mode is \"host-local\"");
|
|
844
|
+
}
|
|
845
|
+
return {
|
|
846
|
+
mode,
|
|
847
|
+
...(root && mode === "host-local" ? { root } : {}),
|
|
848
|
+
};
|
|
849
|
+
}
|
|
850
|
+
function parseImagePortPolicy(value, issues) {
|
|
851
|
+
const defaults = defaultProjectRuntimePolicy().imagePorts;
|
|
852
|
+
if (value === undefined) {
|
|
853
|
+
return {
|
|
854
|
+
allocation: defaults.allocation,
|
|
855
|
+
range: { ...defaults.range },
|
|
856
|
+
coordination: { ...defaults.coordination },
|
|
857
|
+
};
|
|
858
|
+
}
|
|
859
|
+
if (!isObject(value)) {
|
|
860
|
+
issues.push("runtime.imagePorts must be an object");
|
|
861
|
+
return {
|
|
862
|
+
allocation: defaults.allocation,
|
|
863
|
+
range: { ...defaults.range },
|
|
864
|
+
coordination: { ...defaults.coordination },
|
|
865
|
+
};
|
|
866
|
+
}
|
|
867
|
+
const allocationValue = value.allocation ?? defaults.allocation;
|
|
868
|
+
const allocation = allocationValue === "configured-or-dynamic" ||
|
|
869
|
+
allocationValue === "dynamic-only" ||
|
|
870
|
+
allocationValue === "configured-only"
|
|
871
|
+
? allocationValue
|
|
872
|
+
: defaults.allocation;
|
|
873
|
+
if (allocation !== allocationValue) {
|
|
874
|
+
issues.push("runtime.imagePorts.allocation must be one of " +
|
|
875
|
+
"configured-or-dynamic, dynamic-only, configured-only");
|
|
876
|
+
}
|
|
877
|
+
return {
|
|
878
|
+
allocation,
|
|
879
|
+
range: value.range === undefined
|
|
880
|
+
? { ...defaults.range }
|
|
881
|
+
: parseRuntimePortRange(value.range, issues, "runtime.imagePorts.range", defaults.range),
|
|
882
|
+
coordination: parseImagePortCoordination(value.coordination, issues),
|
|
883
|
+
};
|
|
884
|
+
}
|
|
885
|
+
function parseLauncherProfilePolicy(value, issues) {
|
|
886
|
+
if (value === undefined) {
|
|
887
|
+
return { ...defaultProjectRuntimePolicy().launcherProfile };
|
|
888
|
+
}
|
|
889
|
+
if (!isObject(value)) {
|
|
890
|
+
issues.push("runtime.launcherProfile must be an object");
|
|
891
|
+
return { ...defaultProjectRuntimePolicy().launcherProfile };
|
|
892
|
+
}
|
|
893
|
+
const modeValue = value.mode ?? "project-owned";
|
|
894
|
+
const mode = modeValue === "project-owned" || modeValue === "external"
|
|
895
|
+
? modeValue
|
|
896
|
+
: "project-owned";
|
|
897
|
+
if (mode !== modeValue) {
|
|
898
|
+
issues.push("runtime.launcherProfile.mode must be one of project-owned, external");
|
|
899
|
+
}
|
|
900
|
+
const name = optionalStringField(value, "name", issues, "runtime.launcherProfile");
|
|
901
|
+
const root = optionalStringField(value, "root", issues, "runtime.launcherProfile");
|
|
902
|
+
const templateCatalog = parseLauncherTemplateCatalogPolicy(value.templateCatalog, issues);
|
|
903
|
+
return {
|
|
904
|
+
mode,
|
|
905
|
+
...(name ? { name } : {}),
|
|
906
|
+
...(root ? { root } : {}),
|
|
907
|
+
...(templateCatalog
|
|
908
|
+
? {
|
|
909
|
+
templateCatalog,
|
|
910
|
+
}
|
|
911
|
+
: {}),
|
|
912
|
+
};
|
|
913
|
+
}
|
|
914
|
+
function parseLauncherTemplateCatalogPolicy(value, issues) {
|
|
915
|
+
if (value === undefined) {
|
|
916
|
+
return undefined;
|
|
917
|
+
}
|
|
918
|
+
const pathPrefix = "runtime.launcherProfile.templateCatalog";
|
|
919
|
+
if (!isObject(value)) {
|
|
920
|
+
issues.push(`${pathPrefix} must be an object`);
|
|
921
|
+
return undefined;
|
|
922
|
+
}
|
|
923
|
+
const pathValue = optionalStringField(value, "path", issues, pathPrefix);
|
|
924
|
+
const sourceValue = value.source ?? (pathValue ? "path" : "user-or-server");
|
|
925
|
+
const source = sourceValue === "user-or-server" ||
|
|
926
|
+
sourceValue === "user" ||
|
|
927
|
+
sourceValue === "server" ||
|
|
928
|
+
sourceValue === "path" ||
|
|
929
|
+
sourceValue === "none"
|
|
930
|
+
? sourceValue
|
|
931
|
+
: "user-or-server";
|
|
932
|
+
if (source !== sourceValue) {
|
|
933
|
+
issues.push(`${pathPrefix}.source must be one of user-or-server, user, server, path, none`);
|
|
934
|
+
}
|
|
935
|
+
if (source === "path" && !pathValue) {
|
|
936
|
+
issues.push(`${pathPrefix}.path must be set when source is path`);
|
|
937
|
+
}
|
|
938
|
+
const serverSourcesUrl = optionalUrlField(value, "serverSourcesUrl", issues, pathPrefix);
|
|
939
|
+
return {
|
|
940
|
+
source,
|
|
941
|
+
...(pathValue ? { path: pathValue } : {}),
|
|
942
|
+
...(serverSourcesUrl ? { serverSourcesUrl } : {}),
|
|
943
|
+
};
|
|
944
|
+
}
|
|
945
|
+
function parsePharoMcpPolicy(value, issues) {
|
|
946
|
+
const defaults = defaultProjectRuntimePolicy().pharoMcp;
|
|
947
|
+
if (value === undefined) {
|
|
948
|
+
return {
|
|
949
|
+
metadataKey: defaults.metadataKey,
|
|
950
|
+
supportedMajorVersions: [...defaults.supportedMajorVersions],
|
|
951
|
+
};
|
|
952
|
+
}
|
|
953
|
+
if (!isObject(value)) {
|
|
954
|
+
issues.push("runtime.pharoMcp must be an object");
|
|
955
|
+
return {
|
|
956
|
+
metadataKey: defaults.metadataKey,
|
|
957
|
+
supportedMajorVersions: [...defaults.supportedMajorVersions],
|
|
958
|
+
};
|
|
959
|
+
}
|
|
960
|
+
return {
|
|
961
|
+
metadataKey: stringFieldWithDefault(value, "metadataKey", issues, "runtime.pharoMcp", defaults.metadataKey),
|
|
962
|
+
supportedMajorVersions: parsePositiveIntegerArray(value.supportedMajorVersions, issues, "runtime.pharoMcp.supportedMajorVersions", defaults.supportedMajorVersions),
|
|
963
|
+
};
|
|
964
|
+
}
|
|
965
|
+
function parseWorkspaceImagePolicy(value, issues) {
|
|
966
|
+
if (value === undefined) {
|
|
967
|
+
return undefined;
|
|
968
|
+
}
|
|
969
|
+
const pathPrefix = "runtime.workspaceImages";
|
|
970
|
+
if (!isObject(value)) {
|
|
971
|
+
issues.push(`${pathPrefix} must be an object`);
|
|
972
|
+
return undefined;
|
|
973
|
+
}
|
|
974
|
+
const maxCount = optionalPositiveIntegerField(value, "maxCount", issues, pathPrefix);
|
|
975
|
+
return {
|
|
976
|
+
...(maxCount !== undefined ? { maxCount } : {}),
|
|
977
|
+
};
|
|
978
|
+
}
|
|
979
|
+
function parseRuntimePolicy(value, issues) {
|
|
980
|
+
if (value === undefined) {
|
|
981
|
+
return defaultProjectRuntimePolicy();
|
|
982
|
+
}
|
|
983
|
+
if (!isObject(value)) {
|
|
984
|
+
issues.push("runtime must be an object");
|
|
985
|
+
return defaultProjectRuntimePolicy();
|
|
986
|
+
}
|
|
987
|
+
const scopeValue = value.scope ?? "project";
|
|
988
|
+
if (scopeValue !== "project") {
|
|
989
|
+
issues.push("runtime.scope must be \"project\"");
|
|
990
|
+
}
|
|
991
|
+
const workspaceImages = parseWorkspaceImagePolicy(value.workspaceImages, issues);
|
|
992
|
+
const remoteNodes = parseRemoteNodes(value.remoteNodes, issues);
|
|
993
|
+
const nodeId = optionalStringField(value, "nodeId", issues, "runtime");
|
|
994
|
+
return {
|
|
995
|
+
scope: "project",
|
|
996
|
+
...(nodeId ? { nodeId } : {}),
|
|
997
|
+
stateRoot: parseRuntimeStateRoot(value.stateRoot, issues),
|
|
998
|
+
gateway: parseRuntimeGateway(value.gateway, issues),
|
|
999
|
+
imagePorts: parseImagePortPolicy(value.imagePorts, issues),
|
|
1000
|
+
...(workspaceImages ? { workspaceImages } : {}),
|
|
1001
|
+
...(remoteNodes ? { remoteNodes } : {}),
|
|
1002
|
+
launcherProfile: parseLauncherProfilePolicy(value.launcherProfile, issues),
|
|
1003
|
+
pharoMcp: parsePharoMcpPolicy(value.pharoMcp, issues),
|
|
1004
|
+
};
|
|
1005
|
+
}
|
|
1006
|
+
function collectDuplicates(values, label, issues) {
|
|
1007
|
+
const seen = new Set();
|
|
1008
|
+
for (const value of values) {
|
|
1009
|
+
if (!value) {
|
|
1010
|
+
continue;
|
|
1011
|
+
}
|
|
1012
|
+
if (seen.has(value)) {
|
|
1013
|
+
issues.push(`${label} must be unique: ${value}`);
|
|
1014
|
+
}
|
|
1015
|
+
else {
|
|
1016
|
+
seen.add(value);
|
|
1017
|
+
}
|
|
1018
|
+
}
|
|
1019
|
+
}
|
|
1020
|
+
function collectDuplicatePorts(images, issues) {
|
|
1021
|
+
const seen = new Set();
|
|
1022
|
+
for (const image of images) {
|
|
1023
|
+
if (projectMcpStartupMode(image.mcp) === "disabled") {
|
|
1024
|
+
continue;
|
|
1025
|
+
}
|
|
1026
|
+
const port = image.mcp.port;
|
|
1027
|
+
if (!port) {
|
|
1028
|
+
continue;
|
|
1029
|
+
}
|
|
1030
|
+
if (seen.has(port)) {
|
|
1031
|
+
issues.push(`image MCP ports must be unique: ${port}`);
|
|
1032
|
+
}
|
|
1033
|
+
else {
|
|
1034
|
+
seen.add(port);
|
|
1035
|
+
}
|
|
1036
|
+
}
|
|
1037
|
+
}
|
|
1038
|
+
function collectDuplicateActiveRepositoryWorkspacePaths(images, issues) {
|
|
1039
|
+
const seen = new Set();
|
|
1040
|
+
for (const image of images) {
|
|
1041
|
+
if (!image.active) {
|
|
1042
|
+
continue;
|
|
1043
|
+
}
|
|
1044
|
+
for (const workspace of imageRepositoryWorkspaceConfigs(image)) {
|
|
1045
|
+
const path = workspace.materialization.path;
|
|
1046
|
+
if (!path) {
|
|
1047
|
+
continue;
|
|
1048
|
+
}
|
|
1049
|
+
if (seen.has(path)) {
|
|
1050
|
+
issues.push(`active image repository workspace paths must be unique: ${path}`);
|
|
1051
|
+
}
|
|
1052
|
+
else {
|
|
1053
|
+
seen.add(path);
|
|
1054
|
+
}
|
|
1055
|
+
}
|
|
1056
|
+
}
|
|
1057
|
+
}
|
|
1058
|
+
function collectDuplicateRepositoryWorkspaceIds(images, issues) {
|
|
1059
|
+
images.forEach((image, imageIndex) => {
|
|
1060
|
+
const seen = new Set();
|
|
1061
|
+
for (const workspace of imageRepositoryWorkspaceConfigs(image)) {
|
|
1062
|
+
const repositoryId = workspace.repository.id;
|
|
1063
|
+
if (seen.has(repositoryId)) {
|
|
1064
|
+
issues.push(`images[${imageIndex}] repository workspace ids must be unique: ${repositoryId}`);
|
|
1065
|
+
}
|
|
1066
|
+
else {
|
|
1067
|
+
seen.add(repositoryId);
|
|
1068
|
+
}
|
|
1069
|
+
}
|
|
1070
|
+
});
|
|
1071
|
+
}
|
|
1072
|
+
function validateImagePortPolicy(config, issues) {
|
|
1073
|
+
const allocation = resolveProjectRuntimePolicy(config).imagePorts.allocation;
|
|
1074
|
+
config.images.forEach((image, index) => {
|
|
1075
|
+
if (projectMcpStartupMode(image.mcp) === "disabled") {
|
|
1076
|
+
return;
|
|
1077
|
+
}
|
|
1078
|
+
if (allocation === "dynamic-only" && image.mcp.port !== undefined) {
|
|
1079
|
+
issues.push(`images[${index}].mcp.port cannot be used when ` +
|
|
1080
|
+
`runtime.imagePorts.allocation is "dynamic-only"`);
|
|
1081
|
+
}
|
|
1082
|
+
if (allocation === "configured-only" && image.mcp.port === undefined) {
|
|
1083
|
+
issues.push(`images[${index}].mcp.port is required when ` +
|
|
1084
|
+
`runtime.imagePorts.allocation is "configured-only"`);
|
|
1085
|
+
}
|
|
1086
|
+
});
|
|
1087
|
+
}
|
|
1088
|
+
function validatePreparedImageReferences(config, issues) {
|
|
1089
|
+
const preparedImageIds = new Set(config.preparedImages?.map((preparedImage) => preparedImage.id) ?? []);
|
|
1090
|
+
config.images.forEach((image, index) => {
|
|
1091
|
+
const cacheId = image.preparedImage?.cacheId;
|
|
1092
|
+
if (cacheId && !preparedImageIds.has(cacheId)) {
|
|
1093
|
+
issues.push(`images[${index}].preparedImage.cacheId must reference a preparedImages id: ${cacheId}`);
|
|
1094
|
+
}
|
|
1095
|
+
});
|
|
1096
|
+
}
|
|
1097
|
+
function validateRemoteNodeConfig(config, issues) {
|
|
1098
|
+
const runtime = resolveProjectRuntimePolicy(config);
|
|
1099
|
+
const localNodeId = runtime.nodeId ?? projectConfigId(config);
|
|
1100
|
+
const remoteNodes = runtime.remoteNodes ?? [];
|
|
1101
|
+
collectDuplicates(remoteNodes.map((remoteNode) => remoteNode.id), "remote node ids", issues);
|
|
1102
|
+
remoteNodes.forEach((remoteNode, remoteNodeIndex) => {
|
|
1103
|
+
if (remoteNode.id === localNodeId) {
|
|
1104
|
+
issues.push(`runtime.remoteNodes[${remoteNodeIndex}].id must differ from runtime node id: ${localNodeId}`);
|
|
1105
|
+
}
|
|
1106
|
+
if (remoteNode.parentNodeId === remoteNode.id) {
|
|
1107
|
+
issues.push(`runtime.remoteNodes[${remoteNodeIndex}].parentNodeId must not equal its own id: ${remoteNode.id}`);
|
|
1108
|
+
}
|
|
1109
|
+
else if (remoteNode.parentNodeId !== undefined &&
|
|
1110
|
+
remoteNode.parentNodeId !== localNodeId) {
|
|
1111
|
+
issues.push(`runtime.remoteNodes[${remoteNodeIndex}].parentNodeId must be omitted or match runtime node id ${localNodeId} for flat-tree topology`);
|
|
1112
|
+
}
|
|
1113
|
+
collectDuplicates(remoteNode.workspaces?.map((workspace) => workspace.workspaceId) ?? [], `runtime.remoteNodes[${remoteNodeIndex}].workspaces.workspaceId`, issues);
|
|
1114
|
+
remoteNode.workspaces?.forEach((workspace, workspaceIndex) => {
|
|
1115
|
+
collectDuplicates(workspace.targets?.map((target) => target.targetId) ?? [], `runtime.remoteNodes[${remoteNodeIndex}].workspaces[${workspaceIndex}].targets.targetId`, issues);
|
|
1116
|
+
});
|
|
1117
|
+
});
|
|
1118
|
+
}
|
|
1119
|
+
export function parseProjectConfig(value) {
|
|
1120
|
+
const issues = [];
|
|
1121
|
+
if (!isObject(value)) {
|
|
1122
|
+
throw new ProjectConfigError("Invalid Plexus project config", [
|
|
1123
|
+
"config must be an object",
|
|
1124
|
+
]);
|
|
1125
|
+
}
|
|
1126
|
+
const home = parseHome(value.home, issues);
|
|
1127
|
+
const preparedImages = parsePreparedImages(value.preparedImages, issues);
|
|
1128
|
+
const config = {
|
|
1129
|
+
id: parseProjectIdentity(value, issues),
|
|
1130
|
+
name: stringField(value, "name", issues, "config"),
|
|
1131
|
+
...(home ? { home } : {}),
|
|
1132
|
+
runtime: parseRuntimePolicy(value.runtime, issues),
|
|
1133
|
+
...(preparedImages ? { preparedImages } : {}),
|
|
1134
|
+
images: parseImages(value.images, issues),
|
|
1135
|
+
};
|
|
1136
|
+
collectDuplicates(config.images.map((image) => image.id), "image ids", issues);
|
|
1137
|
+
collectDuplicates(config.images.map((image) => image.imageName), "image names", issues);
|
|
1138
|
+
collectDuplicates(config.preparedImages?.map((preparedImage) => preparedImage.id) ?? [], "prepared image ids", issues);
|
|
1139
|
+
collectDuplicates(config.preparedImages?.map((preparedImage) => preparedImage.imageName) ?? [], "prepared image names", issues);
|
|
1140
|
+
collectDuplicatePorts(config.images, issues);
|
|
1141
|
+
collectDuplicateRepositoryWorkspaceIds(config.images, issues);
|
|
1142
|
+
collectDuplicateActiveRepositoryWorkspacePaths(config.images, issues);
|
|
1143
|
+
validateImagePortPolicy(config, issues);
|
|
1144
|
+
validatePreparedImageReferences(config, issues);
|
|
1145
|
+
validateRemoteNodeConfig(config, issues);
|
|
1146
|
+
if (issues.length > 0) {
|
|
1147
|
+
throw new ProjectConfigError("Invalid Plexus project config", issues);
|
|
1148
|
+
}
|
|
1149
|
+
return config;
|
|
1150
|
+
}
|
|
1151
|
+
export function projectConfigPath(projectRoot) {
|
|
1152
|
+
return joinPathLike(projectRoot, plexusProjectConfigFileName);
|
|
1153
|
+
}
|
|
1154
|
+
export function loadProjectConfig(projectRoot) {
|
|
1155
|
+
const filePath = projectConfigPath(projectRoot);
|
|
1156
|
+
const raw = fs.readFileSync(filePath, "utf8");
|
|
1157
|
+
return parseProjectConfig(JSON.parse(raw));
|
|
1158
|
+
}
|
|
1159
|
+
//# sourceMappingURL=projectConfig.js.map
|