Skip to content

🎥 Make videos programmatically with React

Add types

Vlad M31c2b1ea080a
diff --git a/packages/template-ai-video/src/types.ts b/packages/template-ai-video/src/types.ts
new file mode 100644
index 0000000000..0a1bf4b1fb
--- /dev/null
+++ b/packages/template-ai-video/src/types.ts
@@ -0,0 +1,67 @@
+import { z } from "zod";
+
+const BackgroundTransitionTypeSchema = z.union([
+ z.literal("fade"),
+ z.literal("blur"),
+ z.literal("none"),
+]);
+
+const TimelineElementSchema = z.object({
+ startMs: z.number(),
+ endMs: z.number(),
+});
+
+const ElementAnimationSchema = TimelineElementSchema.extend({
+ type: z.union([z.literal("scale"), z.literal("rotate")]),
+ from: z.number(),
+ to: z.number(),
+});
+
+const BackgroundElementSchema = TimelineElementSchema.extend({
+ imageUrl: z.string(),
+ enterTransition: BackgroundTransitionTypeSchema.optional(),
+ exitTransition: BackgroundTransitionTypeSchema.optional(),
+ animations: z.array(ElementAnimationSchema).optional(),
+});
+
+const TextElementSchema = TimelineElementSchema.extend({
+ text: z.string(),
+ position: z.union([
+ z.literal("top"),
+ z.literal("bottom"),
+ z.literal("center"),
+ ]),
+ animations: z.array(ElementAnimationSchema).optional(),
+});
+
+const AudioElementSchema = TimelineElementSchema.extend({
+ audioUrl: z.string(),
+});
+
+const TimelineSchema = z.object({
+ shortTitle: z.string(),
+ elements: z.array(BackgroundElementSchema),
+ text: z.array(TextElementSchema),
+ audio: z.array(AudioElementSchema),
+});
+
+export type BackgroundTransitionType = z.infer<
+ typeof BackgroundTransitionTypeSchema
+>;
+
+export type TimelineElement = z.infer<typeof TimelineElementSchema>;
+export type ElementAnimation = z.infer<typeof ElementAnimationSchema>;
+export type BackgroundElement = z.infer<typeof BackgroundElementSchema>;
+export type TextElement = z.infer<typeof TextElementSchema>;
+export type AudioElement = z.infer<typeof AudioElementSchema>;
+export type Timeline = z.infer<typeof TimelineSchema>;
+
+export {
+ BackgroundTransitionTypeSchema,
+ TimelineElementSchema,
+ ElementAnimationSchema,
+ BackgroundElementSchema,
+ TextElementSchema,
+ AudioElementSchema,
+ TimelineSchema,
+};