@forgeax/engine-pack 0.1.4 → 0.1.7

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/build.mjs CHANGED
@@ -1,5 +1,5 @@
1
- import { ok, err, catalogOperationsFor, authoringCapabilityForAssetKind, MATERIAL_TEXTURE_SLOTS, projectCookProductEvidence, projectAssetEvidence, validateSourceOverrideMap, catalogEntryDigest, PACK_ERROR_HINTS, AssetError, ImportError } from '@forgeax/engine-types';
2
- import { join, basename, dirname, resolve, relative, posix, extname } from 'path';
1
+ import { ok, err, catalogOperationsFor, authoringCapabilityForAssetKind, PACK_ERROR_HINTS, MATERIAL_TEXTURE_SLOTS, projectCookProductEvidence, projectAssetEvidence, validateSourceOverrideMap, catalogEntryDigest, AssetError, ImportError } from '@forgeax/engine-types';
2
+ import { join, dirname, resolve, posix, basename, relative, extname } from 'path';
3
3
  import { uuidv7obj } from 'uuidv7';
4
4
  import { readFileSync, existsSync } from 'fs';
5
5
  import { createHash } from 'crypto';
@@ -9547,77 +9547,112 @@ function serializeCookedMaterialRecord(record) {
9547
9547
  function serializeMaterialCookReceipt(receipt) {
9548
9548
  return JSON.stringify(jsonValue({ ...receipt, sourceClosure: unique(receipt.sourceClosure) }));
9549
9549
  }
9550
- function invalid2(field) {
9550
+ function invalid2(field, actual2) {
9551
9551
  return err({
9552
9552
  code: "material-cook-record-invalid",
9553
- expected: "a complete material-cook/2 record with derived layout identity",
9553
+ expected: "a complete material-cook/3 record with layered identity and provenance",
9554
9554
  hint: "re-cook the material and publish its record, artifact, references, and receipt together",
9555
- detail: { field }
9555
+ detail: {
9556
+ field,
9557
+ ...actual2 === void 0 ? {} : { actual: actual2 },
9558
+ action: "inspect the named field and recook the material generation"
9559
+ }
9560
+ });
9561
+ }
9562
+ var IDENTITY_FIELDS = [
9563
+ "materialContractDigest",
9564
+ "sourceRevision",
9565
+ "sourceClosureDigest",
9566
+ "layoutIdentity",
9567
+ "programIdentity",
9568
+ "pipelineIdentity",
9569
+ "materialPublicationIdentity",
9570
+ "cookIdentity",
9571
+ "compilerFingerprint",
9572
+ "artifactDigest"
9573
+ ];
9574
+ function isGeneration(value) {
9575
+ return typeof value === "number" && Number.isSafeInteger(value) && value >= 1;
9576
+ }
9577
+ function validateIdentity(value) {
9578
+ if (value === null || typeof value !== "object") return invalid2("receipt.identity", value);
9579
+ const candidate = value;
9580
+ for (const field of IDENTITY_FIELDS) {
9581
+ if (typeof candidate[field] !== "string" || candidate[field].length === 0) {
9582
+ return invalid2(`receipt.identity.${field}`, candidate[field]);
9583
+ }
9584
+ }
9585
+ if (candidate.wasm === null || typeof candidate.wasm !== "object") {
9586
+ return invalid2("receipt.identity.wasm", candidate.wasm);
9587
+ }
9588
+ const wasm = candidate.wasm;
9589
+ for (const field of ["sourceContentKey", "artifactSha256", "glueSha256"]) {
9590
+ if (typeof wasm[field] !== "string" || wasm[field].length === 0) {
9591
+ return invalid2(`receipt.identity.wasm.${field}`, wasm[field]);
9592
+ }
9593
+ }
9594
+ for (const field of ["valueGeneration", "dependencyGeneration", "cookGeneration"]) {
9595
+ if (!isGeneration(candidate[field]))
9596
+ return invalid2(`receipt.identity.${field}`, candidate[field]);
9597
+ }
9598
+ return ok({
9599
+ ...candidate,
9600
+ wasm
9556
9601
  });
9557
9602
  }
9558
9603
  function validateMaterialCookReceipt(value, expected = {}) {
9559
9604
  if (value === null || typeof value !== "object") return invalid2("receipt");
9560
9605
  const candidate = value;
9561
- if (candidate.schemaVersion !== "material-cook/2") return invalid2("receipt.schemaVersion");
9562
- if (typeof candidate.layoutIdentity !== "string" || candidate.layoutIdentity.length === 0) {
9563
- return invalid2("receipt.layoutIdentity");
9564
- }
9606
+ if (candidate.schemaVersion !== "material-cook/3")
9607
+ return invalid2("receipt.schemaVersion", candidate.schemaVersion);
9608
+ const identityResult = validateIdentity(candidate.identity);
9609
+ if (!identityResult.ok) return identityResult;
9610
+ const identity = identityResult.value;
9565
9611
  if (candidate.derivedInterface === null || typeof candidate.derivedInterface !== "object") {
9566
- return invalid2("receipt.derivedInterface");
9612
+ return invalid2("receipt.derivedInterface", candidate.derivedInterface);
9567
9613
  }
9568
9614
  const derivedInterface = candidate.derivedInterface;
9569
- if (derivedInterface.layoutIdentity !== candidate.layoutIdentity) {
9570
- return invalid2("receipt.derivedInterface.layoutIdentity");
9571
- }
9572
- for (const field of [
9573
- "sourceClosure",
9574
- "profile",
9575
- "compilerVersion",
9576
- "inputDigest",
9577
- "outputDigest"
9578
- ]) {
9615
+ if (derivedInterface.layoutIdentity !== identity.layoutIdentity) {
9616
+ return invalid2("receipt.derivedInterface.layoutIdentity", derivedInterface.layoutIdentity);
9617
+ }
9618
+ for (const field of ["sourceClosure", "profile", "compilerVersion"]) {
9579
9619
  const fieldValue = candidate[field];
9580
9620
  if (field === "sourceClosure" && !Array.isArray(fieldValue) || field !== "sourceClosure" && typeof fieldValue !== "string") {
9581
- return invalid2(`receipt.${field}`);
9621
+ return invalid2(`receipt.${field}`, fieldValue);
9582
9622
  }
9583
9623
  }
9584
9624
  const sourceClosure = candidate.sourceClosure;
9585
9625
  if (Array.isArray(sourceClosure) && sourceClosure.some((path) => typeof path !== "string")) {
9586
- return invalid2("receipt.sourceClosure");
9626
+ return invalid2("receipt.sourceClosure", sourceClosure);
9587
9627
  }
9588
- if (expected.layoutIdentity !== void 0 && candidate.layoutIdentity !== expected.layoutIdentity) {
9589
- return invalid2("receipt.layoutIdentity");
9628
+ if (expected.layoutIdentity !== void 0 && identity.layoutIdentity !== expected.layoutIdentity) {
9629
+ return invalid2("receipt.identity.layoutIdentity", identity.layoutIdentity);
9590
9630
  }
9591
- if (expected.artifactDigest !== void 0 && candidate.outputDigest !== expected.artifactDigest) {
9592
- return invalid2("receipt.outputDigest");
9631
+ if (expected.artifactDigest !== void 0 && identity.artifactDigest !== expected.artifactDigest) {
9632
+ return invalid2("receipt.identity.artifactDigest", identity.artifactDigest);
9593
9633
  }
9594
- if (expected.inputDigest !== void 0 && candidate.inputDigest !== expected.inputDigest) {
9595
- return invalid2("receipt.inputDigest");
9596
- }
9597
- if (candidate.publicationGeneration !== void 0 && (typeof candidate.publicationGeneration !== "number" || !Number.isSafeInteger(candidate.publicationGeneration) || candidate.publicationGeneration < 1)) {
9598
- return invalid2("receipt.publicationGeneration");
9634
+ if (expected.inputDigest !== void 0 && identity.cookIdentity !== expected.inputDigest) {
9635
+ return invalid2("receipt.identity.cookIdentity", identity.cookIdentity);
9599
9636
  }
9600
9637
  return ok({
9601
- schemaVersion: "material-cook/2",
9638
+ schemaVersion: "material-cook/3",
9602
9639
  sourceClosure: candidate.sourceClosure,
9603
9640
  profile: candidate.profile,
9604
9641
  compilerVersion: candidate.compilerVersion,
9605
- inputDigest: candidate.inputDigest,
9606
- outputDigest: candidate.outputDigest,
9607
- layoutIdentity: candidate.layoutIdentity,
9608
- derivedInterface: { layoutIdentity: derivedInterface.layoutIdentity },
9609
- ...candidate.publicationGeneration === void 0 ? {} : { publicationGeneration: candidate.publicationGeneration }
9642
+ identity,
9643
+ derivedInterface: { layoutIdentity: derivedInterface.layoutIdentity }
9610
9644
  });
9611
9645
  }
9612
9646
  function validateCookedMaterialRecord(value) {
9613
9647
  if (value === null || typeof value !== "object") return invalid2("record");
9614
9648
  const candidate = value;
9615
- if (candidate.schemaVersion !== "material-cook/2") return invalid2("schemaVersion");
9649
+ if (candidate.schemaVersion !== "material-cook/3")
9650
+ return invalid2("schemaVersion", candidate.schemaVersion);
9616
9651
  if (typeof candidate.guid !== "string" || !candidate.guid) return invalid2("guid");
9617
9652
  if (candidate.materialGuid !== void 0 && typeof candidate.materialGuid !== "string")
9618
9653
  return invalid2("materialGuid");
9619
- if (candidate.publicationGeneration !== void 0 && (typeof candidate.publicationGeneration !== "number" || !Number.isSafeInteger(candidate.publicationGeneration) || candidate.publicationGeneration < 1))
9620
- return invalid2("publicationGeneration");
9654
+ if (candidate.publicationGeneration !== void 0 && !isGeneration(candidate.publicationGeneration))
9655
+ return invalid2("publicationGeneration", candidate.publicationGeneration);
9621
9656
  if (candidate.specializationKey !== void 0 && typeof candidate.specializationKey !== "string")
9622
9657
  return invalid2("specializationKey");
9623
9658
  if (candidate.artifactDigest !== void 0 && typeof candidate.artifactDigest !== "string")
@@ -9649,9 +9684,9 @@ function validateCookedMaterialRecord(value) {
9649
9684
  });
9650
9685
  if (!receiptResult.ok) return receiptResult;
9651
9686
  if (candidate.artifactDigest !== void 0 && candidate.artifactDigest !== artifact.digest)
9652
- return invalid2("artifactDigest");
9653
- if (candidate.publicationGeneration !== void 0 && receiptResult.value.publicationGeneration !== candidate.publicationGeneration)
9654
- return invalid2("receipt.publicationGeneration");
9687
+ return invalid2("artifactDigest", candidate.artifactDigest);
9688
+ if (candidate.publicationGeneration !== void 0 && receiptResult.value.identity.cookGeneration !== candidate.publicationGeneration)
9689
+ return invalid2("receipt.identity.cookGeneration", receiptResult.value.identity.cookGeneration);
9655
9690
  const normalized = {
9656
9691
  ...candidate,
9657
9692
  artifact: {
@@ -10163,6 +10198,6 @@ function createRuntimePackPublication(input) {
10163
10198
  };
10164
10199
  }
10165
10200
 
10166
- export { MESH_BIN_DIGEST_BYTES, MESH_BIN_HEADER_V4_BYTES, MESH_BIN_PROJECTION_VERSION, MESH_BIN_VERSION, SCRIPTABLE_PACK_ASSET_KINDS, SCRIPTABLE_PACK_CAPABILITY_MANIFEST, STANDARD_SCRIPTABLE_PACK_SCAN_OPTIONS, buildCatalogProjection, buildOfflineAssetEvidence, calculateCatalogDelta, calculateTopologyDiff, catalogProjectionFor, collectMaterialCookRefs, createMaterialArtifactDigest, createRuntimePackPublication, currentProjectionFor, decodeMeshBinHeader, diffTopology, finalizePackageProduct, finalizePackageTransportSource, findReservedAssetKindConflict, isScriptablePackAssetKind, metaPathForGuid, packageTransportRevision, packageVerification, parsePackV2, projectCookedMaterialRecord, projectCookedPackageEntry, projectExternalCatalogEntries, projectPackageCatalog, projectRuntimeCatalogRow, projectScriptablePackMeta, projectScriptablePackSceneComponents, scanInventory, serializeCookedMaterialRecord, serializeMaterialCookReceipt, upgradeLegacyAuthoredPack, validateArtifactPath, validateCookedMaterialRecord, validateMaterialCookReceipt, validateMeta, validatePack, validatePackV2, validateProducerContract, validateProducerOutputs, validateScriptablePackDefinition, writeMeshBinHeader };
10201
+ export { MESH_BIN_DIGEST_BYTES, MESH_BIN_HEADER_V4_BYTES, MESH_BIN_PROJECTION_VERSION, MESH_BIN_VERSION, SCRIPTABLE_PACK_ASSET_KINDS, SCRIPTABLE_PACK_CAPABILITY_MANIFEST, STANDARD_SCRIPTABLE_PACK_SCAN_OPTIONS, buildCatalogProjection, buildOfflineAssetEvidence, calculateCatalogDelta, calculateTopologyDiff, catalogProjectionFor, collectMaterialCookRefs, createMaterialArtifactDigest, createRuntimePackPublication, currentProjectionFor, decodeMeshBinHeader, diffTopology, finalizePackageProduct, finalizePackageTransportSource, findReservedAssetKindConflict, isScriptablePackAssetKind, loadAssetConfig, metaPathForGuid, packageTransportRevision, packageVerification, parsePackV2, projectCookedMaterialRecord, projectCookedPackageEntry, projectExternalCatalogEntries, projectPackageCatalog, projectRuntimeCatalogRow, projectScriptablePackMeta, projectScriptablePackSceneComponents, resolveAssetSource, scanInventory, serializeCookedMaterialRecord, serializeMaterialCookReceipt, upgradeLegacyAuthoredPack, validateArtifactPath, validateCookedMaterialRecord, validateMaterialCookReceipt, validateMeta, validatePack, validatePackV2, validateProducerContract, validateProducerOutputs, validateScriptablePackDefinition, writeMeshBinHeader };
10167
10202
  //# sourceMappingURL=build.mjs.map
10168
10203
  //# sourceMappingURL=build.mjs.map