2026-05-24 17:37:21 +03:30
|
|
|
import { z } from "zod";
|
|
|
|
|
|
|
|
|
|
export const layerSchema = z.object({
|
|
|
|
|
id: z.string(),
|
|
|
|
|
type: z.enum(["text", "image", "video", "shape"]),
|
|
|
|
|
x: z.number(),
|
|
|
|
|
y: z.number(),
|
|
|
|
|
width: z.number(),
|
|
|
|
|
height: z.number(),
|
|
|
|
|
rotation: z.number(),
|
|
|
|
|
opacity: z.number(),
|
|
|
|
|
zIndex: z.number(),
|
|
|
|
|
props: z.record(z.string(), z.unknown()),
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
export const sceneSchema = z.object({
|
|
|
|
|
id: z.string(),
|
|
|
|
|
name: z.string(),
|
|
|
|
|
duration: z.number().positive(),
|
|
|
|
|
layers: z.array(layerSchema),
|
|
|
|
|
thumbnailUrl: z.string().optional(),
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
export const renderSettingsSchema = z.object({
|
|
|
|
|
resolution: z.enum(["720p", "1080p", "4K"]),
|
|
|
|
|
format: z.literal("mp4").default("mp4"),
|
|
|
|
|
fps: z.union([z.literal(24), z.literal(30), z.literal(60)]),
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
export const renderRequestSchema = z.object({
|
|
|
|
|
projectId: z.string().min(1),
|
2026-06-01 13:42:30 +03:30
|
|
|
// scenes is no longer sent to the server — V2 render service fetches the
|
|
|
|
|
// project directly from the Studio service via saved_project_id.
|
|
|
|
|
scenes: z.array(sceneSchema).optional(),
|
2026-05-24 17:37:21 +03:30
|
|
|
settings: renderSettingsSchema,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
export type RenderRequest = z.infer<typeof renderRequestSchema>;
|
|
|
|
|
export type RenderSettings = z.infer<typeof renderSettingsSchema>;
|
|
|
|
|
export type RenderScene = z.infer<typeof sceneSchema>;
|
|
|
|
|
|
|
|
|
|
export const renderStatusSchema = z.enum([
|
|
|
|
|
"queued",
|
|
|
|
|
"processing",
|
|
|
|
|
"completed",
|
|
|
|
|
"failed",
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
export type RenderJobStatus = z.infer<typeof renderStatusSchema>;
|
|
|
|
|
|
|
|
|
|
export const RESOLUTION_DIMENSIONS: Record<
|
|
|
|
|
RenderSettings["resolution"],
|
|
|
|
|
{ width: number; height: number }
|
|
|
|
|
> = {
|
|
|
|
|
"720p": { width: 1280, height: 720 },
|
|
|
|
|
"1080p": { width: 1920, height: 1080 },
|
|
|
|
|
"4K": { width: 3840, height: 2160 },
|
|
|
|
|
};
|