mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-11-18 07:50:13 +00:00
* feat(cli): share rendered videos through unified reviews (#7135) * feat(share): attach editable project sources to reviews (#7137) * feat(share): measure local sharing outcomes (#7138) * feat(cli): stage the sixty-day publish transition (#7136) * feat(studio): share review pages from local preview (#7140) Advertise the CLI sharing bridge before bootstrapping it so standalone Studio does not request unsupported routes. Preserve origin and session checks. Budget the intended sharing artifact: clean main packs at 8,060,519 bytes versus 8,162,979 with sharing (8,169,168 in CI). Required policy and Unicode tables, bundled sharing code, and Studio controls account for the growth. Set the packed-only budget to 8,577,627, following the 5% headroom convention; retain the unpacked cap and all package checks. * fix(share): persist refusals and improve CLI retry feedback * fix(ci): restore render diagnostics and include sharing workspace * fix(cli): keep sharing owner error codes stable * fix(share): clarify update feedback and align audience changes * fix(share): clarify updates and avoid scratch-file rerenders * fix(cli): report active shares and preserve update channels * fix(cli): resolve update channel when checking registry * fix(ci): refresh sharing package budgets after rebase * fix(share): require consent before uploading project files
130 lines
4.8 KiB
JavaScript
130 lines
4.8 KiB
JavaScript
import { test } from "node:test";
|
|
import assert from "node:assert/strict";
|
|
import { createHash } from "node:crypto";
|
|
import { readFileSync } from "node:fs";
|
|
import {
|
|
ManifestInvalid,
|
|
parseCanonicalManifest,
|
|
parseManifest,
|
|
} from "../src/sources/manifest.mjs";
|
|
import { overLimit, V1_LIMITS } from "../src/sources/limits.mjs";
|
|
import { excludedFolder, skippedSymlink } from "../src/sources/pathPolicy.mjs";
|
|
|
|
/** Reference vectors for the source manifest format. */
|
|
const vectors = JSON.parse(
|
|
readFileSync(
|
|
new URL("./fixtures/compositionSync/manifest-vectors.json", import.meta.url),
|
|
"utf8",
|
|
),
|
|
);
|
|
|
|
/** @param {() => unknown} run */
|
|
function refusal(run) {
|
|
try {
|
|
run();
|
|
} catch (error) {
|
|
if (error instanceof ManifestInvalid) return error;
|
|
throw error;
|
|
}
|
|
return null;
|
|
}
|
|
|
|
test("the vectors are portable-source-v4's, and there are vectors of every kind", () => {
|
|
assert.equal(vectors.policy_version, "portable-source-v4");
|
|
assert.deepEqual(
|
|
[vectors.valid.length, vectors.invalid.length, vectors.limits.length, vectors.stored.length],
|
|
[11, 147, 5, 8],
|
|
);
|
|
});
|
|
|
|
test("every valid vector builds the server's canonical bytes and manifest_sha256", () => {
|
|
for (const vector of vectors.valid) {
|
|
const manifest = parseManifest(vector.manifest);
|
|
assert.equal(manifest.canonical.toString("utf8"), vector.canonical, vector.name);
|
|
assert.equal(manifest.sha256, vector.manifest_sha256, vector.name);
|
|
assert.equal(
|
|
createHash("sha256").update(Buffer.from(vector.canonical, "utf8")).digest("hex"),
|
|
vector.manifest_sha256,
|
|
);
|
|
assert.equal(manifest.document.files.length, vector.file_count, vector.name);
|
|
const bytes = manifest.document.files.reduce((sum, file) => sum + file.size, 0);
|
|
assert.equal(bytes, vector.project_bytes, vector.name);
|
|
}
|
|
});
|
|
|
|
test("every invalid vector is refused with the server's code and rule", () => {
|
|
for (const vector of vectors.invalid) {
|
|
const error = refusal(() => parseManifest(vector.manifest));
|
|
assert.ok(error, `${vector.name} was accepted`);
|
|
assert.equal(error.code, vector.error.code, vector.name);
|
|
if (vector.error.rule) assert.equal(error.violations[0]?.rule, vector.error.rule, vector.name);
|
|
}
|
|
});
|
|
|
|
test("every limits vector breaks the server's first limit, or none", () => {
|
|
for (const vector of vectors.limits) {
|
|
const manifest = parseManifest(vector.manifest);
|
|
const limits = {
|
|
maxFiles: vector.limits.max_files,
|
|
maxFileBytes: vector.limits.max_file_bytes,
|
|
maxProjectBytes: vector.limits.max_project_bytes,
|
|
maxManifestBytes: vector.limits.max_manifest_bytes,
|
|
};
|
|
const over = overLimit(manifest.document.files, manifest.canonical.length, limits);
|
|
assert.equal(over?.limit ?? null, vector.limit, vector.name);
|
|
}
|
|
});
|
|
|
|
test("every stored vector reads only canonical bytes", () => {
|
|
for (const vector of vectors.stored) {
|
|
const body = Buffer.from(vector.body, "base64");
|
|
const error = refusal(() => parseCanonicalManifest(body));
|
|
assert.equal(error?.code ?? null, vector.error?.code ?? null, vector.name);
|
|
}
|
|
});
|
|
|
|
test("V1 limits are 10,000 files, 5 GiB a file, 10 GiB a project and an 8 MiB manifest", () => {
|
|
assert.deepEqual(V1_LIMITS, {
|
|
maxFiles: 10000,
|
|
maxFileBytes: 5368709120,
|
|
maxProjectBytes: 10737418240,
|
|
maxManifestBytes: 8388608,
|
|
});
|
|
});
|
|
|
|
test("a project over a limit names its biggest files first", () => {
|
|
const files = [
|
|
{ path: "index.html", size: 10 },
|
|
{ path: "assets/b.mp4", size: 6 * 1024 ** 3 },
|
|
{ path: "assets/a.mp4", size: 7 * 1024 ** 3 },
|
|
];
|
|
const over = overLimit(files, 300);
|
|
assert.equal(over?.limit, "file_size");
|
|
assert.equal(over?.actual, 7 * 1024 ** 3);
|
|
assert.deepEqual(
|
|
over?.biggest.map((file) => file.path),
|
|
["assets/a.mp4", "assets/b.mp4", "index.html"],
|
|
);
|
|
});
|
|
|
|
test("a capture skips only folders no included file can be under", () => {
|
|
assert.equal(excludedFolder("node_modules"), true);
|
|
assert.equal(excludedFolder("assets/node_modules"), true);
|
|
assert.equal(excludedFolder(".git"), true);
|
|
assert.equal(excludedFolder(".claude"), true);
|
|
assert.equal(excludedFolder("dist"), true);
|
|
assert.equal(excludedFolder("assets/dist"), false);
|
|
assert.equal(excludedFolder("renders"), true);
|
|
assert.equal(excludedFolder(".hyperframes"), false);
|
|
assert.equal(excludedFolder(".hyperframes/prepared-assets"), false);
|
|
assert.equal(excludedFolder("assets"), false);
|
|
assert.equal(excludedFolder("assets/renders"), false);
|
|
});
|
|
|
|
test("only links under assets/podcast/, in any spelling, are skipped", () => {
|
|
assert.equal(skippedSymlink("assets/podcast/cam-a.mov"), true);
|
|
assert.equal(skippedSymlink("Assets/Podcast/raw/cam-a.mov"), true);
|
|
assert.equal(skippedSymlink("assets/cam-a.mov"), false);
|
|
assert.equal(skippedSymlink("other/assets/podcast/cam-a.mov"), false);
|
|
});
|