@forgeax/engine-pack 0.1.6 → 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/README.md +12 -1
- package/dist/.tsbuildinfo +1 -1
- package/dist/build.mjs +76 -41
- package/dist/build.mjs.map +1 -1
- package/dist/cli-asset.mjs.map +1 -1
- package/dist/evidence/material-cook.d.ts +28 -6
- package/dist/evidence/material-cook.d.ts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +97 -42
- package/dist/index.mjs.map +1 -1
- package/dist/material-cook.d.ts +1 -1
- package/dist/material-cook.d.ts.map +1 -1
- package/dist/material-cook.mjs +96 -41
- package/dist/material-cook.mjs.map +1 -1
- package/package.json +3 -3
- package/src/__tests__/material-cook-dependencies.unit.test.ts +67 -0
- package/src/__tests__/material-cook-receipt.unit.test.ts +77 -20
- package/src/__tests__/material-cook-schema.unit.test.ts +64 -10
- package/src/__tests__/pack-v2-fixture-migration.test.ts +24 -1
- package/src/evidence/material-cook.ts +133 -54
- package/src/index.ts +4 -0
- package/src/material-cook.ts +2 -0
- package/src/schema/material-cook.schema.json +48 -8
package/dist/build.mjs
CHANGED
|
@@ -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/
|
|
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: {
|
|
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/
|
|
9562
|
-
|
|
9563
|
-
|
|
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 !==
|
|
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 &&
|
|
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 &&
|
|
9592
|
-
return invalid2("receipt.
|
|
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 &&
|
|
9595
|
-
return invalid2("receipt.
|
|
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/
|
|
9638
|
+
schemaVersion: "material-cook/3",
|
|
9602
9639
|
sourceClosure: candidate.sourceClosure,
|
|
9603
9640
|
profile: candidate.profile,
|
|
9604
9641
|
compilerVersion: candidate.compilerVersion,
|
|
9605
|
-
|
|
9606
|
-
|
|
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/
|
|
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 &&
|
|
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.
|
|
9654
|
-
return invalid2("receipt.
|
|
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: {
|