import {z} from 'zod' export type GetApiV1VideosIdClipsClipIdOverlaysArgs = {id: string, clipId: string}; export type GetApiV1VideosIdClipsClipIdOverlaysOptions = {baseUrl?: string | undefined, BearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; export const overlayAnimationCurve = z.enum(["linear", "smooth", "natural", "slow_down", "accelerate", "elastic", "bounce", "overshoot", "impulse", "swing", "custom", "spring"]); export const overlayAnimationSpringOutput = z.object({damping: z.number().gte(1).lte(300), mass: z.number().gte(0.1).lte(10), stiffness: z.number().gte(1).lte(1000)}); export const overlayAnimationEasing = z.object({bezier: z.array(z.union([z.number().gte(0).lte(1), z.number(), z.number().gte(0).lte(1), z.number()])).optional(), curve: overlayAnimationCurve, intensity: z.number().gte(0).lte(1), spring: overlayAnimationSpringOutput.optional()}); export const overlayAnimationPreset = z.enum(["fade", "slide_up", "slide_down", "slide_left", "slide_right", "mask_up", "mask_down", "grow", "shrink", "blur", "blur_slide_up"]); export const overlayAnimationText = z.object({delayMs: z.number().int().gte(0).lte(2000), order: z.enum(["forward", "backward", "center", "edges", "random"]), smoothing: z.enum(["linear", "smooth", "natural", "slow_down", "accelerate", "elastic", "overshoot", "impulse", "swing"]), unit: z.enum(["letters", "words", "lines"])}); export const overlayAnimationSide = z.object({blur: z.number(), clip: z.boolean(), durationMs: z.number().int().gte(-9007199254740991).lte(9007199254740991), easing: overlayAnimationEasing, moveX: z.number(), moveY: z.number(), opacity: z.number(), preset: overlayAnimationPreset.nullable(), rotate: z.number(), scale: z.number(), text: overlayAnimationText.optional()}); export const overlayAnimation = z.object({intro: overlayAnimationSide.nullable(), motionBlur: z.boolean(), outro: overlayAnimationSide.nullable(), textIntro: overlayAnimationSide.nullable(), textOutro: overlayAnimationSide.nullable()}); export const overlayDepth = z.enum(["front", "behind_presenter"]); export const overlayDepthChanges = z.array(z.object({atMs: z.number().gte(0), depth: overlayDepth})); export const overlayDimensionsOutput = z.object({height: z.number().gt(0), width: z.number().gt(0)}); export const overlayPointOutput = z.object({xPct: z.number(), yPct: z.number()}); export const transitionStyle = z.enum(["smooth", "hard_cut"]); export const overlayZIndex = z.number().int().gte(0).lte(9007199254740991); export const clipOverlay = z.object({animation: overlayAnimation.nullable(), depth: overlayDepth, depthChanges: overlayDepthChanges.optional(), dimensions: overlayDimensionsOutput, durationMs: z.number().gte(0), id: z.string(), imageUrl: z.string().nullable().optional(), motionDocumentId: z.string().optional(), name: z.string().nullable().optional(), point: overlayPointOutput, sourceId: z.string().nullable().optional(), startTimeMs: z.number().gte(0), transition: transitionStyle, type: z.enum(["image", "video", "motion"]), zIndex: overlayZIndex}); export const listClipOverlaysResponse = z.object({overlays: z.array(clipOverlay)}); export const validateResponse = async ( schema: { readonly '~standard': { readonly validate: (value: unknown) => ({ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }) | Promise<{ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }> } }, value: unknown ): Promise => { const result = await schema['~standard'].validate(value) if (result.issues !== undefined) { const detail = result.issues .map(({ message, path }) => path?.length ? `${path.map((segment) => String(typeof segment === 'object' ? segment.key : segment)).join('.')}: ${message}` : message ) .join('; ') throw new Error(`Response does not match the schema: ${detail}`, { cause: { issues: result.issues } }) } return result.value }; /** * List overlays on a clip * * GET /v1/videos/{id}/clips/{clipId}/overlays */ export const getApiV1VideosIdClipsClipIdOverlays = async (args: GetApiV1VideosIdClipsClipIdOverlaysArgs, options?: GetApiV1VideosIdClipsClipIdOverlaysOptions) => { const {baseUrl = "https://api.tella.com", fetch: fetchFn = fetch, BearerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (BearerAuth !== undefined) headers.set('authorization', `Bearer ${BearerAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/v1/videos/${encodeURIComponent(String(args.id))}/clips/${encodeURIComponent(String(args.clipId))}/overlays${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return validateResponse(listClipOverlaysResponse, await res.json()) };