mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-10-30 09:16:55 +00:00
fix(cli): media-treatment finds an area by the name its overview prints (#6675)
* fix(cli): media-treatment finds an area by the name its overview prints * fix(cli): drop the comment lines the ratchet counts
This commit is contained in:
@@ -165,10 +165,21 @@ describe("applyMediaTreatmentToHtml", () => {
|
||||
);
|
||||
});
|
||||
|
||||
it("resolves every name the overview prints for an area to that area", () => {
|
||||
const correction = getMediaTreatmentCapabilityDetail("correction");
|
||||
expect(correction).toMatchObject({ id: "correction" });
|
||||
expect(getMediaTreatmentCapabilityDetail("Adjust")).toEqual(correction);
|
||||
expect(getMediaTreatmentCapabilityDetail("adjust")).toEqual(correction);
|
||||
expect(getMediaTreatmentCapabilityDetail("Color Grading")).toMatchObject({ id: "grading" });
|
||||
expect(() => getMediaTreatmentCapabilityDetail("adjustments")).toThrow(
|
||||
/Unknown media-treatment capability/,
|
||||
);
|
||||
});
|
||||
|
||||
it("lists the area ids the lookup accepts when a capability is unknown", () => {
|
||||
let message = "";
|
||||
try {
|
||||
getMediaTreatmentCapabilityDetail("adjust");
|
||||
getMediaTreatmentCapabilityDetail("adjustments");
|
||||
} catch (error) {
|
||||
message = error instanceof Error ? error.message : String(error);
|
||||
}
|
||||
|
||||
@@ -90,6 +90,16 @@ export function getMediaTreatmentCapabilityOverview() {
|
||||
};
|
||||
}
|
||||
|
||||
const FAMILY_PAYLOAD_KEY: Record<string, string> = { correction: "adjust" };
|
||||
|
||||
function familyIdFor(name: string): string | undefined {
|
||||
const wanted = name.toLowerCase();
|
||||
return getMediaTreatmentCapabilityOverview().families.find(
|
||||
({ id, label }) =>
|
||||
id === wanted || label.toLowerCase() === wanted || FAMILY_PAYLOAD_KEY[id] === wanted,
|
||||
)?.id;
|
||||
}
|
||||
|
||||
export function getMediaTreatmentCapabilityDetail(id: string): unknown {
|
||||
const capabilities = getHfColorGradingCapabilities();
|
||||
const animation = (path: string) => {
|
||||
@@ -306,6 +316,8 @@ export function getMediaTreatmentCapabilityDetail(id: string): unknown {
|
||||
|
||||
const detail = Object.hasOwn(details, id) ? Reflect.get(details, id) : undefined;
|
||||
if (detail) return detail;
|
||||
const family = familyIdFor(id);
|
||||
if (family && family !== id) return getMediaTreatmentCapabilityDetail(family);
|
||||
const families = [...Object.keys(details), ...capabilities.effectFamilies.map((f) => f.id)];
|
||||
throw new Error(
|
||||
`Unknown media-treatment capability: ${id}. Available areas: ${families.join(", ")}.`,
|
||||
|
||||
Reference in New Issue
Block a user