| 12345678910111213141516171819202122232425 |
- import { VideoInputSchema } from "../types/scene.js";
- import type { VideoInput } from "../types/scene.js";
- export type InputFormat = "valid-schema" | "invalid-json" | "non-json";
- export interface DetectResult {
- format: InputFormat;
- parsed?: VideoInput;
- }
- export function detectInputFormat(text: string): DetectResult {
- let parsed: unknown;
- try {
- parsed = JSON.parse(text);
- } catch {
- return { format: "non-json" };
- }
- const result = VideoInputSchema.safeParse(parsed);
- if (result.success) {
- return { format: "valid-schema", parsed: result.data };
- }
- return { format: "invalid-json" };
- }
|