12773e125a
Token auto-refresh (middleware): - Proactively refresh fr_access when < 120s remain — no more silent 15-min kick - Inlines /v1/auth/refresh call in middleware, stamps new cookies on response - /admin/* protected: is_admin JWT claim required, else redirect /dashboard - apiFetch() (src/lib/api/fetch.ts): client-side 401 → auto-refresh → retry; de-duplicates concurrent refresh calls; redirects to /auth on failure Studio → Render V2 wiring: - scenes[] no longer sent to POST /api/render (V2 render-svc fetches project from Studio service via saved_project_id directly) - renderRequestSchema.scenes is now optional - RenderModal uses apiFetch for auto-refresh on 401 during polling Admin panel (/admin/*): - Admin layout: server-side is_admin guard + top nav (Nodes, Render Queue) - /admin/nodes: lists all nodes from GET /v1/nodes with status badges, heartbeat age, slot usage, tags; Drain (PATCH status=Draining) + Release actions - /admin/renders: render job table with step filter tabs; progress bars, error messages, Retry + Cancel per-row actions; polls GET /v1/renders - API proxy routes: /api/admin/nodes/:id/drain|release, /api/admin/renders/:id/retry|cancel — all validate is_admin in JWT before proxying Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
59 lines
1.6 KiB
TypeScript
59 lines
1.6 KiB
TypeScript
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),
|
|
// 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(),
|
|
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 },
|
|
};
|