@orkestrel/scaffold 0.0.49 → 0.0.50

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.
@@ -6,6 +6,7 @@ import { EmitterHooks } from '@orkestrel/emitter';
6
6
  import { EmitterInterface } from '@orkestrel/emitter';
7
7
  import { Guard } from '@orkestrel/contract';
8
8
  import { HostFile } from '@orkestrel/scaffold';
9
+ import { ManifestRegionSet } from '@orkestrel/scaffold';
9
10
  import { Mirror } from '@orkestrel/scaffold';
10
11
  import { Plan } from '@orkestrel/scaffold';
11
12
  import { Release } from '@orkestrel/scaffold';
@@ -428,6 +429,24 @@ export declare function isInventory(value: unknown): value is readonly unknown[]
428
429
  */
429
430
  export declare const isManifestEntry: Guard<ManifestEntry>;
430
431
 
432
+ /**
433
+ * Narrow a value to one {@link ManifestRegionSet}.
434
+ *
435
+ * @remarks
436
+ * The whole closed record a manifest-writing method accepts, so a caller
437
+ * naming a region the writer does not carry is refused before any byte moves.
438
+ * Each region is bounded by the same collection law its own list guard applies.
439
+ *
440
+ * @example
441
+ * ```ts
442
+ * import { isManifestRegionSet } from '@orkestrel/scaffold/server'
443
+ *
444
+ * isManifestRegionSet({ pins: { runtime: [], development: [] }, scripts: [] }) // true
445
+ * isManifestRegionSet({ pins: { runtime: [], development: [] } }) // false
446
+ * ```
447
+ */
448
+ export declare const isManifestRegionSet: Guard<ManifestRegionSet>;
449
+
431
450
  /**
432
451
  * Narrow a value to the materializer's initial listener record.
433
452
  *
@@ -1059,24 +1078,30 @@ export declare class Materializer implements MaterializerInterface {
1059
1078
  */
1060
1079
  catalog(entries: readonly CatalogEntry[], target: string): MaterializeResult;
1061
1080
  /**
1062
- * Rewrite the declared dependency ranges the caller names in the target's manifest.
1081
+ * Rewrite the manifest regions the caller names in the target's manifest.
1063
1082
  *
1064
- * @param dependencies - The names and ranges the manifest must declare.
1083
+ * @param regions - The dependency ranges and script values the manifest must declare.
1065
1084
  * @param target - The directory to write into.
1066
- * @returns The manifest path, written when a declared range moved and skipped otherwise.
1085
+ * @returns The manifest path, written when a named region moved and skipped otherwise.
1067
1086
  * @throws {@link ScaffoldError} coded `INVALID` when an argument is not the
1068
1087
  * exact shape or names a package the manifest does not declare, `TARGET` when
1069
1088
  * the manifest is unreadable, `WRITE` when the write cannot be staged or
1070
1089
  * committed, and `DESTROYED` after teardown.
1071
1090
  *
1072
1091
  * @remarks
1073
- * No other part of the manifest is read back out or rewritten, so a consumer's
1074
- * own description, keywords, scripts, and formatting survive the call. Only a
1075
- * range already declared is rewritten: inserting a package would mean
1076
- * re-serializing the whole manifest, which is exactly the edit this verb
1077
- * promises not to make, so an undeclared name is refused by name instead.
1092
+ * No other part of the manifest is read back out or rewritten. The method
1093
+ * never reads or writes `peerDependencies` or `peerDependenciesMeta`. Only a
1094
+ * range already declared in its named writable section is rewritten, so an
1095
+ * undeclared name is refused instead of inserted.
1096
+ *
1097
+ * The regions refuse differently because their targets differ. A range
1098
+ * the manifest does not declare is the caller's mistake and throws. A script
1099
+ * holding a value the region does not accept is the workspace author's own
1100
+ * chain, so the script region is skipped without a byte moving and the range
1101
+ * region is still written. The advisory channel reports what the maintainer
1102
+ * must paste.
1078
1103
  */
1079
- declare(dependencies: readonly Dependency[], target: string): MaterializeResult;
1104
+ declare(regions: ManifestRegionSet, target: string): MaterializeResult;
1080
1105
  /**
1081
1106
  * Re-derive and delete the tracked files the plan does not own.
1082
1107
  *
@@ -1213,17 +1238,19 @@ export declare class Materializer implements MaterializerInterface {
1213
1238
  */
1214
1239
  catalog(entries: readonly CatalogEntry[], target: string): MaterializeResult;
1215
1240
  /**
1216
- * Rewrite the declared dependency ranges the caller names in the target's manifest.
1241
+ * Rewrite the manifest regions the caller names in the target's manifest.
1217
1242
  *
1218
- * @param dependencies - The names and ranges the manifest must declare.
1243
+ * @param regions - The dependency ranges and script values the manifest must declare.
1219
1244
  * @param target - The directory to write into.
1220
- * @returns The manifest path, written when a declared range moved and skipped otherwise.
1245
+ * @returns The manifest path, written when a named region moved and skipped otherwise.
1221
1246
  *
1222
1247
  * @remarks
1223
- * No other part of the manifest is read back out or rewritten, so a
1224
- * consumer's own description, keywords, and scripts survive the call.
1248
+ * No other part of the manifest is read back out or rewritten. The method
1249
+ * never reads or writes `peerDependencies` or `peerDependenciesMeta`. A
1250
+ * script region naming a value the manifest does not accept is skipped
1251
+ * without a byte moving, and the range region is written regardless.
1225
1252
  */
1226
- declare(dependencies: readonly Dependency[], target: string): MaterializeResult;
1253
+ declare(regions: ManifestRegionSet, target: string): MaterializeResult;
1227
1254
  /**
1228
1255
  * Re-derive and delete the tracked files the plan does not own.
1229
1256
  *
@@ -6,6 +6,7 @@ import { EmitterHooks } from '@orkestrel/emitter';
6
6
  import { EmitterInterface } from '@orkestrel/emitter';
7
7
  import { Guard } from '@orkestrel/contract';
8
8
  import { HostFile } from '@orkestrel/scaffold';
9
+ import { ManifestRegionSet } from '@orkestrel/scaffold';
9
10
  import { Mirror } from '@orkestrel/scaffold';
10
11
  import { Plan } from '@orkestrel/scaffold';
11
12
  import { Release } from '@orkestrel/scaffold';
@@ -428,6 +429,24 @@ export declare function isInventory(value: unknown): value is readonly unknown[]
428
429
  */
429
430
  export declare const isManifestEntry: Guard<ManifestEntry>;
430
431
 
432
+ /**
433
+ * Narrow a value to one {@link ManifestRegionSet}.
434
+ *
435
+ * @remarks
436
+ * The whole closed record a manifest-writing method accepts, so a caller
437
+ * naming a region the writer does not carry is refused before any byte moves.
438
+ * Each region is bounded by the same collection law its own list guard applies.
439
+ *
440
+ * @example
441
+ * ```ts
442
+ * import { isManifestRegionSet } from '@orkestrel/scaffold/server'
443
+ *
444
+ * isManifestRegionSet({ pins: { runtime: [], development: [] }, scripts: [] }) // true
445
+ * isManifestRegionSet({ pins: { runtime: [], development: [] } }) // false
446
+ * ```
447
+ */
448
+ export declare const isManifestRegionSet: Guard<ManifestRegionSet>;
449
+
431
450
  /**
432
451
  * Narrow a value to the materializer's initial listener record.
433
452
  *
@@ -1059,24 +1078,30 @@ export declare class Materializer implements MaterializerInterface {
1059
1078
  */
1060
1079
  catalog(entries: readonly CatalogEntry[], target: string): MaterializeResult;
1061
1080
  /**
1062
- * Rewrite the declared dependency ranges the caller names in the target's manifest.
1081
+ * Rewrite the manifest regions the caller names in the target's manifest.
1063
1082
  *
1064
- * @param dependencies - The names and ranges the manifest must declare.
1083
+ * @param regions - The dependency ranges and script values the manifest must declare.
1065
1084
  * @param target - The directory to write into.
1066
- * @returns The manifest path, written when a declared range moved and skipped otherwise.
1085
+ * @returns The manifest path, written when a named region moved and skipped otherwise.
1067
1086
  * @throws {@link ScaffoldError} coded `INVALID` when an argument is not the
1068
1087
  * exact shape or names a package the manifest does not declare, `TARGET` when
1069
1088
  * the manifest is unreadable, `WRITE` when the write cannot be staged or
1070
1089
  * committed, and `DESTROYED` after teardown.
1071
1090
  *
1072
1091
  * @remarks
1073
- * No other part of the manifest is read back out or rewritten, so a consumer's
1074
- * own description, keywords, scripts, and formatting survive the call. Only a
1075
- * range already declared is rewritten: inserting a package would mean
1076
- * re-serializing the whole manifest, which is exactly the edit this verb
1077
- * promises not to make, so an undeclared name is refused by name instead.
1092
+ * No other part of the manifest is read back out or rewritten. The method
1093
+ * never reads or writes `peerDependencies` or `peerDependenciesMeta`. Only a
1094
+ * range already declared in its named writable section is rewritten, so an
1095
+ * undeclared name is refused instead of inserted.
1096
+ *
1097
+ * The regions refuse differently because their targets differ. A range
1098
+ * the manifest does not declare is the caller's mistake and throws. A script
1099
+ * holding a value the region does not accept is the workspace author's own
1100
+ * chain, so the script region is skipped without a byte moving and the range
1101
+ * region is still written. The advisory channel reports what the maintainer
1102
+ * must paste.
1078
1103
  */
1079
- declare(dependencies: readonly Dependency[], target: string): MaterializeResult;
1104
+ declare(regions: ManifestRegionSet, target: string): MaterializeResult;
1080
1105
  /**
1081
1106
  * Re-derive and delete the tracked files the plan does not own.
1082
1107
  *
@@ -1213,17 +1238,19 @@ export declare class Materializer implements MaterializerInterface {
1213
1238
  */
1214
1239
  catalog(entries: readonly CatalogEntry[], target: string): MaterializeResult;
1215
1240
  /**
1216
- * Rewrite the declared dependency ranges the caller names in the target's manifest.
1241
+ * Rewrite the manifest regions the caller names in the target's manifest.
1217
1242
  *
1218
- * @param dependencies - The names and ranges the manifest must declare.
1243
+ * @param regions - The dependency ranges and script values the manifest must declare.
1219
1244
  * @param target - The directory to write into.
1220
- * @returns The manifest path, written when a declared range moved and skipped otherwise.
1245
+ * @returns The manifest path, written when a named region moved and skipped otherwise.
1221
1246
  *
1222
1247
  * @remarks
1223
- * No other part of the manifest is read back out or rewritten, so a
1224
- * consumer's own description, keywords, and scripts survive the call.
1248
+ * No other part of the manifest is read back out or rewritten. The method
1249
+ * never reads or writes `peerDependencies` or `peerDependenciesMeta`. A
1250
+ * script region naming a value the manifest does not accept is skipped
1251
+ * without a byte moving, and the range region is written regardless.
1225
1252
  */
1226
- declare(dependencies: readonly Dependency[], target: string): MaterializeResult;
1253
+ declare(regions: ManifestRegionSet, target: string): MaterializeResult;
1227
1254
  /**
1228
1255
  * Re-derive and delete the tracked files the plan does not own.
1229
1256
  *
@@ -1,5 +1,5 @@
1
1
  import { andOf, arrayOf, attempt, boundsOf, holds, isArray, isBoolean, isError, isFunction, isInteger, isRecord, isString, parseJSON, parseJSONAs, parseStringField, recordOf, stringOf, unionOf } from "@orkestrel/contract";
2
- import { CATALOG_AGENT_PATH, CONTROL_CHARACTER_PATTERN, EXECUTABLE_PATHS, HOST_INVENTORY_PATH, HOST_PATHS, MAX_ARTIFACT_BYTES, MAX_COLLECTION_ITEMS, MAX_DEPENDENCY_NAME_LENGTH, MAX_MANIFEST_BYTES, MAX_PATH_LENGTH, MAX_RANGE_LENGTH, MAX_REGISTRY_BYTES, MAX_TOTAL_ARTIFACT_BYTES, MAX_TOTAL_REGISTRY_BYTES, ScaffoldError, WORKSPACE_OWNED_PATHS, bytesToHex, catalogToLayers, cloneValue, compareVersions, computeBytes, contentToHex, extractRangeMajor, extractVersion, inferGroup, isAudit, isCatalogEntry, isCollection, isDeferredPath, isDependency, isDependencyName, isHex, isMirror, isPath, isPlan, isSnapshot, matchesDriftReachability, matchesRange, nameToGuide, planToFindings, replaceManifestRanges } from "../core/index.js";
2
+ import { CATALOG_AGENT_PATH, CONTROL_CHARACTER_PATTERN, EXECUTABLE_PATHS, HOST_INVENTORY_PATH, HOST_PATHS, MAX_ARTIFACT_BYTES, MAX_COLLECTION_ITEMS, MAX_DEPENDENCY_NAME_LENGTH, MAX_MANIFEST_BYTES, MAX_PATH_LENGTH, MAX_RANGE_LENGTH, MAX_REGISTRY_BYTES, MAX_TOTAL_ARTIFACT_BYTES, MAX_TOTAL_REGISTRY_BYTES, ScaffoldError, WORKSPACE_OWNED_PATHS, bytesToHex, catalogToLayers, cloneValue, compareVersions, computeBytes, contentToHex, extractRangeMajor, extractVersion, inferGroup, isAudit, isCatalogEntry, isCollection, isDeferredPath, isDependency, isDependencyName, isHex, isManifestScript, isMirror, isPath, isPlan, isSnapshot, matchesDriftReachability, matchesRange, nameToGuide, planToFindings, replaceManifestRanges, replaceManifestScripts } from "../core/index.js";
3
3
  import { createHash, randomUUID } from "node:crypto";
4
4
  import { chmodSync, closeSync, constants, copyFileSync, fstatSync, linkSync, lstatSync, mkdirSync, mkdtempSync, openSync, opendirSync, readSync, readdirSync, readlinkSync, realpathSync, renameSync, rmSync, rmdirSync, writeFileSync } from "node:fs";
5
5
  import { tmpdir } from "node:os";
@@ -291,6 +291,29 @@ var isDependencyNames = andOf(isCollection, arrayOf(isDependencyName));
291
291
  var isPaths = andOf(isCollection, arrayOf(isPath));
292
292
  /** Narrow a value to a bounded list of declared runtime dependencies. */
293
293
  var isDependencies = andOf(isCollection, arrayOf(isDependency));
294
+ /**
295
+ * Narrow a value to one {@link ManifestRegionSet}.
296
+ *
297
+ * @remarks
298
+ * The whole closed record a manifest-writing method accepts, so a caller
299
+ * naming a region the writer does not carry is refused before any byte moves.
300
+ * Each region is bounded by the same collection law its own list guard applies.
301
+ *
302
+ * @example
303
+ * ```ts
304
+ * import { isManifestRegionSet } from '@orkestrel/scaffold/server'
305
+ *
306
+ * isManifestRegionSet({ pins: { runtime: [], development: [] }, scripts: [] }) // true
307
+ * isManifestRegionSet({ pins: { runtime: [], development: [] } }) // false
308
+ * ```
309
+ */
310
+ var isManifestRegionSet = recordOf({
311
+ pins: recordOf({
312
+ runtime: isDependencies,
313
+ development: isDependencies
314
+ }),
315
+ scripts: andOf(isCollection, arrayOf(isManifestScript))
316
+ });
294
317
  /** Narrow a value to a bounded list of fetched guide mirrors. */
295
318
  var isMirrors = andOf(isCollection, arrayOf(isMirror));
296
319
  /** Narrow a value to a bounded list of fleet catalog rows. */
@@ -2785,26 +2808,32 @@ var Materializer = class Materializer {
2785
2808
  return this.#rewrite(directory, CATALOG_AGENT_PATH, MAX_ARTIFACT_BYTES, this.#recatalog(accepted));
2786
2809
  }
2787
2810
  /**
2788
- * Rewrite the declared dependency ranges the caller names in the target's manifest.
2811
+ * Rewrite the manifest regions the caller names in the target's manifest.
2789
2812
  *
2790
- * @param dependencies - The names and ranges the manifest must declare.
2813
+ * @param regions - The dependency ranges and script values the manifest must declare.
2791
2814
  * @param target - The directory to write into.
2792
- * @returns The manifest path, written when a declared range moved and skipped otherwise.
2815
+ * @returns The manifest path, written when a named region moved and skipped otherwise.
2793
2816
  * @throws {@link ScaffoldError} coded `INVALID` when an argument is not the
2794
2817
  * exact shape or names a package the manifest does not declare, `TARGET` when
2795
2818
  * the manifest is unreadable, `WRITE` when the write cannot be staged or
2796
2819
  * committed, and `DESTROYED` after teardown.
2797
2820
  *
2798
2821
  * @remarks
2799
- * No other part of the manifest is read back out or rewritten, so a consumer's
2800
- * own description, keywords, scripts, and formatting survive the call. Only a
2801
- * range already declared is rewritten: inserting a package would mean
2802
- * re-serializing the whole manifest, which is exactly the edit this verb
2803
- * promises not to make, so an undeclared name is refused by name instead.
2822
+ * No other part of the manifest is read back out or rewritten. The method
2823
+ * never reads or writes `peerDependencies` or `peerDependenciesMeta`. Only a
2824
+ * range already declared in its named writable section is rewritten, so an
2825
+ * undeclared name is refused instead of inserted.
2826
+ *
2827
+ * The regions refuse differently because their targets differ. A range
2828
+ * the manifest does not declare is the caller's mistake and throws. A script
2829
+ * holding a value the region does not accept is the workspace author's own
2830
+ * chain, so the script region is skipped without a byte moving and the range
2831
+ * region is still written. The advisory channel reports what the maintainer
2832
+ * must paste.
2804
2833
  */
2805
- declare(dependencies, target) {
2834
+ declare(regions, target) {
2806
2835
  this.#assertAlive();
2807
- const accepted = this.#accept(dependencies, isDependencies, "dependencies");
2836
+ const accepted = this.#accept(regions, isManifestRegionSet, "regions");
2808
2837
  const directory = this.#accept(target, isFilesystemPath, "target");
2809
2838
  return this.#rewrite(directory, "package.json", MAX_MANIFEST_BYTES, this.#redeclare(accepted));
2810
2839
  }
@@ -3341,12 +3370,14 @@ var Materializer = class Materializer {
3341
3370
  #cell(note) {
3342
3371
  return note.replaceAll("|", "\\|").replaceAll(/\s+/gu, " ").trim();
3343
3372
  }
3344
- #redeclare(dependencies) {
3373
+ #redeclare(regions) {
3345
3374
  return (text) => {
3346
- const manifest = replaceManifestRanges(text, dependencies);
3347
- if (manifest !== void 0) return manifest;
3348
- const missing = dependencies.find((dependency) => !text.includes(JSON.stringify(dependency.name)));
3349
- throw this.#error("INVALID", `The manifest does not declare ${missing?.name ?? "a requested package"}, so its range cannot be rewritten.`, missing === void 0 ? void 0 : { name: missing.name });
3375
+ const manifest = replaceManifestRanges(text, regions.pins);
3376
+ if (manifest === void 0) {
3377
+ const missing = [...regions.pins.runtime, ...regions.pins.development].find((dependency) => !text.includes(JSON.stringify(dependency.name)));
3378
+ throw this.#error("INVALID", `The manifest does not declare ${missing?.name ?? "a requested package"}, so its range cannot be rewritten.`, missing === void 0 ? void 0 : { name: missing.name });
3379
+ }
3380
+ return replaceManifestScripts(manifest, regions.scripts) ?? manifest;
3350
3381
  };
3351
3382
  }
3352
3383
  #finish(result) {
@@ -4105,6 +4136,6 @@ var Upstream = class Upstream {
4105
4136
  }
4106
4137
  };
4107
4138
  //#endregion
4108
- export { BRANCH_PATTERN, DIGEST_PATTERN, DRIVE_PATTERN, INVALID_SEGMENT_CHARACTER_PATTERN, MANIFEST_NAME, MAX_BRANCH_LENGTH, MAX_ENDPOINT_LENGTH, MAX_INVENTORY_PATHS, MAX_PATH_DEPTH, MAX_PATH_SEGMENT_BYTES, MAX_UPSTREAM_CONCURRENCY, MAX_UPSTREAM_RETRIES, MAX_UPSTREAM_TIMEOUT, Materializer, RESERVED_SEGMENT_PATTERN, Upstream, WriteTransaction, computeDigest, computeFileDigest, computeManifestDigest, filesToHost, hexToDigest, isBranch, isCatalogEntries, isDependencies, isDependencyNames, isDigest, isEndpoint, isExactCaseFile, isFilesystemPath, isHost, isHostManifest, isInventory, isManifestEntry, isMaterializerHooks, isMaterializerOptions, isMirrors, isPaths, isPhysicalDirectory, isPhysicalFile, isTimeout, isUpstreamHooks, isUpstreamOptions, isVacant, isWorktree, listDirectories, listFiles, matchesAnchor, matchesExecutablePath, matchesExpectation, matchesGitPath, matchesMissingPath, matchesPrecondition, matchesProtectedPath, matchesSensitivePath, pathToStorage, readAnchor, readExpectation, readFileHex, readFileText, readHostFloor, readHostManifest, readManifestEntry, readSnapshot, resolveContainedPath, resolveRealPath, stageBytes, stageHost, stageInventory };
4139
+ export { BRANCH_PATTERN, DIGEST_PATTERN, DRIVE_PATTERN, INVALID_SEGMENT_CHARACTER_PATTERN, MANIFEST_NAME, MAX_BRANCH_LENGTH, MAX_ENDPOINT_LENGTH, MAX_INVENTORY_PATHS, MAX_PATH_DEPTH, MAX_PATH_SEGMENT_BYTES, MAX_UPSTREAM_CONCURRENCY, MAX_UPSTREAM_RETRIES, MAX_UPSTREAM_TIMEOUT, Materializer, RESERVED_SEGMENT_PATTERN, Upstream, WriteTransaction, computeDigest, computeFileDigest, computeManifestDigest, filesToHost, hexToDigest, isBranch, isCatalogEntries, isDependencies, isDependencyNames, isDigest, isEndpoint, isExactCaseFile, isFilesystemPath, isHost, isHostManifest, isInventory, isManifestEntry, isManifestRegionSet, isMaterializerHooks, isMaterializerOptions, isMirrors, isPaths, isPhysicalDirectory, isPhysicalFile, isTimeout, isUpstreamHooks, isUpstreamOptions, isVacant, isWorktree, listDirectories, listFiles, matchesAnchor, matchesExecutablePath, matchesExpectation, matchesGitPath, matchesMissingPath, matchesPrecondition, matchesProtectedPath, matchesSensitivePath, pathToStorage, readAnchor, readExpectation, readFileHex, readFileText, readHostFloor, readHostManifest, readManifestEntry, readSnapshot, resolveContainedPath, resolveRealPath, stageBytes, stageHost, stageInventory };
4109
4140
 
4110
4141
  //# sourceMappingURL=index.js.map