import {z} from 'zod' export type OverlayAnimationCurve = 'linear' | 'smooth' | 'natural' | 'slow_down' | 'accelerate' | 'elastic' | 'bounce' | 'overshoot' | 'impulse' | 'swing' | 'custom' | 'spring'; export type OverlayAnimationSpring = {damping: number, mass: number, stiffness: number}; export type OverlayAnimationEasingInput = {bezier?: (Array) | undefined, curve: OverlayAnimationCurve, intensity?: number | undefined, spring?: OverlayAnimationSpring | undefined}; export type OverlayAnimationPreset = 'fade' | 'slide_up' | 'slide_down' | 'slide_left' | 'slide_right' | 'mask_up' | 'mask_down' | 'grow' | 'shrink' | 'blur' | 'blur_slide_up'; export type OverlayAnimationTextInput = {delayMs?: number | undefined, order?: ('forward' | 'backward' | 'center' | 'edges' | 'random') | undefined, smoothing?: ('linear' | 'smooth' | 'natural' | 'slow_down' | 'accelerate' | 'elastic' | 'overshoot' | 'impulse' | 'swing') | undefined, unit: 'letters' | 'words' | 'lines'}; export type OverlayAnimationSideInput = {blur?: number | undefined, clip?: boolean | undefined, durationMs?: number | undefined, easing?: OverlayAnimationEasingInput | undefined, moveX?: number | undefined, moveY?: number | undefined, opacity?: number | undefined, preset?: OverlayAnimationPreset | undefined, rotate?: number | undefined, scale?: number | undefined, text?: OverlayAnimationTextInput | undefined}; export type OverlayAnimationInput = {intro?: (OverlayAnimationSideInput | null) | undefined, motionBlur?: boolean | undefined, outro?: (OverlayAnimationSideInput | null) | undefined, textIntro?: (OverlayAnimationSideInput | null) | undefined, textOutro?: (OverlayAnimationSideInput | null) | undefined}; export type TextOverlayBackground = {color: string, type: 'solid'}; export type TextOverlayBackgroundPadding = number; export type TextOverlayBackgroundShape = 'none' | 'regular' | 'squircle'; export type OverlayDepth = 'front' | 'behind_presenter'; export type OverlayDepthChanges = Array<{atMs: number, depth: OverlayDepth}>; export type OverlayDimensions = {height: number, width: number}; export type TextOverlayFontFamily = 'Inter' | 'Roboto Mono' | 'Archivo' | 'Barlow' | 'Caveat' | 'DM Sans' | 'Figtree' | 'Lora' | 'Merriweather' | 'Montserrat' | 'Nunito Sans' | 'Open Sans' | 'Oswald' | 'Playfair Display' | 'Poppins' | 'Raleway' | 'Roboto' | 'Roboto Flex' | 'Source Sans 3' | 'Space Grotesk'; export type TextOverlayFontId = string; export type TextOverlayLetterSpacing = number; export type TextOverlayOutline = string | null; export type OverlayPoint = {xPct: number, yPct: number}; export type TextOverlayShadow = 'none' | 'subtle' | 'deep'; export type TextOverlayTextAlign = 'left' | 'center' | 'right'; export type TransitionStyle = 'smooth' | 'hard_cut'; export type ZoomFocusPoint = {xPct: number, yPct: number}; export type MaskDimensions = {heightPct: number, widthPct: number}; export type MaskPoint = {xPct: number, yPct: number}; export type ShapeBorder = {color: string, width: number} | null; export type ClipBackground = {color?: (string | null) | undefined, gradientAngle?: (number | null) | undefined, gradientColor1?: (string | null) | undefined, gradientColor2?: (string | null) | undefined, imageUrl?: (string | null) | undefined, shaderGradientPreset?: (string | null) | undefined, sourceId?: (string | null) | undefined, type: 'solid' | 'gradient' | 'image' | 'video' | 'shaderGradient' | 'ambient', videoDurationSeconds?: (number | null) | undefined, videoUrl?: (string | null) | undefined}; export type ShapeType = 'square' | 'circle' | 'triangle' | 'diamond' | 'star' | 'hexagon' | 'arrow' | 'path'; export type ClipLayoutCrop = {bottom: number, left: number, right: number, top: number}; export type CustomLayoutDimensions = {height: number, width: number}; export type CustomLayoutPoint = {x: number, y: number}; export type CustomLayoutSlot = {corners?: ('none' | 'regular' | 'squircle') | undefined, dimensions?: CustomLayoutDimensions | undefined, hidden?: boolean | undefined, order?: number | undefined, point?: CustomLayoutPoint | undefined, shape?: ('none' | 'circle' | 'square' | 'portrait' | 'cutout' | 'blob' | 'blob-outline') | undefined}; export type ClipLayoutShape = {kind: 'fullscreen', screenFit?: ('cover' | 'letterbox') | undefined, style?: ('regular' | 'stretch') | undefined} | {kind: 'middle', shape?: ('circle' | 'square' | 'landscape' | 'portrait') | undefined} | {kind: 'side-by-side', position: 'left' | 'right' | 'top' | 'bottom', size?: ('S' | 'M' | 'L') | undefined, style: 'regular' | 'even' | 'overlap' | 'perspective'} | {kind: 'tv-presenter', position: 'left' | 'right', style: 'regular' | 'full' | 'overlap'} | {kind: 'cut-out', position?: ('left' | 'right') | undefined, style?: ('regular' | 'perspective') | undefined} | {kind: 'camera-bubble', position: 'left' | 'right' | 'top' | 'bottom' | 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right' | 'middle', screenFit?: ('cover' | 'letterbox') | undefined, shape?: ('circle' | 'square' | 'landscape' | 'portrait') | undefined, size: 'S' | 'M' | 'L', style?: ('regular' | 'full') | undefined} | {kind: 'camera-only', punchIn?: boolean | undefined, shape?: ('circle' | 'square' | 'landscape' | 'portrait') | undefined, style: 'fullscreen' | 'middle'} | {kind: 'screen-only', screenFit?: ('cover' | 'letterbox') | undefined, style: 'fullscreen' | 'middle'} | {kind: 'custom', presentation?: CustomLayoutSlot | undefined, subject?: CustomLayoutSlot | undefined}; export type ClipMedia = {slot?: ('screen' | 'camera') | undefined, sourceId: string, type: 'image'} | {muted?: boolean | undefined, slot?: ('screen' | 'camera') | undefined, sourceId: string, startTimeMs?: number | undefined, type: 'video'} | {muted?: boolean | undefined, slot?: ('screen' | 'camera') | undefined, startTimeMs: number, type: 'recording'} | {documentId: string, slot?: ('screen' | 'camera') | undefined, type: 'motion'}; export type ClipPopOut = {amount?: number | undefined, background?: ('original' | 'color') | undefined, color?: string | undefined, outlineColor?: string | undefined, outlineWidth?: number | undefined}; export type LayoutTransitionStyle = 'spring' | 'hardCut'; export type VideoEditOperation = {clipId: string, durationMs: number, name?: string | undefined, operationId: string, presetId?: string | undefined, sourceId?: string | undefined, startTimeMs: number, type: 'add_sound_effect', volume?: number | undefined} | {animation?: OverlayAnimationInput | undefined, background?: TextOverlayBackground | undefined, backgroundPadding?: TextOverlayBackgroundPadding | undefined, backgroundShape?: TextOverlayBackgroundShape | undefined, clipId: string, color?: string | undefined, depth?: OverlayDepth | undefined, depthChanges?: OverlayDepthChanges | undefined, dimensions?: OverlayDimensions | undefined, durationMs: number, fontFamily?: TextOverlayFontFamily | undefined, fontId?: TextOverlayFontId | undefined, fontSize?: number | undefined, fontWeight?: number | undefined, fontWidth?: number | undefined, letterSpacing?: TextOverlayLetterSpacing | undefined, operationId: string, outline?: TextOverlayOutline | undefined, point?: OverlayPoint | undefined, presetId?: string | undefined, shadow?: TextOverlayShadow | undefined, startTimeMs: number, text: string, textAlign?: TextOverlayTextAlign | undefined, transition?: TransitionStyle | undefined, type: 'add_text_overlay'} | {clipId: string, durationMs: number, focusPoint?: ZoomFocusPoint | undefined, operationId: string, scale: number, startTimeMs: number, type: 'add_zoom', zoomType: 'manualZoom' | 'trackingZoom'} | {clipId: string, dimensions: MaskDimensions, durationMs: number, intensity?: number | undefined, operationId: string, point: MaskPoint, startTimeMs: number, transition?: TransitionStyle | undefined, type: 'add_blur'} | {clipId: string, dimensions: MaskDimensions, durationMs: number, intensity?: number | undefined, operationId: string, point: MaskPoint, startTimeMs: number, transition?: TransitionStyle | undefined, type: 'add_highlight'} | {animation?: OverlayAnimationInput | undefined, clipId: string, depth?: OverlayDepth | undefined, depthChanges?: OverlayDepthChanges | undefined, dimensions?: OverlayDimensions | undefined, durationMs: number, motionDocumentId?: string | undefined, name?: string | undefined, operationId: string, point?: OverlayPoint | undefined, sourceId?: string | undefined, startTimeMs: number, transition?: TransitionStyle | undefined, type: 'add_media_overlay'} | {clipId: string, durationMs?: number | undefined, focusPoint?: ZoomFocusPoint | undefined, operationId: string, scale?: number | undefined, startTimeMs?: number | undefined, type: 'update_zoom', zoomId: string, zoomType?: ('manualZoom' | 'trackingZoom') | undefined} | {clipId: string, operationId: string, type: 'remove_zoom', zoomId: string} | {clipId: string, dimensions?: MaskDimensions | undefined, durationMs?: number | undefined, intensity?: number | undefined, maskId: string, operationId: string, point?: MaskPoint | undefined, startTimeMs?: number | undefined, transition?: TransitionStyle | undefined, type: 'update_blur'} | {clipId: string, maskId: string, operationId: string, type: 'remove_blur'} | {clipId: string, dimensions?: MaskDimensions | undefined, durationMs?: number | undefined, intensity?: number | undefined, maskId: string, operationId: string, point?: MaskPoint | undefined, startTimeMs?: number | undefined, transition?: TransitionStyle | undefined, type: 'update_highlight'} | {clipId: string, maskId: string, operationId: string, type: 'remove_highlight'} | {animation?: (OverlayAnimationInput | null) | undefined, clipId: string, depth?: OverlayDepth | undefined, depthChanges?: OverlayDepthChanges | undefined, dimensions?: OverlayDimensions | undefined, durationMs?: number | undefined, operationId: string, overlayId: string, point?: OverlayPoint | undefined, startTimeMs?: number | undefined, transition?: TransitionStyle | undefined, type: 'update_media_overlay', zIndex?: number | undefined} | {clipId: string, operationId: string, overlayId: string, type: 'remove_media_overlay'} | {animation?: (OverlayAnimationInput | null) | undefined, background?: TextOverlayBackground | undefined, backgroundPadding?: TextOverlayBackgroundPadding | undefined, backgroundShape?: TextOverlayBackgroundShape | undefined, clipId: string, color?: string | undefined, depth?: OverlayDepth | undefined, depthChanges?: OverlayDepthChanges | undefined, dimensions?: OverlayDimensions | undefined, durationMs?: number | undefined, fontFamily?: TextOverlayFontFamily | undefined, fontId?: TextOverlayFontId | undefined, fontSize?: number | undefined, fontWeight?: number | undefined, fontWidth?: number | undefined, letterSpacing?: TextOverlayLetterSpacing | undefined, operationId: string, outline?: TextOverlayOutline | undefined, point?: OverlayPoint | undefined, presetId?: string | undefined, shadow?: TextOverlayShadow | undefined, startTimeMs?: number | undefined, text?: string | undefined, textAlign?: TextOverlayTextAlign | undefined, textOverlayId: string, transition?: TransitionStyle | undefined, type: 'update_text_overlay', zIndex?: number | undefined} | {clipId: string, operationId: string, textOverlayId: string, type: 'remove_text_overlay'} | {animation?: OverlayAnimationInput | undefined, border?: ShapeBorder | undefined, clipId: string, corners?: TextOverlayBackgroundShape | undefined, depth?: OverlayDepth | undefined, depthChanges?: OverlayDepthChanges | undefined, dimensions?: OverlayDimensions | undefined, durationMs: number, fill?: ClipBackground | undefined, name?: string | undefined, operationId: string, path?: string | undefined, point?: OverlayPoint | undefined, shadow?: TextOverlayShadow | undefined, shapeType?: ShapeType | undefined, startTimeMs: number, transition?: TransitionStyle | undefined, type: 'add_shape_overlay'} | {animation?: (OverlayAnimationInput | null) | undefined, border?: ShapeBorder | undefined, clipId: string, corners?: TextOverlayBackgroundShape | undefined, depth?: OverlayDepth | undefined, depthChanges?: OverlayDepthChanges | undefined, dimensions?: OverlayDimensions | undefined, durationMs?: number | undefined, fill?: ClipBackground | undefined, operationId: string, path?: string | undefined, point?: OverlayPoint | undefined, shadow?: TextOverlayShadow | undefined, shapeOverlayId: string, shapeType?: ShapeType | undefined, startTimeMs?: number | undefined, transition?: TransitionStyle | undefined, type: 'update_shape_overlay', zIndex?: number | undefined} | {clipId: string, operationId: string, shapeOverlayId: string, type: 'remove_shape_overlay'} | {clipId: string, durationMs?: number | undefined, operationId: string, soundEffectId: string, startTimeMs?: number | undefined, type: 'update_sound_effect', volume?: number | undefined} | {clipId: string, operationId: string, soundEffectId: string, type: 'remove_sound_effect'} | {cameraStyle?: ('none' | 'circle' | 'square' | 'portrait' | 'cutout' | 'blob' | 'blob-outline' | null) | undefined, clipId: string, crop?: (ClipLayoutCrop | null) | undefined, durationMs?: number | undefined, layout?: ClipLayoutShape | undefined, media?: ClipMedia | undefined, operationId: string, popOut?: (ClipPopOut | null) | undefined, startTimeMs?: number | undefined, transitionStyle?: LayoutTransitionStyle | undefined, type: 'add_layout'} | {cameraStyle?: ('none' | 'circle' | 'square' | 'portrait' | 'cutout' | 'blob' | 'blob-outline' | null) | undefined, clipId: string, crop?: (ClipLayoutCrop | null) | undefined, durationMs?: number | undefined, layout?: ClipLayoutShape | undefined, layoutId: string, media?: ClipMedia | undefined, operationId: string, popOut?: (ClipPopOut | null) | undefined, startTimeMs?: number | undefined, transitionStyle?: LayoutTransitionStyle | undefined, type: 'update_layout'} | {clipId: string, layoutId: string, operationId: string, type: 'remove_layout'}; export type ApplyVideoEditsRequest = {operations: Array}; export type CreateApiV1VideosIdEditsArgs = {id: string, body: ApplyVideoEditsRequest}; export type CreateApiV1VideosIdEditsOptions = {baseUrl?: string | undefined, BearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; export const applyVideoEditsResponse = z.object({results: z.array(z.object({id: z.string(), operationId: z.string(), type: z.enum(["sound_effect", "text_overlay", "shape_overlay", "zoom", "blur", "highlight", "media_overlay", "layout"])})), revision: z.number().int().gte(0).lte(9007199254740991)}); 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 }; /** * Apply many video edits * * POST /v1/videos/{id}/edits */ export const createApiV1VideosIdEdits = async (args: CreateApiV1VideosIdEditsArgs, options?: CreateApiV1VideosIdEditsOptions) => { const {baseUrl = "https://api.tella.com", fetch: fetchFn = fetch, BearerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (BearerAuth !== undefined) headers.set('authorization', `Bearer ${BearerAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/v1/videos/${encodeURIComponent(String(args.id))}/edits${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return validateResponse(applyVideoEditsResponse, await res.json()) };