mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-09-01 19:42:03 +00:00
fix(producer): omit absent render request options
This commit is contained in:
@@ -146,6 +146,21 @@ describe("RenderRequest", () => {
|
||||
}
|
||||
});
|
||||
|
||||
it("omits absent optional options while preserving JSON validation for payloads", () => {
|
||||
const value = createRenderRequest({
|
||||
projectDir: "/project",
|
||||
outputPath: "/output/video.mp4",
|
||||
options: {
|
||||
fps: { num: 30, den: 1 },
|
||||
quality: "standard",
|
||||
format: "mp4",
|
||||
gifLoop: undefined,
|
||||
},
|
||||
});
|
||||
|
||||
expect(value.options).not.toHaveProperty("gifLoop");
|
||||
});
|
||||
|
||||
it("rejects malformed optional and distributed fields", () => {
|
||||
const value = request();
|
||||
expect(() =>
|
||||
|
||||
@@ -204,6 +204,10 @@ function assertNonEmptyPath(value: unknown, field: "projectDir" | "outputPath"):
|
||||
}
|
||||
}
|
||||
|
||||
function omitUndefinedProperties<T extends object>(value: T): T {
|
||||
return Object.fromEntries(Object.entries(value).filter(([, item]) => item !== undefined)) as T;
|
||||
}
|
||||
|
||||
function assertRenderRequest(value: unknown): asserts value is RenderRequest {
|
||||
if (!isPlainObject(value) || value.version !== RENDER_REQUEST_VERSION) {
|
||||
const version = isPlainObject(value) ? value.version : undefined;
|
||||
@@ -232,7 +236,7 @@ export function createRenderRequest(input: CreateRenderRequestInput): RenderRequ
|
||||
projectDir: input.projectDir,
|
||||
outputPath: input.outputPath,
|
||||
options: {
|
||||
...input.options,
|
||||
...omitUndefinedProperties(input.options),
|
||||
engineConfig: input.engineConfig ?? resolveConfig(input.engineOverrides),
|
||||
},
|
||||
} satisfies RenderRequest;
|
||||
|
||||
Reference in New Issue
Block a user