@le-space/rootfs 0.1.18 → 0.1.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # @shared-aleph/rootfs
1
+ # @le-space/rootfs
2
2
 
3
3
  Shared rootfs contract parsing, reference profile assets, and build helpers.
4
4
 
package/index.d.ts CHANGED
@@ -131,6 +131,13 @@ interface RootfsManifestOutputPaths {
131
131
  copyTargetPath?: string;
132
132
  versionedTargetPath?: string;
133
133
  }
134
+ interface RootfsManifestState {
135
+ manifest: RootfsManifest | null;
136
+ valid: boolean;
137
+ errors: string[];
138
+ }
139
+ declare const ITEM_HASH_RE: RegExp;
140
+ declare function validateRootfsManifest(manifest: RootfsManifest | null): RootfsManifestState;
134
141
  declare function rootfsSourceSizeBytesFromIpfsAddResponse(content: string): number | undefined;
135
142
  declare function createRootfsManifest(plan: RootfsBuildPlan, contract: RootfsContract, options?: RootfsManifestOptions): RootfsManifest;
136
143
  declare function resolveRootfsManifestOutputPaths(plan: RootfsBuildPlan): RootfsManifestOutputPaths;
@@ -246,4 +253,4 @@ declare function createRootfsScriptCommand(buildPlan: RootfsBuildPlan, reference
246
253
  declare function buildRootfs(buildPlan: RootfsBuildPlan, deps: RootfsCommandRunner, availability: RootfsToolchainAvailability, options?: RootfsExecutionPlanOptions): Promise<RootfsExecutionResult>;
247
254
  declare function publishRootfs(buildPlan: RootfsBuildPlan, deps: RootfsExecutorDependencies, options?: RootfsPublishOptions): Promise<RootfsPublishExecutionResult>;
248
255
 
249
- export { type RootfsBuildDriver, type RootfsBuildOptions, type RootfsBuildPipeline, type RootfsBuildPlan, type RootfsCommandPlan, type RootfsCommandRunner, type RootfsContract, type RootfsContractManifest, type RootfsContractPort, type RootfsContractRootfs, type RootfsContractServices, type RootfsContractSource, type RootfsContractState, type RootfsExecutedCommand, type RootfsExecutionPlan, type RootfsExecutionPlanOptions, type RootfsExecutionResult, type RootfsExecutorDependencies, type RootfsFileReader, type RootfsFinalizeOptions, type RootfsFinalizeResult, type RootfsIpfsAddEntry, type RootfsManifest, type RootfsManifestOptions, type RootfsManifestOutputPaths, type RootfsPublicationArtifacts, type RootfsPublicationResult, type RootfsPublishExecutionResult, type RootfsPublishOptions, type RootfsStoreMessageResponse, type RootfsStoreMessageStatus, type RootfsToolchainAvailability, buildRootfs, contractShellEnv, createDockerRootfsBuildPipeline, createDockerRootfsExecutionPlan, createHostRootfsBuildPipeline, createHostRootfsExecutionPlan, createRootfsBuildPipeline, createRootfsBuildPlan, createRootfsManifest, createRootfsPublicationResult, createRootfsScriptCommand, deriveRootfsVersion, extractRootfsCid, extractRootfsSourceSizeBytes, finalizeRootfsBuildPipeline, parseIpfsAddResponse, parseRootfsContract, parseStoreMessageResponse, parseStoreMessageStatus, publicationArtifacts, publishRootfs, readRootfsContractFile, referenceProfileContractPath, referenceProfileRoot, referenceProfileRootfsDir, resolveRootfsManifestOutputPaths, rootfsBuildShellEnv, rootfsSourceSizeBytesFromIpfsAddResponse, selectRootfsExecutionPlan, serializeRootfsManifest, summarizeStoreMessageFailure, validateRootfsContract };
256
+ export { ITEM_HASH_RE, type RootfsBuildDriver, type RootfsBuildOptions, type RootfsBuildPipeline, type RootfsBuildPlan, type RootfsCommandPlan, type RootfsCommandRunner, type RootfsContract, type RootfsContractManifest, type RootfsContractPort, type RootfsContractRootfs, type RootfsContractServices, type RootfsContractSource, type RootfsContractState, type RootfsExecutedCommand, type RootfsExecutionPlan, type RootfsExecutionPlanOptions, type RootfsExecutionResult, type RootfsExecutorDependencies, type RootfsFileReader, type RootfsFinalizeOptions, type RootfsFinalizeResult, type RootfsIpfsAddEntry, type RootfsManifest, type RootfsManifestOptions, type RootfsManifestOutputPaths, type RootfsManifestState, type RootfsPublicationArtifacts, type RootfsPublicationResult, type RootfsPublishExecutionResult, type RootfsPublishOptions, type RootfsStoreMessageResponse, type RootfsStoreMessageStatus, type RootfsToolchainAvailability, buildRootfs, contractShellEnv, createDockerRootfsBuildPipeline, createDockerRootfsExecutionPlan, createHostRootfsBuildPipeline, createHostRootfsExecutionPlan, createRootfsBuildPipeline, createRootfsBuildPlan, createRootfsManifest, createRootfsPublicationResult, createRootfsScriptCommand, deriveRootfsVersion, extractRootfsCid, extractRootfsSourceSizeBytes, finalizeRootfsBuildPipeline, parseIpfsAddResponse, parseRootfsContract, parseStoreMessageResponse, parseStoreMessageStatus, publicationArtifacts, publishRootfs, readRootfsContractFile, referenceProfileContractPath, referenceProfileRoot, referenceProfileRootfsDir, resolveRootfsManifestOutputPaths, rootfsBuildShellEnv, rootfsSourceSizeBytesFromIpfsAddResponse, selectRootfsExecutionPlan, serializeRootfsManifest, summarizeStoreMessageFailure, validateRootfsContract, validateRootfsManifest };
package/index.js CHANGED
@@ -239,6 +239,57 @@ function rootfsBuildShellEnv(plan) {
239
239
 
240
240
  // src/manifest.ts
241
241
  import { dirname, extname, isAbsolute, join } from "path";
242
+ var ITEM_HASH_RE = /^[a-fA-F0-9]{64}$/u;
243
+ function validateRootfsManifest(manifest) {
244
+ const errors = [];
245
+ if (!manifest) {
246
+ return { manifest, valid: false, errors: ["Rootfs manifest is missing."] };
247
+ }
248
+ if (!manifest.version) errors.push("Rootfs manifest version is missing.");
249
+ if (manifest.rootfsInstallStrategy != null && manifest.rootfsInstallStrategy !== "thin" && manifest.rootfsInstallStrategy !== "prebaked") {
250
+ errors.push('Rootfs install strategy must be "thin" or "prebaked" when provided.');
251
+ }
252
+ if (manifest.requiresBootstrapNetwork != null && typeof manifest.requiresBootstrapNetwork !== "boolean") {
253
+ errors.push("Rootfs bootstrap network flag must be a boolean when provided.");
254
+ }
255
+ if (manifest.bootstrapSummary != null && !manifest.bootstrapSummary.trim()) {
256
+ errors.push("Rootfs bootstrap summary must be non-empty when provided.");
257
+ }
258
+ if (manifest.requiredPortForwards != null) {
259
+ if (!Array.isArray(manifest.requiredPortForwards)) {
260
+ errors.push("Rootfs required port forwards must be an array when provided.");
261
+ } else {
262
+ manifest.requiredPortForwards.forEach((entry, index) => {
263
+ if (!entry || typeof entry !== "object") {
264
+ errors.push(`Rootfs required port forward #${index + 1} must be an object.`);
265
+ return;
266
+ }
267
+ if (!Number.isInteger(entry.port) || entry.port < 1 || entry.port > 65535) {
268
+ errors.push(`Rootfs required port forward #${index + 1} must use a TCP/UDP port between 1 and 65535.`);
269
+ }
270
+ if (entry.tcp !== true && entry.udp !== true) {
271
+ errors.push(`Rootfs required port forward #${index + 1} must enable TCP or UDP.`);
272
+ }
273
+ if (entry.purpose != null && (typeof entry.purpose !== "string" || !entry.purpose.trim())) {
274
+ errors.push(`Rootfs required port forward #${index + 1} purpose must be non-empty when provided.`);
275
+ }
276
+ });
277
+ }
278
+ }
279
+ if (!ITEM_HASH_RE.test(manifest.rootfsItemHash || "")) {
280
+ errors.push("Rootfs ItemHash must be a 64 character hex value.");
281
+ }
282
+ if (!Number.isInteger(manifest.rootfsSizeMiB) || manifest.rootfsSizeMiB <= 0) {
283
+ errors.push("Rootfs size must be a positive MiB integer.");
284
+ }
285
+ if (manifest.rootfsSourceSizeBytes != null && (!Number.isInteger(manifest.rootfsSourceSizeBytes) || manifest.rootfsSourceSizeBytes <= 0)) {
286
+ errors.push("Rootfs source size must be a positive byte integer when provided.");
287
+ }
288
+ if (!manifest.createdAt || Number.isNaN(new Date(manifest.createdAt).getTime())) {
289
+ errors.push("Rootfs creation date is missing or invalid.");
290
+ }
291
+ return { manifest, valid: errors.length === 0, errors };
292
+ }
242
293
  function rootfsSourceSizeBytesFromIpfsAddResponse(content) {
243
294
  const lines = content.split(/\r?\n/u).map((line) => line.trim()).filter(Boolean);
244
295
  if (lines.length === 0) {
@@ -620,6 +671,7 @@ async function publishRootfs(buildPlan, deps, options = {}) {
620
671
  };
621
672
  }
622
673
  export {
674
+ ITEM_HASH_RE,
623
675
  buildRootfs,
624
676
  contractShellEnv,
625
677
  createDockerRootfsBuildPipeline,
@@ -651,5 +703,6 @@ export {
651
703
  selectRootfsExecutionPlan,
652
704
  serializeRootfsManifest,
653
705
  summarizeStoreMessageFailure,
654
- validateRootfsContract
706
+ validateRootfsContract,
707
+ validateRootfsManifest
655
708
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@le-space/rootfs",
3
- "version": "0.1.18",
3
+ "version": "0.1.20",
4
4
  "description": "Shared rootfs contract parsing, reference profile assets, and build helpers.",
5
5
  "license": "MIT",
6
6
  "type": "module",